Changeset 60:e16e13d8cd68
- Timestamp:
- 12/18/09 20:41:38 (2 years ago)
- Author:
- Thibaut GIRKA <thib@…>
- Branch:
- default
- Message:
-
Replaced SATURATE -> ADD, implemented objComposite, corrected minor things
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r56
|
r60
|
|
| 169 | 169 | if (picture == NULL) return; |
| 170 | 170 | if (attr & UPDATE_POS) { |
| 171 | | if ( (attr & SATURATE) || zoom != -1) { |
| | 171 | if (zoom != -1) { |
| 172 | 172 | int w=0, h=0; |
| 173 | 173 | GetSrcGeom(w,h); |
| … |
… |
|
| 239 | 239 | picture->SetSurfaceRect(Rect(0,0,width,height)); |
| 240 | 240 | } |
| 241 | | if (attr & SATURATE) |
| 242 | | picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); |
| | 241 | if (attr & BLIT_ADD) |
| | 242 | picture->SetSurfaceAttribute(PicBase::BLIT_ADD); |
| 243 | 243 | } else if (gtype == MOJI) { // ¥Æ¥¥¹¥ÈÉÁ²è |
| 244 | 244 | if (print_moji.length() == 0) return; |
| … |
… |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | | picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); |
| 400 | | attr = Attribute(attr | UPDATE_POS | SATURATE); |
| | 399 | attr = Attribute(attr | UPDATE_POS); |
| 401 | 400 | |
| 402 | 401 | const char* buf = data + 16; |
| … |
… |
|
| 632 | 631 | RegisterCommand(1, 33, 1201, "recFill", (CmdImpl) &Grp::impl_recFill); |
| 633 | 632 | RegisterCommand(1, 33, 1100, "recCopy", (CmdImpl) &Grp::impl_recCopy); |
| 634 | | RegisterCommand(1, 33, 1101, "recMaskCopy", NULL); //FIXME |
| | 633 | RegisterCommand(1, 33, 1101, "recMaskCopy", NULL); //TODO: Same thing as recCopy, but using source's alpha |
| 635 | 634 | RegisterCommand(1, 33, 1600, "recAdd", (CmdImpl) &Grp::impl_recAdd); |
| 636 | 635 | RegisterCommand(1, 33, 406, "grpPan", (CmdImpl) &Grp::impl_grpPan); |
| … |
… |
|
| 735 | 734 | RegisterCommand(1, 81, 1020, "objColLevel", NULL); |
| 736 | 735 | RegisterCommand(1, 82, 1020, "objBgColLevel", NULL); |
| 737 | | RegisterCommand(1, 81, 1021, "objComposite", NULL);//(CmdImpl) &Grp::impl_objComposite); //FIXME: May be broken |
| | 736 | RegisterCommand(1, 81, 1021, "objComposite", (CmdImpl) &Grp::impl_objComposite); //FIXME: May be broken |
| 738 | 737 | RegisterCommand(1, 82, 1021, "objBgComposite", (CmdImpl) &Grp::impl_objComposite); |
| 739 | 738 | RegisterCommand(1, 81, 1024, "objSetText", (CmdImpl) &Grp::impl_objSetText); |
| … |
… |
|
| 1554 | 1553 | |
| 1555 | 1554 | //TODO: ??? |
| 1556 | | if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0) { // ??? : KANOGI : ²èÁü¥ª¥Ö¥ž¥§¥¯¥È€Îºïœü¡© |
| | 1555 | if (cmd.cmd1 == 1 && cmd.cmd2 == 60 && cmd.cmd3 == 0) { // ??? : KANOGI : ²èÁü¥ª¥Ö¥ž¥§¥¯¥È€Îºïœü¡© |
| 1557 | 1556 | DeleteObjPic(cmd.args[0].value); // µì¥Õ¥¡¥€¥ëÌŸ€Îsurface€òºïœü |
| 1558 | 1557 | GrpObj& g = grpobj[cmd.args[0].value]; |
| … |
… |
|
| 1561 | 1560 | } |
| 1562 | 1561 | |
| 1563 | | //TODO: ??? |
| 1564 | | if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && cmd.cmd2 == 0x51) { |
| 1565 | | /*GrpObj& g = grpobj[cmd.args[0].value]; |
| 1566 | | int attr; |
| 1567 | | GrpObjMap::iterator it; |
| 1568 | | for (it = g.children_obj.begin(); it != g.children_obj.end(); it++) |
| 1569 | | attr |= it->second.attr; |
| 1570 | | if (attr & GrpObj::UPDATE_ALL) |
| 1571 | | SetObjChanged(cmd.args[0].value);*/ |
| | 1562 | // Refresh changed objects... |
| | 1563 | //FIXME: should may be go away? |
| | 1564 | //Seems it'll work only for objects in the foreground |
| | 1565 | if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && cmd.cmd2 == 81) { |
| 1572 | 1566 | GrpObj* g; |
| 1573 | 1567 | if (cmd.cmd1 == 2) |
-
|
r56
|
r60
|
|
| 82 | 82 | vector<Rect> src_pos; |
| 83 | 83 | enum GrpType { FILLRECT = 1, FILE = 2, GAN = 3, MOJI = 4, DIGIT = 5} gtype; |
| 84 | | enum Attribute { NONE=0, WIPEON=1, SATURATE=2, HIDDEN=4, |
| | 84 | enum Attribute { NONE=0, WIPEON=1, BLIT_ADD=2, HIDDEN=4, |
| 85 | 85 | UPDATE_PICTURE = 16, UPDATE_POS = 32, UPDATE_ALPHA = 64, UPDATE_SNUM = 128, UPDATE_CLIP = 256, UPDATE_VISIBLE = 512, |
| 86 | 86 | UPDATE_ALL = (UPDATE_PICTURE | UPDATE_POS | UPDATE_ALPHA | UPDATE_SNUM | UPDATE_CLIP | UPDATE_VISIBLE), |
-
|
r56
|
r60
|
|
| 157 | 157 | |
| 158 | 158 | void Grp::impl_recCopy(Cmd& cmd) { |
| | 159 | //TODO: Handle forms 0 and 1 |
| 159 | 160 | int sx = cmd.args[0].value; |
| 160 | 161 | int sy = cmd.args[1].value; |
| … |
… |
|
| 174 | 175 | cmd.cmd_type = CMD_SAVECMDGRP; |
| 175 | 176 | } |
| 176 | | |
| 177 | 177 | else if (cmd.cmd4 == 3) { // alpha ã€ãcopy |
| 178 | 178 | unsigned char alpha; |
| … |
… |
|
| 193 | 193 | |
| 194 | 194 | void Grp::impl_recAdd(Cmd& cmd) { |
| 195 | | if (cmd.cmd4 == 3) { // saturate mode ã§ alpha ä»ã copy |
| | 195 | if (cmd.cmd4 == 3) { // add mode ã§ alpha ä»ã copy |
| 196 | 196 | int sx = cmd.args[0].value; |
| 197 | 197 | int sy = cmd.args[1].value; |
| … |
… |
|
| 207 | 207 | else if (cmd.args[8].value > 255) alpha = 255; |
| 208 | 208 | else alpha = cmd.args[8].value; |
| 209 | | eprintf("copy surface w/ saturate %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); |
| | 209 | eprintf("copy surface w/ add %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); |
| 210 | 210 | if (src == dest) { |
| 211 | 211 | DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); |
| … |
… |
|
| 213 | 213 | } |
| 214 | 214 | if (alpha != 0) { |
| 215 | | // saturate mode : screen (picture) ãäžæçã«äœæ |
| | 215 | // add mode : screen (picture) ãäžæçã«äœæ |
| 216 | 216 | PicBase* screen_tmp = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); |
| 217 | | screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_SATURATE); |
| | 217 | screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_ADD); |
| 218 | 218 | screen_tmp->SetSurfaceRect(rect); |
| 219 | 219 | screen_tmp->Move(dx, dy); |
| … |
… |
|
| 351 | 351 | |
| 352 | 352 | if (cmd.cmd3 == 1000) { /* ãã¡ã€ã«åèšå® */ |
| 353 | | g->gtype = GrpObj::FILE; //FIXME: Strange thing in the main menu; that happens with objComposite |
| | 353 | g->gtype = GrpObj::FILE; |
| 354 | 354 | string name = cmd.Str(cmd.args[base_argc + 1]); |
| 355 | 355 | if (name.find('?') != -1) {//TODO |
| … |
… |
|
| 519 | 519 | int base_arg = 0; |
| 520 | 520 | GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); |
| 521 | | |
| 522 | 521 | if (cmd.args[base_arg + 1].value == 1) { |
| 523 | | g->attr = GrpObj::Attribute(g->attr | GrpObj::SATURATE); |
| | 522 | g->attr = GrpObj::Attribute(g->attr | GrpObj::BLIT_ADD); |
| 524 | 523 | cmd.clear(); |
| 525 | 524 | } else if (cmd.args[base_arg + 1].value == 0) { |
| 526 | | g->attr = GrpObj::Attribute(g->attr & (~GrpObj::SATURATE)); |
| | 525 | g->attr = GrpObj::Attribute(g->attr & (~GrpObj::BLIT_ADD)); |
| 527 | 526 | cmd.clear(); |
| 528 | 527 | } |
| … |
… |
|
| 768 | 767 | } |
| 769 | 768 | } |
| | 769 | |
-
|
r53
|
r60
|
|
| 42 | 42 | using namespace std; |
| 43 | 43 | |
| 44 | | int print_blit = 0; |
| 45 | 44 | /* render.cc */ |
| 46 | 45 | void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect); |
| 47 | | void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); |
| | 46 | void DSurfaceBlitAdd(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); |
| 48 | 47 | void DSurfaceBlitMultiply(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); |
| 49 | 48 | void DSurfaceFill(Surface* src, const Rect& rect, int r, int g, int b, int a=0xff); // ¥¯¥ê¥¢ |
| … |
… |
|
| 181 | 180 | Rect abs_r = QueryAbsPos(rpos); |
| 182 | 181 | Rect ppos = parent_pos(rpos); |
| 183 | | if(print_blit) fprintf(stderr,"back."); |
| 184 | 182 | if (parent) parent->BlitBack(z_pos, ppos); |
| 185 | | if(print_blit) fprintf(stderr,"self."); |
| 186 | 183 | if (!is_hidden_now) Blit(rpos); |
| 187 | | if(print_blit) fprintf(stderr,"front."); |
| 188 | 184 | if (parent) parent->BlitFront(z_pos, ppos); |
| 189 | | if(print_blit) fprintf(stderr,"end."); |
| 190 | 185 | } |
| 191 | 186 | |
| … |
… |
|
| 325 | 320 | surface_alpha = 0; |
| 326 | 321 | surface_alpha_rect = Rect(0,0); |
| 327 | | attribute &= ~(BLIT_SATURATE | BLIT_MULTIPLY); |
| | 322 | attribute &= ~(BLIT_ADD | BLIT_MULTIPLY); |
| 328 | 323 | if (surface_own) { |
| 329 | 324 | int key = SDL_MapRGB( ((SDL_Surface*)surface_own)->format, r, g, b); |
| … |
… |
|
| 403 | 398 | root->DeleteSurface(surface_own); |
| 404 | 399 | } |
| 405 | | attribute &= ~(SURFACE_FREE | BLIT_SATURATE | BLIT_MULTIPLY | NO_PICTURE | SOLID); |
| | 400 | attribute &= ~(SURFACE_FREE | BLIT_ADD | BLIT_MULTIPLY | NO_PICTURE | SOLID); |
| 406 | 401 | attribute |= new_attr; |
| 407 | 402 | surface_own = new_surface; |
| … |
… |
|
| 470 | 465 | |
| 471 | 466 | void PicBase::SetSurfaceAttribute(int new_attribute) { |
| 472 | | attribute &= ~(BLIT_SATURATE | BLIT_MULTIPLY); |
| 473 | | attribute |= new_attribute & (BLIT_SATURATE | BLIT_MULTIPLY); |
| 474 | | if (new_attribute & (BLIT_SATURATE | BLIT_MULTIPLY)) { |
| | 467 | attribute &= ~(BLIT_ADD | BLIT_MULTIPLY); |
| | 468 | attribute |= new_attribute & (BLIT_ADD | BLIT_MULTIPLY); |
| | 469 | if (new_attribute & (BLIT_ADD | BLIT_MULTIPLY)) { |
| 475 | 470 | rel_solid_area = Rect(0,0); |
| 476 | 471 | } |
| … |
… |
|
| 540 | 535 | Rect apos = (*z)->QueryAbsPos(cpos); |
| 541 | 536 | Rect draw_rpos = (*z)->parent_pos(cpos); |
| 542 | | if(print_blit) fprintf(stderr,"cahce."); |
| 543 | 537 | root->BlitSurface(surface_back, draw_rpos, root->surface, apos); |
| 544 | 538 | goto self_redraw; |
| … |
… |
|
| 547 | 541 | if (parent) { |
| 548 | 542 | Rect ppos = parent_pos(rpos); |
| 549 | | if(print_blit) fprintf(stderr,"parent-back."); |
| 550 | 543 | parent->BlitBack(z_pos, ppos); |
| 551 | 544 | } |
| 552 | 545 | if (is_hidden_now) return; |
| 553 | 546 | self_redraw: |
| 554 | | if(print_blit) fprintf(stderr,"back-self."); |
| 555 | 547 | BlitSelf(rpos); // »Ò€ÏÉÁ²è€»€º¡¢Œ«Ê¬€À€±ÉÁ²è |
| 556 | 548 | children_redraw: |
| … |
… |
|
| 565 | 557 | |
| 566 | 558 | void PicContainer::BlitChildren(Rect rpos) { |
| 567 | | if (print_blit) fprintf(stderr,"bc."); |
| 568 | 559 | iterator end = children.end(); |
| 569 | 560 | for (iterator it = children.begin(); it != end; it++) { |
| 570 | | if ( (*it)->is_hidden_now) if(print_blit) fprintf(stderr,"bch %p;",*it); |
| 571 | 561 | if ( (*it)->is_hidden_now) continue; |
| 572 | 562 | if ( (*it)->rel_pos.is_crossed(rpos)) { |
| … |
… |
|
| 602 | 592 | Rect apos = QueryAbsPos(rpos); |
| 603 | 593 | // ɬÍ׀˱þ€ž€ÆÊÝž¡¢ÉÁ²è |
| 604 | | if(print_blit) fprintf(stderr,"self-back."); |
| 605 | 594 | if (attribute & CACHE_BACK) root->BlitSurface(root->surface, apos, surface_back, rpos); |
| 606 | 595 | if (! (attribute & NO_PICTURE)) { |
| … |
… |
|
| 611 | 600 | rpos.intersect(clip); |
| 612 | 601 | } |
| 613 | | if(print_blit) fprintf(stderr,"self-blit."); |
| 614 | 602 | root->BlitSurface(surface_own, rpos, surface_alpha, surface_alpha_rect, root->surface, apos, attribute); |
| 615 | 603 | } else if (parent == NULL) { // ¿Æ€¬€€€Ê€€€Ê€éÇØ·ÊŸÃµî€ÎÀÕÇ€€ò€â€Ä |
| … |
… |
|
| 895 | 883 | vector<UpdateItem>::iterator end = update_rects.end(); |
| 896 | 884 | |
| 897 | | if(print_blit){ |
| 898 | | fprintf(stderr,"ExecUpdate Start: \n\t"); |
| 899 | | for (it=update_rects.begin(); it != end; it++) { |
| 900 | | fprintf(stderr,"(%d,%d,%d,%d), ",it->apos.lx,it->apos.ty,it->apos.rx,it->apos.by); |
| 901 | | } |
| 902 | | fprintf(stderr,"\n"); |
| 903 | | } |
| 904 | | |
| 905 | 885 | for (it=update_rects.begin(); it != end; it++) { |
| 906 | 886 | if (it->rpos.width() == 0) continue; |
| … |
… |
|
| 926 | 906 | } |
| 927 | 907 | |
| 928 | | if(print_blit){ |
| 929 | | fprintf(stderr,"->\t"); |
| 930 | | for (it=update_rects.begin(); it != end; it++) { |
| 931 | | fprintf(stderr,"(%d,%d,%d,%d), ",it->apos.lx,it->apos.ty,it->apos.rx,it->apos.by); |
| 932 | | } |
| 933 | | fprintf(stderr,"\n"); |
| 934 | | } |
| 935 | | |
| 936 | 908 | int num = update_rects.size(); |
| 937 | 909 | SDL_Rect* r = new SDL_Rect[num]; |
| … |
… |
|
| 943 | 915 | Rect& ur = item.apos; |
| 944 | 916 | if (ur.width() == 0) continue; |
| 945 | | if(print_blit)fprintf(stderr,"%p: %d,%d,%d,%d",item.pic, item.apos.lx, item.apos.ty, item.apos.rx, item.apos.by); |
| 946 | 917 | |
| 947 | 918 | item.pic->ExecReBlit(item.rpos); |
| 948 | | if(print_blit)fprintf(stderr,"\n"); |
| | 919 | |
| 949 | 920 | ur.intersect(confine); |
| 950 | 921 | r[n].x = ur.lx; |
| … |
… |
|
| 955 | 926 | n++; |
| 956 | 927 | } |
| 957 | | if(print_blit)fprintf(stderr,"\n"); |
| | 928 | |
| 958 | 929 | SDL_UpdateRects(hw_surface, n, r); |
| 959 | 930 | delete[] r; |
| … |
… |
|
| 1017 | 988 | #define ALPHA_MAX 255 |
| 1018 | 989 | #endif |
| 1019 | | void PicRoot::BlitSurface(Surface* src, const Rect& src_r, const unsigned char* alpha, const Rect& alpha_r, Surface* dest, const Rect& dest_r, int attribute) const { |
| 1020 | | if (print_blit) fprintf(stderr," s %p %d:%d:%d:%d;",src, dest_r.lx, dest_r.ty, dest_r.rx, dest_r.by); |
| | 990 | void PicRoot::BlitSurface(Surface* src, const Rect& src_r, const unsigned char* alpha, const Rect& alpha_r, |
| | 991 | Surface* dest, const Rect& dest_r, int attribute) const |
| | 992 | { |
| 1021 | 993 | SDL_Rect sr = SDLed(src_r); SDL_Rect dr = SDLed(dest_r); |
| 1022 | 994 | |
| 1023 | | if (attribute & PicBase::BLIT_MULTIPLY) { |
| 1024 | | if (print_blit) fprintf(stderr,"M"); |
| | 995 | if (attribute & PicBase::BLIT_MULTIPLY) |
| | 996 | { |
| 1025 | 997 | DSurfaceBlitMultiply(src, src_r, dest, dest_r); |
| 1026 | 998 | return; |
| 1027 | | } else if (attribute & PicBase::BLIT_SATURATE && src->format->Amask == 0) { |
| 1028 | | if (print_blit) fprintf(stderr,"S"); |
| | 999 | } |
| | 1000 | else if (attribute & PicBase::BLIT_ADD) |
| | 1001 | { |
| 1029 | 1002 | unsigned char a = 255; |
| 1030 | | if (alpha && alpha_r.width() >= 1 && alpha_r.height() >= 1) a = *alpha; |
| 1031 | | DSurfaceBlitSaturate(src, src_r, dest, dest_r, a); |
| | 1003 | if (alpha != NULL && alpha_r.width() >= 1 && alpha_r.height() >= 1) |
| | 1004 | a = *alpha; |
| | 1005 | DSurfaceBlitAdd(src, src_r, dest, dest_r, a); |
| 1032 | 1006 | return; |
| 1033 | 1007 | } |
| 1034 | 1008 | |
| 1035 | | if (print_blit) fprintf(stderr,"N"); |
| 1036 | | if (alpha == NULL || alpha_r.width() == 0) { // simple blit |
| 1037 | | if (print_blit) fprintf(stderr,"X"); |
| | 1009 | if (alpha == NULL || alpha_r.width() == 0) // simple blit |
| | 1010 | { |
| 1038 | 1011 | SDL_BlitSurface(src, &sr, dest, &dr); |
| 1039 | 1012 | return; |
| … |
… |
|
| 1041 | 1014 | if (alpha_r.width() == 1 && alpha_r.height() == 1) { |
| 1042 | 1015 | if (*alpha == 255) { |
| 1043 | | if (print_blit) fprintf(stderr,"Y"); |
| 1044 | 1016 | SDL_BlitSurface(src, &sr, dest, &dr); |
| 1045 | 1017 | return; |
| 1046 | 1018 | } |
| 1047 | 1019 | if (src->format->Amask == 0) { // use per-surface alpha |
| 1048 | | if (print_blit) fprintf(stderr,"Z"); |
| 1049 | 1020 | SDL_SetAlpha(src, SDL_SRCALPHA, *alpha); |
| 1050 | 1021 | SDL_BlitSurface(src, &sr, dest, &dr); |
| … |
… |
|
| 1054 | 1025 | } |
| 1055 | 1026 | // generic alpha blit |
| 1056 | | if (print_blit) fprintf(stderr,"W"); |
| 1057 | 1027 | DSurfaceBlitAlpha(src, src_r, dest, dest_r, alpha, alpha_r); |
| 1058 | | return; |
| 1059 | 1028 | } |
| 1060 | 1029 | |
-
|
r52
|
r60
|
|
| 72 | 72 | bool is_cached; |
| 73 | 73 | public: |
| 74 | | enum { /*MOBILE=1,*/ CACHE_BACK=2, /* CACHE_SELF=4,*/ NO_PICTURE=8, SOLID = 16, SURFACE_FREE = 32, FIT_SURFACE = 64, BLIT_SATURATE = 128, BLIT_MULTIPLY = 256, ALPHA_FREE=512}; |
| | 74 | enum { /*MOBILE=1,*/ CACHE_BACK=2, /* CACHE_SELF=4,*/ NO_PICTURE=8, SOLID = 16, SURFACE_FREE = 32, FIT_SURFACE = 64, BLIT_ADD = 128, BLIT_MULTIPLY = 256, ALPHA_FREE=512}; |
| 75 | 75 | private: |
| 76 | 76 | int attribute; |
-
|
r56
|
r60
|
|
| 252 | 252 | #define CMASK2 0x00ff00 |
| 253 | 253 | |
| 254 | | inline void blit_pixel(Uint32* dmem, Uint32* smem, const unsigned char* amem, bool use_srcalpha) { |
| 255 | | Uint32 d = *dmem; |
| 256 | | Uint32 s = *smem; |
| 257 | | Uint32 as = s>>ASHIFT; |
| | 254 | inline void blit_pixel(Uint32* dest, Uint32* src, const unsigned char* alpha, bool use_srcalpha) { |
| | 255 | Uint32 dest_value = *dest; |
| | 256 | Uint32 src_value = *src; |
| | 257 | Uint32 as = src_value >> ASHIFT; |
| 258 | 258 | if (as == 255 || (!use_srcalpha) ) { |
| 259 | | as = *amem; |
| | 259 | as = *alpha; |
| 260 | 260 | } else { |
| 261 | | as += as>>7; /* 0-0xff -> 0-0x100 */ |
| 262 | | as *= *amem; |
| | 261 | as += (as >> 7); /* 0-0xff -> 0-0x100 */ |
| | 262 | as *= *alpha; |
| 263 | 263 | as >>= 8; |
| 264 | 264 | } |
| 265 | | as += as>>7; |
| 266 | | Uint32 s1 = s & CMASK1; |
| 267 | | Uint32 d1 = d & CMASK1; |
| 268 | | d1 = (d1 + (((s1-d1) * as) >> 8)) & CMASK1; |
| 269 | | s &= CMASK2; |
| 270 | | d &= CMASK2; |
| 271 | | d = (d + (((s-d) * as) >> 8)) & CMASK2; |
| 272 | | *dmem = d1 | d | 0xff000000; |
| 273 | | } |
| 274 | | |
| 275 | | static void blit_line(Uint32* dmem, Uint32* smem, const unsigned char* amem,int ax0, int ax1, int awidth, int aj0, int aj1, bool use_srcalpha) { |
| | 265 | as += as >> 7; |
| | 266 | // Isolate Red and Blue components |
| | 267 | Uint32 src_c1 = src_value & CMASK1; |
| | 268 | Uint32 dest_c1 = dest_value & CMASK1; |
| | 269 | // Blend Red and Blue components |
| | 270 | dest_c1 = (dest_c1 + (((src_c1-dest_c1) * as) >> 8)) & CMASK1; |
| | 271 | // Isolate Green component |
| | 272 | src_value &= CMASK2; |
| | 273 | dest_value &= CMASK2; |
| | 274 | // Blend Green component |
| | 275 | dest_value = (dest_value + (((src_value-dest_value) * as) >> 8)) & CMASK2; |
| | 276 | // Put it alltogether |
| | 277 | *dest = dest_c1 | dest_value | 0xff000000; |
| | 278 | } |
| | 279 | |
| | 280 | static void blit_line(Uint32* dest, Uint32* src, const unsigned char* alpha,int ax0, int ax1, int awidth, int aj0, int aj1, bool use_srcalpha) { |
| 276 | 281 | int j; |
| 277 | 282 | int ax = ax0; |
| 278 | | const unsigned char* a = amem + ax0; |
| 279 | | Uint32* d = dmem; |
| 280 | | Uint32* s = smem; |
| | 283 | const unsigned char* a = alpha + ax0; |
| 281 | 284 | if (awidth == 1) { // €ï€ê€È€è€¯€¢€ë€Î€ÇºÇŬ²œ |
| 282 | 285 | for (j=aj0; j < aj1; j++) { |
| 283 | | blit_pixel(d++, s++, amem, use_srcalpha); |
| 284 | | } |
| 285 | | } else { |
| | 286 | blit_pixel(dest++, src++, alpha, use_srcalpha); |
| | 287 | } |
| | 288 | } |
| | 289 | else |
| | 290 | { |
| 286 | 291 | for (j=aj0; j < aj1; j++) { |
| 287 | 292 | for (; ax<awidth; ax++) |
| 288 | | blit_pixel(d++, s++, a++, use_srcalpha); |
| | 293 | blit_pixel(dest++, src++, a++, use_srcalpha); |
| 289 | 294 | ax = 0; |
| 290 | | a = amem; |
| 291 | | } |
| 292 | | for (; ax < ax1; ax++) blit_pixel(d++, s++, a++, use_srcalpha); |
| 293 | | } |
| 294 | | } |
| 295 | | |
| 296 | | void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect) { |
| | 295 | a = alpha; |
| | 296 | } |
| | 297 | for (; ax < ax1; ax++) |
| | 298 | blit_pixel(dest++, src++, a++, use_srcalpha); |
| | 299 | } |
| | 300 | } |
| | 301 | |
| | 302 | void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect) |
| | 303 | { |
| 297 | 304 | SDL_Surface* dst = (SDL_Surface*)dst_o; |
| 298 | 305 | SDL_Surface* src = (SDL_Surface*)src_o; |
| … |
… |
|
| 347 | 354 | } |
| 348 | 355 | |
| 349 | | void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, unsigned char alpha) { |
| | 356 | void DSurfaceBlitAdd(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, unsigned char alpha) { |
| 350 | 357 | SDL_Surface* dst = (SDL_Surface*)dst_o; |
| 351 | 358 | SDL_Surface* src = (SDL_Surface*)src_o; |
| … |
… |
|
| 371 | 378 | int gshift = fmt.Gshift - fmt.Gloss; int gmask = fmt.Gmask; |
| 372 | 379 | int bshift = fmt.Bshift - fmt.Bloss; int bmask = fmt.Bmask; |
| | 380 | int ashift = src->format->Ashift - src->format->Aloss; int amask = src->format->Amask; |
| 373 | 381 | int allmask = rmask | gmask | bmask; |
| 374 | | int i; |
| 375 | | for (i=0; i<height; i++) { |
| | 382 | int i, j; |
| | 383 | for (i=0; i < height; i++) { |
| 376 | 384 | char* d = dmem; char* s = smem; |
| 377 | | int j; for (j=0; j<width; j++) { |
| | 385 | for (j=0; j < width; j++) { |
| 378 | 386 | Uint32 sd = *(Uint32*)s; |
| 379 | 387 | Uint32 dd = *(Uint32*)d; |
| … |
… |
|
| 382 | 390 | Uint32 sg = (sd&gmask)>>gshift; |
| 383 | 391 | Uint32 sb = (sd&bmask)>>bshift; |
| 384 | | if (alpha != ALPHA_MAX) { |
| 385 | | sr = (sr*alpha)>>8; |
| 386 | | sg = (sg*alpha)>>8; |
| 387 | | sb = (sb*alpha)>>8; |
| | 392 | Uint32 alpha2 = alpha; |
| | 393 | if (amask) |
| | 394 | { |
| | 395 | alpha2 = ((sd&amask)>>ashift); |
| | 396 | alpha2 += alpha2 >> 7; |
| | 397 | alpha2 *= alpha; |
| | 398 | alpha2 >>= 8; |
| | 399 | } |
| | 400 | |
| | 401 | if (alpha2 != ALPHA_MAX) { |
| | 402 | sr = (sr*alpha2)>>8; |
| | 403 | sg = (sg*alpha2)>>8; |
| | 404 | sb = (sb*alpha2)>>8; |
| 388 | 405 | } |
| 389 | 406 | Uint32 dr = sr + ((dd&rmask)>>rshift); |
-
|
r56
|
r60
|
|
| 39 | 39 | void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); // ¥³¥Ã¡Š|
| 40 | 40 | void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect); |
| 41 | | void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); |
| | 41 | void DSurfaceBlitAdd(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); |
| 42 | 42 | void DSurfaceBlitMultiply(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o); |
| 43 | 43 | |