| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkAtomics.h" | 8 #include "SkAtomics.h" |
| 9 #include "SkBitmapProcShader.h" | 9 #include "SkBitmapProcShader.h" |
| 10 #include "SkColorShader.h" | 10 #include "SkColorShader.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 fPaintAlpha = rec.fPaint->getAlpha(); | 111 fPaintAlpha = rec.fPaint->getAlpha(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 SkShader::Context::~Context() {} | 114 SkShader::Context::~Context() {} |
| 115 | 115 |
| 116 SkShader::Context::ShadeProc SkShader::Context::asAShadeProc(void** ctx) { | 116 SkShader::Context::ShadeProc SkShader::Context::asAShadeProc(void** ctx) { |
| 117 return nullptr; | 117 return nullptr; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void SkShader::Context::shadeSpan4f(int x, int y, SkPM4f[], int count) { |
| 121 SkASSERT(false && "shadeSpan4f called but not implemented"); |
| 122 } |
| 123 |
| 120 #include "SkColorPriv.h" | 124 #include "SkColorPriv.h" |
| 121 | 125 |
| 122 #define kTempColorQuadCount 6 // balance between speed (larger) and saving sta
ck-space | 126 #define kTempColorQuadCount 6 // balance between speed (larger) and saving sta
ck-space |
| 123 #define kTempColorCount (kTempColorQuadCount << 2) | 127 #define kTempColorCount (kTempColorQuadCount << 2) |
| 124 | 128 |
| 125 #ifdef SK_CPU_BENDIAN | 129 #ifdef SK_CPU_BENDIAN |
| 126 #define SkU32BitShiftToByteOffset(shift) (3 - ((shift) >> 3)) | 130 #define SkU32BitShiftToByteOffset(shift) (3 - ((shift) >> 3)) |
| 127 #else | 131 #else |
| 128 #define SkU32BitShiftToByteOffset(shift) ((shift) >> 3) | 132 #define SkU32BitShiftToByteOffset(shift) ((shift) >> 3) |
| 129 #endif | 133 #endif |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 unsigned g = SkColorGetG(color); | 276 unsigned g = SkColorGetG(color); |
| 273 unsigned b = SkColorGetB(color); | 277 unsigned b = SkColorGetB(color); |
| 274 | 278 |
| 275 if (a != 255) { | 279 if (a != 255) { |
| 276 r = SkMulDiv255Round(r, a); | 280 r = SkMulDiv255Round(r, a); |
| 277 g = SkMulDiv255Round(g, a); | 281 g = SkMulDiv255Round(g, a); |
| 278 b = SkMulDiv255Round(b, a); | 282 b = SkMulDiv255Round(b, a); |
| 279 } | 283 } |
| 280 fPMColor = SkPackARGB32(a, r, g, b); | 284 fPMColor = SkPackARGB32(a, r, g, b); |
| 281 | 285 |
| 282 fFlags = kConstInY32_Flag; | 286 SkColor4f c4 = SkColor4f::FromColor(shader.fColor); |
| 287 c4.fA *= rec.fPaint->getAlpha() / 255.0f; |
| 288 fPM4f = c4.premul(); |
| 289 |
| 290 fFlags = kConstInY32_Flag | kSupports4f_Flag; |
| 283 if (255 == a) { | 291 if (255 == a) { |
| 284 fFlags |= kOpaqueAlpha_Flag; | 292 fFlags |= kOpaqueAlpha_Flag; |
| 285 } | 293 } |
| 286 } | 294 } |
| 287 | 295 |
| 288 void SkColorShader::ColorShaderContext::shadeSpan(int x, int y, SkPMColor span[]
, int count) { | 296 void SkColorShader::ColorShaderContext::shadeSpan(int x, int y, SkPMColor span[]
, int count) { |
| 289 sk_memset32(span, fPMColor, count); | 297 sk_memset32(span, fPMColor, count); |
| 290 } | 298 } |
| 291 | 299 |
| 292 void SkColorShader::ColorShaderContext::shadeSpanAlpha(int x, int y, uint8_t alp
ha[], int count) { | 300 void SkColorShader::ColorShaderContext::shadeSpanAlpha(int x, int y, uint8_t alp
ha[], int count) { |
| 293 memset(alpha, SkGetPackedA32(fPMColor), count); | 301 memset(alpha, SkGetPackedA32(fPMColor), count); |
| 294 } | 302 } |
| 295 | 303 |
| 304 void SkColorShader::ColorShaderContext::shadeSpan4f(int x, int y, SkPM4f span[],
int count) { |
| 305 for (int i = 0; i < count; ++i) { |
| 306 span[i] = fPM4f; |
| 307 } |
| 308 } |
| 309 |
| 296 SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { | 310 SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { |
| 297 if (info) { | 311 if (info) { |
| 298 if (info->fColors && info->fColorCount >= 1) { | 312 if (info->fColors && info->fColorCount >= 1) { |
| 299 info->fColors[0] = fColor; | 313 info->fColors[0] = fColor; |
| 300 } | 314 } |
| 301 info->fColorCount = 1; | 315 info->fColorCount = 1; |
| 302 info->fTileMode = SkShader::kRepeat_TileMode; | 316 info->fTileMode = SkShader::kRepeat_TileMode; |
| 303 } | 317 } |
| 304 return kColor_GradientType; | 318 return kColor_GradientType; |
| 305 } | 319 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 #include "SkEmptyShader.h" | 354 #include "SkEmptyShader.h" |
| 341 | 355 |
| 342 void SkEmptyShader::toString(SkString* str) const { | 356 void SkEmptyShader::toString(SkString* str) const { |
| 343 str->append("SkEmptyShader: ("); | 357 str->append("SkEmptyShader: ("); |
| 344 | 358 |
| 345 this->INHERITED::toString(str); | 359 this->INHERITED::toString(str); |
| 346 | 360 |
| 347 str->append(")"); | 361 str->append(")"); |
| 348 } | 362 } |
| 349 #endif | 363 #endif |
| OLD | NEW |