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_Coverage_Blitter : public SkRasterBlitter { 44 public: 45 SkA8_Coverage_Blitter(const SkBitmap& device, const SkPaint& paint); 46 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 47 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) SK_OVERRIDE; 48 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; 49 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 50 virtual void blitMask(const SkMask&, const SkIRect&) SK_OVERRIDE; 51 virtual const SkBitmap* justAnOpaqueColor(uint32_t*) SK_OVERRIDE; 52 }; 53 54 class SkA8_Blitter : public SkRasterBlitter { 55 public: 56 SkA8_Blitter(const SkBitmap& device, const SkPaint& paint); 57 virtual void blitH(int x, int y, int width); 58 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 59 virtual void blitV(int x, int y, int height, SkAlpha alpha); 60 virtual void blitRect(int x, int y, int width, int height); 61 virtual void blitMask(const SkMask&, const SkIRect&); 62 virtual const SkBitmap* justAnOpaqueColor(uint32_t*); 63 64 private: 65 unsigned fSrcA; 66 67 // illegal 68 SkA8_Blitter& operator=(const SkA8_Blitter&); 69 70 typedef SkRasterBlitter INHERITED; 71 }; 72 73 class SkA8_Shader_Blitter : public SkShaderBlitter { 74 public: 75 SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 76 virtual ~SkA8_Shader_Blitter(); 77 virtual void blitH(int x, int y, int width); 78 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 79 virtual void blitMask(const SkMask&, const SkIRect&); 80 81 private: 82 SkXfermode* fXfermode; 83 SkPMColor* fBuffer; 84 uint8_t* fAAExpand; 85 86 // illegal 87 SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&); 88 89 typedef SkShaderBlitter INHERITED; 90 }; 91 92 //////////////////////////////////////////////////////////////// 93 94 class SkARGB32_Blitter : public SkRasterBlitter { 95 public: 96 SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint); 97 virtual void blitH(int x, int y, int width); 98 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 99 virtual void blitV(int x, int y, int height, SkAlpha alpha); 100 virtual void blitRect(int x, int y, int width, int height); 101 virtual void blitMask(const SkMask&, const SkIRect&); 102 virtual const SkBitmap* justAnOpaqueColor(uint32_t*); 103 104 protected: 105 SkColor fColor; 106 SkPMColor fPMColor; 107 SkBlitRow::ColorProc fColor32Proc; 108 SkBlitRow::ColorRectProc fColorRect32Proc; 109 110 private: 111 unsigned fSrcA, fSrcR, fSrcG, fSrcB; 112 113 // illegal 114 SkARGB32_Blitter& operator=(const SkARGB32_Blitter&); 115 116 typedef SkRasterBlitter INHERITED; 117 }; 118 119 class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter { 120 public: 121 SkARGB32_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint) 122 : INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); } 123 virtual void blitMask(const SkMask&, const SkIRect&); 124 125 private: 126 typedef SkARGB32_Blitter INHERITED; 127 }; 128 129 class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter { 130 public: 131 SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint) 132 : INHERITED(device, paint) {} 133 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]); 134 135 private: 136 typedef SkARGB32_Opaque_Blitter INHERITED; 137 }; 138 139 class SkARGB32_Shader_Blitter : public SkShaderBlitter { 140 public: 141 SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 142 virtual ~SkARGB32_Shader_Blitter(); 143 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 144 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; 145 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 146 virtual void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) SK_OVERRIDE; 147 virtual void blitMask(const SkMask&, const SkIRect&) SK_OVERRIDE; 148 149 private: 150 SkXfermode* fXfermode; 151 SkPMColor* fBuffer; 152 SkBlitRow::Proc32 fProc32; 153 SkBlitRow::Proc32 fProc32Blend; 154 bool fShadeDirectlyIntoDevice; 155 bool fConstInY; 156 157 // illegal 158 SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&); 159 160 typedef SkShaderBlitter INHERITED; 161 }; 162 163 /////////////////////////////////////////////////////////////////////////////// 164 165 /* These return the correct subclass of blitter for their device config. 166 167 Currently, they make the following assumptions about the state of the 168 paint: 169 170 1. If there is an xfermode, there will also be a shader 171 2. If there is a colorfilter, there will be a shader that itself handles 172 calling the filter, so the blitter can always ignore the colorfilter obj 173 174 These pre-conditions must be handled by the caller, in our case 175 SkBlitter::Choose(...) 176 */ 177 178 extern SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, 179 const SkPaint& paint, 180 void* storage, size_t storageSize); 181 182 #endif 183