| 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 | |
| 124 #include "SkColorPriv.h" | 120 #include "SkColorPriv.h" |
| 125 | 121 |
| 126 #define kTempColorQuadCount 6 // balance between speed (larger) and saving sta
ck-space | 122 #define kTempColorQuadCount 6 // balance between speed (larger) and saving sta
ck-space |
| 127 #define kTempColorCount (kTempColorQuadCount << 2) | 123 #define kTempColorCount (kTempColorQuadCount << 2) |
| 128 | 124 |
| 129 #ifdef SK_CPU_BENDIAN | 125 #ifdef SK_CPU_BENDIAN |
| 130 #define SkU32BitShiftToByteOffset(shift) (3 - ((shift) >> 3)) | 126 #define SkU32BitShiftToByteOffset(shift) (3 - ((shift) >> 3)) |
| 131 #else | 127 #else |
| 132 #define SkU32BitShiftToByteOffset(shift) ((shift) >> 3) | 128 #define SkU32BitShiftToByteOffset(shift) ((shift) >> 3) |
| 133 #endif | 129 #endif |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 unsigned g = SkColorGetG(color); | 272 unsigned g = SkColorGetG(color); |
| 277 unsigned b = SkColorGetB(color); | 273 unsigned b = SkColorGetB(color); |
| 278 | 274 |
| 279 if (a != 255) { | 275 if (a != 255) { |
| 280 r = SkMulDiv255Round(r, a); | 276 r = SkMulDiv255Round(r, a); |
| 281 g = SkMulDiv255Round(g, a); | 277 g = SkMulDiv255Round(g, a); |
| 282 b = SkMulDiv255Round(b, a); | 278 b = SkMulDiv255Round(b, a); |
| 283 } | 279 } |
| 284 fPMColor = SkPackARGB32(a, r, g, b); | 280 fPMColor = SkPackARGB32(a, r, g, b); |
| 285 | 281 |
| 286 SkColor4f c4 = SkColor4f::FromColor(shader.fColor); | 282 fFlags = kConstInY32_Flag; |
| 287 c4.fA *= rec.fPaint->getAlpha() / 255.0f; | |
| 288 fPM4f = c4.premul(); | |
| 289 | |
| 290 fFlags = kConstInY32_Flag | kSupports4f_Flag; | |
| 291 if (255 == a) { | 283 if (255 == a) { |
| 292 fFlags |= kOpaqueAlpha_Flag; | 284 fFlags |= kOpaqueAlpha_Flag; |
| 293 } | 285 } |
| 294 } | 286 } |
| 295 | 287 |
| 296 void SkColorShader::ColorShaderContext::shadeSpan(int x, int y, SkPMColor span[]
, int count) { | 288 void SkColorShader::ColorShaderContext::shadeSpan(int x, int y, SkPMColor span[]
, int count) { |
| 297 sk_memset32(span, fPMColor, count); | 289 sk_memset32(span, fPMColor, count); |
| 298 } | 290 } |
| 299 | 291 |
| 300 void SkColorShader::ColorShaderContext::shadeSpanAlpha(int x, int y, uint8_t alp
ha[], int count) { | 292 void SkColorShader::ColorShaderContext::shadeSpanAlpha(int x, int y, uint8_t alp
ha[], int count) { |
| 301 memset(alpha, SkGetPackedA32(fPMColor), count); | 293 memset(alpha, SkGetPackedA32(fPMColor), count); |
| 302 } | 294 } |
| 303 | 295 |
| 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 | |
| 310 SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { | 296 SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { |
| 311 if (info) { | 297 if (info) { |
| 312 if (info->fColors && info->fColorCount >= 1) { | 298 if (info->fColors && info->fColorCount >= 1) { |
| 313 info->fColors[0] = fColor; | 299 info->fColors[0] = fColor; |
| 314 } | 300 } |
| 315 info->fColorCount = 1; | 301 info->fColorCount = 1; |
| 316 info->fTileMode = SkShader::kRepeat_TileMode; | 302 info->fTileMode = SkShader::kRepeat_TileMode; |
| 317 } | 303 } |
| 318 return kColor_GradientType; | 304 return kColor_GradientType; |
| 319 } | 305 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 #include "SkEmptyShader.h" | 340 #include "SkEmptyShader.h" |
| 355 | 341 |
| 356 void SkEmptyShader::toString(SkString* str) const { | 342 void SkEmptyShader::toString(SkString* str) const { |
| 357 str->append("SkEmptyShader: ("); | 343 str->append("SkEmptyShader: ("); |
| 358 | 344 |
| 359 this->INHERITED::toString(str); | 345 this->INHERITED::toString(str); |
| 360 | 346 |
| 361 str->append(")"); | 347 str->append(")"); |
| 362 } | 348 } |
| 363 #endif | 349 #endif |
| OLD | NEW |