epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 9 | #include "SkScalar.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #include "SkShader.h" |
djsollen@google.com | c73dd5c | 2012-08-07 15:54:32 +0000 | [diff] [blame] | 11 | #include "SkFlattenableBuffers.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 12 | #include "SkPaint.h" |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 13 | #include "SkMallocPixelRef.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 14 | |
robertphillips@google.com | 0456e0b | 2012-06-27 14:03:26 +0000 | [diff] [blame] | 15 | SK_DEFINE_INST_COUNT(SkShader) |
| 16 | |
bsalomon@google.com | f94b3a4 | 2012-10-31 18:09:01 +0000 | [diff] [blame] | 17 | SkShader::SkShader() { |
| 18 | fLocalMatrix.reset(); |
reed@google.com | a641f3f | 2012-12-13 22:16:30 +0000 | [diff] [blame] | 19 | SkDEBUGCODE(fInSetContext = false;) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | SkShader::SkShader(SkFlattenableReadBuffer& buffer) |
bsalomon@google.com | f94b3a4 | 2012-10-31 18:09:01 +0000 | [diff] [blame] | 23 | : INHERITED(buffer) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | if (buffer.readBool()) { |
bsalomon@google.com | f94b3a4 | 2012-10-31 18:09:01 +0000 | [diff] [blame] | 25 | buffer.readMatrix(&fLocalMatrix); |
| 26 | } else { |
| 27 | fLocalMatrix.reset(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 28 | } |
bsalomon@google.com | f94b3a4 | 2012-10-31 18:09:01 +0000 | [diff] [blame] | 29 | |
reed@google.com | a641f3f | 2012-12-13 22:16:30 +0000 | [diff] [blame] | 30 | SkDEBUGCODE(fInSetContext = false;) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | SkShader::~SkShader() { |
reed@google.com | a641f3f | 2012-12-13 22:16:30 +0000 | [diff] [blame] | 34 | SkASSERT(!fInSetContext); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 35 | } |
| 36 | |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 37 | void SkShader::flatten(SkFlattenableWriteBuffer& buffer) const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 38 | this->INHERITED::flatten(buffer); |
bsalomon@google.com | f94b3a4 | 2012-10-31 18:09:01 +0000 | [diff] [blame] | 39 | bool hasLocalM = this->hasLocalMatrix(); |
| 40 | buffer.writeBool(hasLocalM); |
| 41 | if (hasLocalM) { |
| 42 | buffer.writeMatrix(fLocalMatrix); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | } |
| 44 | } |
| 45 | |
| 46 | bool SkShader::setContext(const SkBitmap& device, |
| 47 | const SkPaint& paint, |
| 48 | const SkMatrix& matrix) { |
reed@google.com | a641f3f | 2012-12-13 22:16:30 +0000 | [diff] [blame] | 49 | SkASSERT(!this->setContextHasBeenCalled()); |
| 50 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 51 | const SkMatrix* m = &matrix; |
| 52 | SkMatrix total; |
| 53 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 54 | fDeviceConfig = SkToU8(device.config()); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | fPaintAlpha = paint.getAlpha(); |
bsalomon@google.com | f94b3a4 | 2012-10-31 18:09:01 +0000 | [diff] [blame] | 56 | if (this->hasLocalMatrix()) { |
| 57 | total.setConcat(matrix, this->getLocalMatrix()); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 58 | m = &total; |
| 59 | } |
| 60 | if (m->invert(&fTotalInverse)) { |
| 61 | fTotalInverseClass = (uint8_t)ComputeMatrixClass(fTotalInverse); |
reed@google.com | a641f3f | 2012-12-13 22:16:30 +0000 | [diff] [blame] | 62 | SkDEBUGCODE(fInSetContext = true;) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 63 | return true; |
| 64 | } |
| 65 | return false; |
| 66 | } |
| 67 | |
reed@google.com | a641f3f | 2012-12-13 22:16:30 +0000 | [diff] [blame] | 68 | void SkShader::endContext() { |
| 69 | SkASSERT(fInSetContext); |
| 70 | SkDEBUGCODE(fInSetContext = false;) |
| 71 | } |
| 72 | |
reed@google.com | 3bafe74 | 2012-10-12 18:56:18 +0000 | [diff] [blame] | 73 | SkShader::ShadeProc SkShader::asAShadeProc(void** ctx) { |
| 74 | return NULL; |
| 75 | } |
| 76 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 77 | #include "SkColorPriv.h" |
| 78 | |
| 79 | void SkShader::shadeSpan16(int x, int y, uint16_t span16[], int count) { |
| 80 | SkASSERT(span16); |
| 81 | SkASSERT(count > 0); |
| 82 | SkASSERT(this->canCallShadeSpan16()); |
| 83 | |
| 84 | // basically, if we get here, the subclass screwed up |
tomhudson@google.com | 0c00f21 | 2011-12-28 14:59:50 +0000 | [diff] [blame] | 85 | SkDEBUGFAIL("kHasSpan16 flag is set, but shadeSpan16() not implemented"); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | #define kTempColorQuadCount 6 // balance between speed (larger) and saving stack-space |
reed@google.com | 7c2f27d | 2011-03-07 19:29:00 +0000 | [diff] [blame] | 89 | #define kTempColorCount (kTempColorQuadCount << 2) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 90 | |
| 91 | #ifdef SK_CPU_BENDIAN |
| 92 | #define SkU32BitShiftToByteOffset(shift) (3 - ((shift) >> 3)) |
| 93 | #else |
| 94 | #define SkU32BitShiftToByteOffset(shift) ((shift) >> 3) |
| 95 | #endif |
| 96 | |
| 97 | void SkShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) { |
| 98 | SkASSERT(count > 0); |
| 99 | |
| 100 | SkPMColor colors[kTempColorCount]; |
| 101 | |
| 102 | while ((count -= kTempColorCount) >= 0) { |
| 103 | this->shadeSpan(x, y, colors, kTempColorCount); |
| 104 | x += kTempColorCount; |
| 105 | |
| 106 | const uint8_t* srcA = (const uint8_t*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT); |
| 107 | int quads = kTempColorQuadCount; |
| 108 | do { |
| 109 | U8CPU a0 = srcA[0]; |
| 110 | U8CPU a1 = srcA[4]; |
| 111 | U8CPU a2 = srcA[8]; |
| 112 | U8CPU a3 = srcA[12]; |
| 113 | srcA += 4*4; |
| 114 | *alpha++ = SkToU8(a0); |
| 115 | *alpha++ = SkToU8(a1); |
| 116 | *alpha++ = SkToU8(a2); |
| 117 | *alpha++ = SkToU8(a3); |
| 118 | } while (--quads != 0); |
| 119 | } |
| 120 | SkASSERT(count < 0); |
| 121 | SkASSERT(count + kTempColorCount >= 0); |
| 122 | if (count += kTempColorCount) { |
| 123 | this->shadeSpan(x, y, colors, count); |
| 124 | |
| 125 | const uint8_t* srcA = (const uint8_t*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT); |
| 126 | do { |
| 127 | *alpha++ = *srcA; |
| 128 | srcA += 4; |
| 129 | } while (--count != 0); |
| 130 | } |
| 131 | #if 0 |
| 132 | do { |
| 133 | int n = count; |
| 134 | if (n > kTempColorCount) |
| 135 | n = kTempColorCount; |
| 136 | SkASSERT(n > 0); |
| 137 | |
| 138 | this->shadeSpan(x, y, colors, n); |
| 139 | x += n; |
| 140 | count -= n; |
| 141 | |
| 142 | const uint8_t* srcA = (const uint8_t*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT); |
| 143 | do { |
| 144 | *alpha++ = *srcA; |
| 145 | srcA += 4; |
| 146 | } while (--n != 0); |
| 147 | } while (count > 0); |
| 148 | #endif |
| 149 | } |
| 150 | |
| 151 | SkShader::MatrixClass SkShader::ComputeMatrixClass(const SkMatrix& mat) { |
| 152 | MatrixClass mc = kLinear_MatrixClass; |
| 153 | |
tomhudson@google.com | 8d43018 | 2011-06-06 19:11:19 +0000 | [diff] [blame] | 154 | if (mat.hasPerspective()) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 155 | if (mat.fixedStepInX(0, NULL, NULL)) { |
| 156 | mc = kFixedStepInX_MatrixClass; |
| 157 | } else { |
| 158 | mc = kPerspective_MatrixClass; |
| 159 | } |
| 160 | } |
| 161 | return mc; |
| 162 | } |
| 163 | |
| 164 | ////////////////////////////////////////////////////////////////////////////// |
| 165 | |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 166 | SkShader::BitmapType SkShader::asABitmap(SkBitmap*, SkMatrix*, |
rileya@google.com | 91f319c | 2012-07-25 17:18:31 +0000 | [diff] [blame] | 167 | TileMode*) const { |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 168 | return kNone_BitmapType; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 169 | } |
| 170 | |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 171 | SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { |
| 172 | return kNone_GradientType; |
| 173 | } |
| 174 | |
bsalomon@google.com | 0ac6af4 | 2013-01-16 15:16:18 +0000 | [diff] [blame] | 175 | GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const { |
humper@google.com | a3bdc1a | 2013-01-14 21:01:28 +0000 | [diff] [blame] | 176 | return NULL; |
rileya@google.com | 03c1c35 | 2012-07-20 20:02:43 +0000 | [diff] [blame] | 177 | } |
| 178 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 179 | SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, |
| 180 | TileMode tmx, TileMode tmy) { |
| 181 | return SkShader::CreateBitmapShader(src, tmx, tmy, NULL, 0); |
| 182 | } |
| 183 | |
robertphillips@google.com | 76f9e93 | 2013-01-15 20:17:47 +0000 | [diff] [blame] | 184 | #ifdef SK_DEVELOPER |
| 185 | void SkShader::toString(SkString* str) const { |
| 186 | if (this->hasLocalMatrix()) { |
| 187 | str->append(" "); |
| 188 | this->getLocalMatrix().toString(str); |
| 189 | } |
| 190 | } |
| 191 | #endif |
| 192 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 193 | ////////////////////////////////////////////////////////////////////////////// |
| 194 | |
| 195 | #include "SkColorShader.h" |
| 196 | #include "SkUtils.h" |
| 197 | |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 198 | SkColorShader::SkColorShader() { |
| 199 | fFlags = 0; |
| 200 | fInheritColor = true; |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | SkColorShader::SkColorShader(SkColor c) { |
| 204 | fFlags = 0; |
| 205 | fColor = c; |
| 206 | fInheritColor = false; |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 207 | } |
| 208 | |
reed@google.com | 2be9e8b | 2011-07-06 21:18:09 +0000 | [diff] [blame] | 209 | SkColorShader::~SkColorShader() {} |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 210 | |
junov@chromium.org | b6e1619 | 2011-12-09 15:48:03 +0000 | [diff] [blame] | 211 | bool SkColorShader::isOpaque() const { |
| 212 | if (fInheritColor) { |
| 213 | return true; // using paint's alpha |
| 214 | } |
| 215 | return SkColorGetA(fColor) == 255; |
| 216 | } |
| 217 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 218 | SkColorShader::SkColorShader(SkFlattenableReadBuffer& b) : INHERITED(b) { |
reed@android.com | 5119bdb | 2009-06-12 21:27:03 +0000 | [diff] [blame] | 219 | fFlags = 0; // computed in setContext |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 220 | |
djsollen@google.com | c73dd5c | 2012-08-07 15:54:32 +0000 | [diff] [blame] | 221 | fInheritColor = b.readBool(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 222 | if (fInheritColor) { |
| 223 | return; |
| 224 | } |
djsollen@google.com | c73dd5c | 2012-08-07 15:54:32 +0000 | [diff] [blame] | 225 | fColor = b.readColor(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 226 | } |
| 227 | |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 228 | void SkColorShader::flatten(SkFlattenableWriteBuffer& buffer) const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 229 | this->INHERITED::flatten(buffer); |
djsollen@google.com | c73dd5c | 2012-08-07 15:54:32 +0000 | [diff] [blame] | 230 | buffer.writeBool(fInheritColor); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 231 | if (fInheritColor) { |
| 232 | return; |
| 233 | } |
djsollen@google.com | c73dd5c | 2012-08-07 15:54:32 +0000 | [diff] [blame] | 234 | buffer.writeColor(fColor); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 235 | } |
| 236 | |
reed@google.com | 59ccef6 | 2011-12-07 14:59:50 +0000 | [diff] [blame] | 237 | uint32_t SkColorShader::getFlags() { |
| 238 | return fFlags; |
| 239 | } |
| 240 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 241 | uint8_t SkColorShader::getSpan16Alpha() const { |
| 242 | return SkGetPackedA32(fPMColor); |
| 243 | } |
| 244 | |
| 245 | bool SkColorShader::setContext(const SkBitmap& device, const SkPaint& paint, |
| 246 | const SkMatrix& matrix) { |
| 247 | if (!this->INHERITED::setContext(device, paint, matrix)) { |
| 248 | return false; |
| 249 | } |
| 250 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 251 | unsigned a; |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 252 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 253 | if (fInheritColor) { |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 254 | fColor = paint.getColor(); |
| 255 | a = SkColorGetA(fColor); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 256 | } else { |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 257 | a = SkAlphaMul(SkColorGetA(fColor), SkAlpha255To256(paint.getAlpha())); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 258 | } |
| 259 | |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 260 | unsigned r = SkColorGetR(fColor); |
| 261 | unsigned g = SkColorGetG(fColor); |
| 262 | unsigned b = SkColorGetB(fColor); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 263 | |
| 264 | // we want this before we apply any alpha |
| 265 | fColor16 = SkPack888ToRGB16(r, g, b); |
| 266 | |
| 267 | if (a != 255) { |
reed@android.com | 8f07338 | 2010-03-11 21:56:16 +0000 | [diff] [blame] | 268 | r = SkMulDiv255Round(r, a); |
| 269 | g = SkMulDiv255Round(g, a); |
| 270 | b = SkMulDiv255Round(b, a); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 271 | } |
| 272 | fPMColor = SkPackARGB32(a, r, g, b); |
| 273 | |
reed@android.com | 8f07338 | 2010-03-11 21:56:16 +0000 | [diff] [blame] | 274 | fFlags = kConstInY32_Flag; |
reed@android.com | 5b81535 | 2010-03-11 22:20:43 +0000 | [diff] [blame] | 275 | if (255 == a) { |
reed@android.com | 5119bdb | 2009-06-12 21:27:03 +0000 | [diff] [blame] | 276 | fFlags |= kOpaqueAlpha_Flag; |
reed@android.com | 5b81535 | 2010-03-11 22:20:43 +0000 | [diff] [blame] | 277 | if (paint.isDither() == false) { |
| 278 | fFlags |= kHasSpan16_Flag; |
| 279 | } |
reed@android.com | 5119bdb | 2009-06-12 21:27:03 +0000 | [diff] [blame] | 280 | } |
| 281 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 282 | return true; |
| 283 | } |
| 284 | |
| 285 | void SkColorShader::shadeSpan(int x, int y, SkPMColor span[], int count) { |
| 286 | sk_memset32(span, fPMColor, count); |
| 287 | } |
| 288 | |
| 289 | void SkColorShader::shadeSpan16(int x, int y, uint16_t span[], int count) { |
| 290 | sk_memset16(span, fColor16, count); |
| 291 | } |
| 292 | |
| 293 | void SkColorShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) { |
| 294 | memset(alpha, SkGetPackedA32(fPMColor), count); |
| 295 | } |
| 296 | |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 297 | // if we had a asAColor method, that would be more efficient... |
| 298 | SkShader::BitmapType SkColorShader::asABitmap(SkBitmap* bitmap, SkMatrix* matrix, |
rileya@google.com | 91f319c | 2012-07-25 17:18:31 +0000 | [diff] [blame] | 299 | TileMode modes[]) const { |
reed@google.com | 2be9e8b | 2011-07-06 21:18:09 +0000 | [diff] [blame] | 300 | return kNone_BitmapType; |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 301 | } |
| 302 | |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 303 | SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { |
| 304 | if (info) { |
| 305 | if (info->fColors && info->fColorCount >= 1) { |
| 306 | info->fColors[0] = fColor; |
| 307 | } |
| 308 | info->fColorCount = 1; |
| 309 | info->fTileMode = SkShader::kRepeat_TileMode; |
| 310 | } |
| 311 | return kColor_GradientType; |
| 312 | } |
reed@google.com | 37a2012 | 2011-07-05 18:54:12 +0000 | [diff] [blame] | 313 | |
robertphillips@google.com | 76f9e93 | 2013-01-15 20:17:47 +0000 | [diff] [blame] | 314 | #ifdef SK_DEVELOPER |
| 315 | void SkColorShader::toString(SkString* str) const { |
| 316 | str->append("SkColorShader: ("); |
| 317 | |
| 318 | if (fInheritColor) { |
| 319 | str->append("Color: inherited from paint"); |
| 320 | } else { |
| 321 | str->append("Color: "); |
| 322 | str->appendHex(fColor); |
| 323 | } |
| 324 | |
| 325 | this->INHERITED::toString(str); |
| 326 | |
| 327 | str->append(")"); |
| 328 | } |
| 329 | #endif |
| 330 | |
reed@google.com | 37a2012 | 2011-07-05 18:54:12 +0000 | [diff] [blame] | 331 | /////////////////////////////////////////////////////////////////////////////// |
| 332 | |
| 333 | #include "SkEmptyShader.h" |
| 334 | |
reed@google.com | 37a2012 | 2011-07-05 18:54:12 +0000 | [diff] [blame] | 335 | uint32_t SkEmptyShader::getFlags() { return 0; } |
| 336 | uint8_t SkEmptyShader::getSpan16Alpha() const { return 0; } |
reed@google.com | 59ccef6 | 2011-12-07 14:59:50 +0000 | [diff] [blame] | 337 | |
| 338 | bool SkEmptyShader::setContext(const SkBitmap&, const SkPaint&, |
| 339 | const SkMatrix&) { return false; } |
| 340 | |
| 341 | void SkEmptyShader::shadeSpan(int x, int y, SkPMColor span[], int count) { |
tomhudson@google.com | 0c00f21 | 2011-12-28 14:59:50 +0000 | [diff] [blame] | 342 | SkDEBUGFAIL("should never get called, since setContext() returned false"); |
reed@google.com | 37a2012 | 2011-07-05 18:54:12 +0000 | [diff] [blame] | 343 | } |
reed@google.com | 59ccef6 | 2011-12-07 14:59:50 +0000 | [diff] [blame] | 344 | |
| 345 | void SkEmptyShader::shadeSpan16(int x, int y, uint16_t span[], int count) { |
tomhudson@google.com | 0c00f21 | 2011-12-28 14:59:50 +0000 | [diff] [blame] | 346 | SkDEBUGFAIL("should never get called, since setContext() returned false"); |
reed@google.com | 59ccef6 | 2011-12-07 14:59:50 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | void SkEmptyShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) { |
tomhudson@google.com | 0c00f21 | 2011-12-28 14:59:50 +0000 | [diff] [blame] | 350 | SkDEBUGFAIL("should never get called, since setContext() returned false"); |
reed@google.com | 59ccef6 | 2011-12-07 14:59:50 +0000 | [diff] [blame] | 351 | } |
robertphillips@google.com | 76f9e93 | 2013-01-15 20:17:47 +0000 | [diff] [blame] | 352 | |
| 353 | #ifdef SK_DEVELOPER |
| 354 | void SkEmptyShader::toString(SkString* str) const { |
| 355 | str->append("SkEmptyShader: ("); |
| 356 | |
| 357 | this->INHERITED::toString(str); |
| 358 | |
| 359 | str->append(")"); |
| 360 | } |
| 361 | #endif |