reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* libs/graphics/sgl/SkCoreBlitters.h |
| 2 | ** |
| 3 | ** Copyright 2006, The Android Open Source Project |
| 4 | ** |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame^] | 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | ** |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame^] | 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | ** |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame^] | 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef SkCoreBlitters_DEFINED |
| 19 | #define SkCoreBlitters_DEFINED |
| 20 | |
| 21 | #include "SkBlitter.h" |
| 22 | #include "SkBlitRow.h" |
| 23 | |
| 24 | class SkRasterBlitter : public SkBlitter { |
| 25 | public: |
| 26 | SkRasterBlitter(const SkBitmap& device) : fDevice(device) {} |
| 27 | |
| 28 | protected: |
| 29 | const SkBitmap& fDevice; |
| 30 | |
| 31 | private: |
| 32 | typedef SkBlitter INHERITED; |
| 33 | }; |
| 34 | |
| 35 | class SkShaderBlitter : public SkRasterBlitter { |
| 36 | public: |
| 37 | SkShaderBlitter(const SkBitmap& device, const SkPaint& paint); |
| 38 | virtual ~SkShaderBlitter(); |
| 39 | |
| 40 | protected: |
reed@android.com | 5119bdb | 2009-06-12 21:27:03 +0000 | [diff] [blame] | 41 | uint32_t fShaderFlags; |
| 42 | SkShader* fShader; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | |
| 44 | private: |
| 45 | // illegal |
| 46 | SkShaderBlitter& operator=(const SkShaderBlitter&); |
| 47 | |
| 48 | typedef SkRasterBlitter INHERITED; |
| 49 | }; |
| 50 | |
| 51 | /////////////////////////////////////////////////////////////////////////////// |
| 52 | |
| 53 | class SkA8_Blitter : public SkRasterBlitter { |
| 54 | public: |
| 55 | SkA8_Blitter(const SkBitmap& device, const SkPaint& paint); |
| 56 | virtual void blitH(int x, int y, int width); |
| 57 | virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); |
| 58 | virtual void blitV(int x, int y, int height, SkAlpha alpha); |
| 59 | virtual void blitRect(int x, int y, int width, int height); |
| 60 | virtual void blitMask(const SkMask&, const SkIRect&); |
| 61 | virtual const SkBitmap* justAnOpaqueColor(uint32_t*); |
| 62 | |
| 63 | private: |
| 64 | unsigned fSrcA; |
| 65 | |
| 66 | // illegal |
| 67 | SkA8_Blitter& operator=(const SkA8_Blitter&); |
| 68 | |
| 69 | typedef SkRasterBlitter INHERITED; |
| 70 | }; |
| 71 | |
| 72 | class SkA8_Shader_Blitter : public SkShaderBlitter { |
| 73 | public: |
| 74 | SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); |
| 75 | virtual ~SkA8_Shader_Blitter(); |
| 76 | virtual void blitH(int x, int y, int width); |
| 77 | virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); |
| 78 | virtual void blitMask(const SkMask&, const SkIRect&); |
| 79 | |
| 80 | private: |
| 81 | SkXfermode* fXfermode; |
| 82 | SkPMColor* fBuffer; |
| 83 | uint8_t* fAAExpand; |
| 84 | |
| 85 | // illegal |
| 86 | SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&); |
| 87 | |
| 88 | typedef SkShaderBlitter INHERITED; |
| 89 | }; |
| 90 | |
| 91 | //////////////////////////////////////////////////////////////// |
| 92 | |
| 93 | class SkARGB32_Blitter : public SkRasterBlitter { |
| 94 | public: |
| 95 | SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint); |
| 96 | virtual void blitH(int x, int y, int width); |
| 97 | virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); |
| 98 | virtual void blitV(int x, int y, int height, SkAlpha alpha); |
| 99 | virtual void blitRect(int x, int y, int width, int height); |
| 100 | virtual void blitMask(const SkMask&, const SkIRect&); |
| 101 | virtual const SkBitmap* justAnOpaqueColor(uint32_t*); |
| 102 | |
| 103 | protected: |
senorblanco@chromium.org | 29e5054 | 2010-12-16 19:07:45 +0000 | [diff] [blame] | 104 | SkColor fPMColor; |
| 105 | SkBlitRow::ColorProc fColor32Proc; |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame^] | 106 | SkBlitMask::Proc fBlitMaskProc; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 107 | |
| 108 | private: |
| 109 | unsigned fSrcA, fSrcR, fSrcG, fSrcB; |
| 110 | |
| 111 | // illegal |
| 112 | SkARGB32_Blitter& operator=(const SkARGB32_Blitter&); |
| 113 | |
| 114 | typedef SkRasterBlitter INHERITED; |
| 115 | }; |
| 116 | |
reed@android.com | dafaf7a | 2009-07-10 03:05:59 +0000 | [diff] [blame] | 117 | class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 118 | public: |
reed@android.com | dafaf7a | 2009-07-10 03:05:59 +0000 | [diff] [blame] | 119 | SkARGB32_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint) |
| 120 | : INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 121 | virtual void blitMask(const SkMask&, const SkIRect&); |
reed@android.com | dafaf7a | 2009-07-10 03:05:59 +0000 | [diff] [blame] | 122 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 123 | private: |
| 124 | typedef SkARGB32_Blitter INHERITED; |
| 125 | }; |
| 126 | |
reed@android.com | dafaf7a | 2009-07-10 03:05:59 +0000 | [diff] [blame] | 127 | class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 128 | public: |
reed@android.com | dafaf7a | 2009-07-10 03:05:59 +0000 | [diff] [blame] | 129 | SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint) |
| 130 | : INHERITED(device, paint) {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 131 | virtual void blitMask(const SkMask&, const SkIRect&); |
reed@android.com | dafaf7a | 2009-07-10 03:05:59 +0000 | [diff] [blame] | 132 | virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); |
reed@android.com | b602b8e | 2009-07-10 15:58:53 +0000 | [diff] [blame] | 133 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 134 | private: |
reed@android.com | dafaf7a | 2009-07-10 03:05:59 +0000 | [diff] [blame] | 135 | typedef SkARGB32_Opaque_Blitter INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | class SkARGB32_Shader_Blitter : public SkShaderBlitter { |
| 139 | public: |
| 140 | SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); |
| 141 | virtual ~SkARGB32_Shader_Blitter(); |
| 142 | virtual void blitH(int x, int y, int width); |
| 143 | virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); |
| 144 | |
| 145 | private: |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 146 | SkXfermode* fXfermode; |
| 147 | SkPMColor* fBuffer; |
| 148 | SkBlitRow::Proc32 fProc32; |
| 149 | SkBlitRow::Proc32 fProc32Blend; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 150 | |
| 151 | // illegal |
| 152 | SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&); |
| 153 | |
| 154 | typedef SkShaderBlitter INHERITED; |
| 155 | }; |
| 156 | |
reed@android.com | 1fc4c60 | 2009-10-02 16:34:57 +0000 | [diff] [blame] | 157 | /////////////////////////////////////////////////////////////////////////////// |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 158 | |
| 159 | class SkA1_Blitter : public SkRasterBlitter { |
| 160 | public: |
| 161 | SkA1_Blitter(const SkBitmap& device, const SkPaint& paint); |
| 162 | virtual void blitH(int x, int y, int width); |
| 163 | |
| 164 | private: |
| 165 | uint8_t fSrcA; |
| 166 | |
| 167 | // illegal |
| 168 | SkA1_Blitter& operator=(const SkA1_Blitter&); |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame^] | 169 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 170 | typedef SkRasterBlitter INHERITED; |
| 171 | }; |
| 172 | |
reed@android.com | 1fc4c60 | 2009-10-02 16:34:57 +0000 | [diff] [blame] | 173 | /////////////////////////////////////////////////////////////////////////////// |
| 174 | |
| 175 | /* These return the correct subclass of blitter for their device config. |
| 176 | |
| 177 | Currently, they make the following assumptions about the state of the |
| 178 | paint: |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame^] | 179 | |
reed@android.com | 1fc4c60 | 2009-10-02 16:34:57 +0000 | [diff] [blame] | 180 | 1. If there is an xfermode, there will also be a shader |
| 181 | 2. If there is a colorfilter, there will be a shader that itself handles |
| 182 | calling the filter, so the blitter can always ignore the colorfilter obj |
| 183 | |
| 184 | These pre-conditions must be handled by the caller, in our case |
| 185 | SkBlitter::Choose(...) |
| 186 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 187 | |
| 188 | extern SkBlitter* SkBlitter_ChooseD4444(const SkBitmap& device, |
| 189 | const SkPaint& paint, |
| 190 | void* storage, size_t storageSize); |
| 191 | |
reed@android.com | 1fc4c60 | 2009-10-02 16:34:57 +0000 | [diff] [blame] | 192 | extern SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, |
| 193 | const SkPaint& paint, |
| 194 | void* storage, size_t storageSize); |
| 195 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 196 | #endif |
| 197 | |