1 /* 2 * Copyright 2006 The Android Open Source Project 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkCoreBlitters_DEFINED 9 #define SkCoreBlitters_DEFINED 10 11 #include "SkBlitter.h" 12 #include "SkBlitRow.h" 13 14 class SkRasterBlitter : public SkBlitter { 15 public: 16 SkRasterBlitter(const SkBitmap& device) : fDevice(device) {} 17 18 protected: 19 const SkBitmap& fDevice; 20 21 private: 22 typedef SkBlitter INHERITED; 23 }; 24 25 class SkShaderBlitter : public SkRasterBlitter { 26 public: 27 SkShaderBlitter(const SkBitmap& device, const SkPaint& paint); 28 virtual ~SkShaderBlitter(); 29 30 protected: 31 uint32_t fShaderFlags; 32 SkShader* fShader; 33 34 private: 35 // illegal 36 SkShaderBlitter& operator=(const SkShaderBlitter&); 37 38 typedef SkRasterBlitter INHERITED; 39 }; 40 41 /////////////////////////////////////////////////////////////////////////////// 42 43 class SkA8_Blitter : public SkRasterBlitter { 44 public: 45 SkA8_Blitter(const SkBitmap& device, const SkPaint& paint); 46 virtual void blitH(int x, int y, int width); 47 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 48 virtual void blitV(int x, int y, int height, SkAlpha alpha); 49 virtual void blitRect(int x, int y, int width, int height); 50 virtual void blitMask(const SkMask&, const SkIRect&); 51 virtual const SkBitmap* justAnOpaqueColor(uint32_t*); 52 53 private: 54 unsigned fSrcA; 55 56 // illegal 57 SkA8_Blitter& operator=(const SkA8_Blitter&); 58 59 typedef SkRasterBlitter INHERITED; 60 }; 61 62 class SkA8_Shader_Blitter : public SkShaderBlitter { 63 public: 64 SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 65 virtual ~SkA8_Shader_Blitter(); 66 virtual void blitH(int x, int y, int width); 67 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 68 virtual void blitMask(const SkMask&, const SkIRect&); 69 70 private: 71 SkXfermode* fXfermode; 72 SkPMColor* fBuffer; 73 uint8_t* fAAExpand; 74 75 // illegal 76 SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&); 77 78 typedef SkShaderBlitter INHERITED; 79 }; 80 81 //////////////////////////////////////////////////////////////// 82 83 class SkARGB32_Blitter : public SkRasterBlitter { 84 public: 85 SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint); 86 virtual void blitH(int x, int y, int width); 87 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 88 virtual void blitV(int x, int y, int height, SkAlpha alpha); 89 virtual void blitRect(int x, int y, int width, int height); 90 virtual void blitMask(const SkMask&, const SkIRect&); 91 virtual const SkBitmap* justAnOpaqueColor(uint32_t*); 92 93 protected: 94 SkColor fColor; 95 SkPMColor fPMColor; 96 SkBlitRow::ColorProc fColor32Proc; 97 SkBlitRow::ColorRectProc fColorRect32Proc; 98 99 private: 100 unsigned fSrcA, fSrcR, fSrcG, fSrcB; 101 102 // illegal 103 SkARGB32_Blitter& operator=(const SkARGB32_Blitter&); 104 105 typedef SkRasterBlitter INHERITED; 106 }; 107 108 class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter { 109 public: 110 SkARGB32_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint) 111 : INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); } 112 virtual void blitMask(const SkMask&, const SkIRect&); 113 114 private: 115 typedef SkARGB32_Blitter INHERITED; 116 }; 117 118 class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter { 119 public: 120 SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint) 121 : INHERITED(device, paint) {} 122 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 123 124 private: 125 typedef SkARGB32_Opaque_Blitter INHERITED; 126 }; 127 128 class SkARGB32_Shader_Blitter : public SkShaderBlitter { 129 public: 130 SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 131 virtual ~SkARGB32_Shader_Blitter(); 132 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 133 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; 134 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 135 virtual void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) SK_OVERRIDE; 136 virtual void blitMask(const SkMask&, const SkIRect&) SK_OVERRIDE; 137 138 private: 139 SkXfermode* fXfermode; 140 SkPMColor* fBuffer; 141 SkBlitRow::Proc32 fProc32; 142 SkBlitRow::Proc32 fProc32Blend; 143 bool fShadeDirectlyIntoDevice; 144 bool fConstInY; 145 146 // illegal 147 SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&); 148 149 typedef SkShaderBlitter INHERITED; 150 }; 151 152 /////////////////////////////////////////////////////////////////////////////// 153 154 class SkA1_Blitter : public SkRasterBlitter { 155 public: 156 SkA1_Blitter(const SkBitmap& device, const SkPaint& paint); 157 virtual void blitH(int x, int y, int width); 158 159 private: 160 uint8_t fSrcA; 161 162 // illegal 163 SkA1_Blitter& operator=(const SkA1_Blitter&); 164 165 typedef SkRasterBlitter INHERITED; 166 }; 167 168 /////////////////////////////////////////////////////////////////////////////// 169 170 /* These return the correct subclass of blitter for their device config. 171 172 Currently, they make the following assumptions about the state of the 173 paint: 174 175 1. If there is an xfermode, there will also be a shader 176 2. If there is a colorfilter, there will be a shader that itself handles 177 calling the filter, so the blitter can always ignore the colorfilter obj 178 179 These pre-conditions must be handled by the caller, in our case 180 SkBlitter::Choose(...) 181 */ 182 183 extern SkBlitter* SkBlitter_ChooseD4444(const SkBitmap& device, 184 const SkPaint& paint, 185 void* storage, size_t storageSize); 186 187 extern SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, 188 const SkPaint& paint, 189 void* storage, size_t storageSize); 190 191 #endif 192