Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_sw.c @ 5143:e743b9c3f6d6
Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 31 Jan 2011 23:23:57 -0800 |
parents | da10636e5eca |
children | 31e7f523ab3d |
comparison
equal
deleted
inserted
replaced
5142:57851a238c8f | 5143:e743b9c3f6d6 |
---|---|
47 int firstcolor, int ncolors); | 47 int firstcolor, int ncolors); |
48 static int SW_SetTextureColorMod(SDL_Renderer * renderer, | 48 static int SW_SetTextureColorMod(SDL_Renderer * renderer, |
49 SDL_Texture * texture); | 49 SDL_Texture * texture); |
50 static int SW_SetTextureAlphaMod(SDL_Renderer * renderer, | 50 static int SW_SetTextureAlphaMod(SDL_Renderer * renderer, |
51 SDL_Texture * texture); | 51 SDL_Texture * texture); |
52 static int SW_SetTextureBlendMode(SDL_Renderer * renderer, | |
53 SDL_Texture * texture); | |
54 static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, | 52 static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
55 const SDL_Rect * rect, const void *pixels, | 53 const SDL_Rect * rect, const void *pixels, |
56 int pitch); | 54 int pitch); |
57 static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, | 55 static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
58 const SDL_Rect * rect, int markDirty, void **pixels, | 56 const SDL_Rect * rect, int markDirty, void **pixels, |
84 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | | 82 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | |
85 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | | 83 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
86 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), | 84 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), |
87 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | | 85 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | |
88 SDL_TEXTUREMODULATE_ALPHA), | 86 SDL_TEXTUREMODULATE_ALPHA), |
89 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | | |
90 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), | |
91 14, | 87 14, |
92 { | 88 { |
93 SDL_PIXELFORMAT_INDEX8, | 89 SDL_PIXELFORMAT_INDEX8, |
94 SDL_PIXELFORMAT_RGB555, | 90 SDL_PIXELFORMAT_RGB555, |
95 SDL_PIXELFORMAT_RGB565, | 91 SDL_PIXELFORMAT_RGB565, |
174 renderer->QueryTexturePixels = SW_QueryTexturePixels; | 170 renderer->QueryTexturePixels = SW_QueryTexturePixels; |
175 renderer->SetTexturePalette = SW_SetTexturePalette; | 171 renderer->SetTexturePalette = SW_SetTexturePalette; |
176 renderer->GetTexturePalette = SW_GetTexturePalette; | 172 renderer->GetTexturePalette = SW_GetTexturePalette; |
177 renderer->SetTextureColorMod = SW_SetTextureColorMod; | 173 renderer->SetTextureColorMod = SW_SetTextureColorMod; |
178 renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod; | 174 renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod; |
179 renderer->SetTextureBlendMode = SW_SetTextureBlendMode; | |
180 renderer->UpdateTexture = SW_UpdateTexture; | 175 renderer->UpdateTexture = SW_UpdateTexture; |
181 renderer->LockTexture = SW_LockTexture; | 176 renderer->LockTexture = SW_LockTexture; |
182 renderer->UnlockTexture = SW_UnlockTexture; | 177 renderer->UnlockTexture = SW_UnlockTexture; |
183 renderer->DestroyTexture = SW_DestroyTexture; | 178 renderer->DestroyTexture = SW_DestroyTexture; |
184 | 179 |
185 renderer->info.mod_modes = SW_RenderDriver.info.mod_modes; | 180 renderer->info.mod_modes = SW_RenderDriver.info.mod_modes; |
186 renderer->info.blend_modes = SW_RenderDriver.info.blend_modes; | |
187 renderer->info.num_texture_formats = | 181 renderer->info.num_texture_formats = |
188 SW_RenderDriver.info.num_texture_formats; | 182 SW_RenderDriver.info.num_texture_formats; |
189 SDL_memcpy(renderer->info.texture_formats, | 183 SDL_memcpy(renderer->info.texture_formats, |
190 SW_RenderDriver.info.texture_formats, | 184 SW_RenderDriver.info.texture_formats, |
191 sizeof(renderer->info.texture_formats));; | 185 sizeof(renderer->info.texture_formats));; |
562 | 556 |
563 data->surface.clip_rect.w = data->surface.w = rect.w; | 557 data->surface.clip_rect.w = data->surface.w = rect.w; |
564 data->surface.clip_rect.h = data->surface.h = rect.h; | 558 data->surface.clip_rect.h = data->surface.h = rect.h; |
565 | 559 |
566 /* Draw the points! */ | 560 /* Draw the points! */ |
567 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 561 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
568 renderer->blendMode == SDL_BLENDMODE_MASK) { | |
569 Uint32 color = SDL_MapRGBA(data->surface.format, | 562 Uint32 color = SDL_MapRGBA(data->surface.format, |
570 renderer->r, renderer->g, renderer->b, | 563 renderer->r, renderer->g, renderer->b, |
571 renderer->a); | 564 renderer->a); |
572 | 565 |
573 for (i = 0; i < count; ++i) { | 566 for (i = 0; i < count; ++i) { |
627 | 620 |
628 data->surface.clip_rect.w = data->surface.w = rect.w; | 621 data->surface.clip_rect.w = data->surface.w = rect.w; |
629 data->surface.clip_rect.h = data->surface.h = rect.h; | 622 data->surface.clip_rect.h = data->surface.h = rect.h; |
630 | 623 |
631 /* Draw the points! */ | 624 /* Draw the points! */ |
632 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 625 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
633 renderer->blendMode == SDL_BLENDMODE_MASK) { | |
634 Uint32 color = SDL_MapRGBA(data->surface.format, | 626 Uint32 color = SDL_MapRGBA(data->surface.format, |
635 renderer->r, renderer->g, renderer->b, | 627 renderer->r, renderer->g, renderer->b, |
636 renderer->a); | 628 renderer->a); |
637 | 629 |
638 for (i = 1; i < count; ++i) { | 630 for (i = 1; i < count; ++i) { |
676 clip.x = 0; | 668 clip.x = 0; |
677 clip.y = 0; | 669 clip.y = 0; |
678 clip.w = texture->w; | 670 clip.w = texture->w; |
679 clip.h = texture->h; | 671 clip.h = texture->h; |
680 | 672 |
681 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 673 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
682 renderer->blendMode == SDL_BLENDMODE_MASK) { | |
683 color = SDL_MapRGBA(data->surface.format, | 674 color = SDL_MapRGBA(data->surface.format, |
684 renderer->r, renderer->g, renderer->b, | 675 renderer->r, renderer->g, renderer->b, |
685 renderer->a); | 676 renderer->a); |
686 } | 677 } |
687 | 678 |
703 } | 694 } |
704 | 695 |
705 data->surface.clip_rect.w = data->surface.w = rect.w; | 696 data->surface.clip_rect.w = data->surface.w = rect.w; |
706 data->surface.clip_rect.h = data->surface.h = rect.h; | 697 data->surface.clip_rect.h = data->surface.h = rect.h; |
707 | 698 |
708 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 699 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
709 renderer->blendMode == SDL_BLENDMODE_MASK) { | |
710 status = SDL_DrawRect(&data->surface, NULL, color); | 700 status = SDL_DrawRect(&data->surface, NULL, color); |
711 } else { | 701 } else { |
712 status = SDL_BlendRect(&data->surface, NULL, | 702 status = SDL_BlendRect(&data->surface, NULL, |
713 renderer->blendMode, | 703 renderer->blendMode, |
714 renderer->r, renderer->g, renderer->b, | 704 renderer->r, renderer->g, renderer->b, |
734 clip.x = 0; | 724 clip.x = 0; |
735 clip.y = 0; | 725 clip.y = 0; |
736 clip.w = texture->w; | 726 clip.w = texture->w; |
737 clip.h = texture->h; | 727 clip.h = texture->h; |
738 | 728 |
739 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 729 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
740 renderer->blendMode == SDL_BLENDMODE_MASK) { | |
741 color = SDL_MapRGBA(data->surface.format, | 730 color = SDL_MapRGBA(data->surface.format, |
742 renderer->r, renderer->g, renderer->b, | 731 renderer->r, renderer->g, renderer->b, |
743 renderer->a); | 732 renderer->a); |
744 } | 733 } |
745 | 734 |
760 } | 749 } |
761 | 750 |
762 data->surface.clip_rect.w = data->surface.w = rect.w; | 751 data->surface.clip_rect.w = data->surface.w = rect.w; |
763 data->surface.clip_rect.h = data->surface.h = rect.h; | 752 data->surface.clip_rect.h = data->surface.h = rect.h; |
764 | 753 |
765 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 754 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
766 renderer->blendMode == SDL_BLENDMODE_MASK) { | |
767 status = SDL_FillRect(&data->surface, NULL, color); | 755 status = SDL_FillRect(&data->surface, NULL, color); |
768 } else { | 756 } else { |
769 status = SDL_BlendFillRect(&data->surface, NULL, | 757 status = SDL_BlendFillRect(&data->surface, NULL, |
770 renderer->blendMode, | 758 renderer->blendMode, |
771 renderer->r, renderer->g, renderer->b, | 759 renderer->r, renderer->g, renderer->b, |