Index: src/core/SkShader.cpp |
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp |
index 0ed97b02239e3d9bc7b9f429d1c56ca97a301f59..1b729ea9a851f45ec42f5e370e86e38584832897 100644 |
--- a/src/core/SkShader.cpp |
+++ b/src/core/SkShader.cpp |
@@ -252,171 +252,7 @@ void SkShader::toString(SkString* str) const { |
} |
#endif |
-////////////////////////////////////////////////////////////////////////////// |
- |
-#include "SkUtils.h" |
- |
-SkColorShader::SkColorShader(SkColor c) |
- : fColor(c) { |
-} |
- |
-bool SkColorShader::isOpaque() const { |
- return SkColorGetA(fColor) == 255; |
-} |
- |
-sk_sp<SkFlattenable> SkColorShader::CreateProc(SkReadBuffer& buffer) { |
- return sk_make_sp<SkColorShader>(buffer.readColor()); |
-} |
- |
-void SkColorShader::flatten(SkWriteBuffer& buffer) const { |
- buffer.writeColor(fColor); |
-} |
- |
-uint32_t SkColorShader::ColorShaderContext::getFlags() const { |
- return fFlags; |
-} |
- |
-SkShader::Context* SkColorShader::onCreateContext(const ContextRec& rec, void* storage) const { |
- return new (storage) ColorShaderContext(*this, rec); |
-} |
- |
-SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shader, |
- const ContextRec& rec) |
- : INHERITED(shader, rec) |
-{ |
- SkColor color = shader.fColor; |
- unsigned a = SkAlphaMul(SkColorGetA(color), SkAlpha255To256(rec.fPaint->getAlpha())); |
- |
- unsigned r = SkColorGetR(color); |
- unsigned g = SkColorGetG(color); |
- unsigned b = SkColorGetB(color); |
- |
- if (a != 255) { |
- r = SkMulDiv255Round(r, a); |
- g = SkMulDiv255Round(g, a); |
- b = SkMulDiv255Round(b, a); |
- } |
- fPMColor = SkPackARGB32(a, r, g, b); |
- |
- SkColor4f c4 = SkColor4f::FromColor(shader.fColor); |
- c4.fA *= rec.fPaint->getAlpha() / 255.0f; |
- fPM4f = c4.premul(); |
- |
- fFlags = kConstInY32_Flag; |
- if (255 == a) { |
- fFlags |= kOpaqueAlpha_Flag; |
- } |
-} |
- |
-void SkColorShader::ColorShaderContext::shadeSpan(int x, int y, SkPMColor span[], int count) { |
- sk_memset32(span, fPMColor, count); |
-} |
- |
-void SkColorShader::ColorShaderContext::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) { |
- memset(alpha, SkGetPackedA32(fPMColor), count); |
-} |
- |
-void SkColorShader::ColorShaderContext::shadeSpan4f(int x, int y, SkPM4f span[], int count) { |
- for (int i = 0; i < count; ++i) { |
- span[i] = fPM4f; |
- } |
-} |
- |
-SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { |
- if (info) { |
- if (info->fColors && info->fColorCount >= 1) { |
- info->fColors[0] = fColor; |
- } |
- info->fColorCount = 1; |
- info->fTileMode = SkShader::kRepeat_TileMode; |
- } |
- return kColor_GradientType; |
-} |
- |
-#if SK_SUPPORT_GPU |
- |
-#include "SkGr.h" |
-#include "effects/GrConstColorProcessor.h" |
-const GrFragmentProcessor* SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&, |
- const SkMatrix*, |
- SkFilterQuality) const { |
- GrColor color = SkColorToPremulGrColor(fColor); |
- return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode); |
-} |
- |
-#endif |
- |
-#ifndef SK_IGNORE_TO_STRING |
-void SkColorShader::toString(SkString* str) const { |
- str->append("SkColorShader: ("); |
- |
- str->append("Color: "); |
- str->appendHex(fColor); |
- |
- this->INHERITED::toString(str); |
- |
- str->append(")"); |
-} |
-#endif |
- |
-/////////////////////////////////////////////////////////////////////////////// |
- |
-static void D32_BlitBW(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst, |
- int count) { |
- SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0]; |
- const SkPM4f* src = (const SkPM4f*)state->fStorage[1]; |
- proc(state->fXfer, dst.writable_addr32(x, y), src, count, nullptr); |
-} |
- |
-static void D32_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst, |
- int count, const SkAlpha aa[]) { |
- SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0]; |
- const SkPM4f* src = (const SkPM4f*)state->fStorage[1]; |
- proc(state->fXfer, dst.writable_addr32(x, y), src, count, aa); |
-} |
- |
-static void F16_BlitBW(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst, |
- int count) { |
- SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0]; |
- const SkPM4f* src = (const SkPM4f*)state->fStorage[1]; |
- proc(state->fXfer, dst.writable_addr64(x, y), src, count, nullptr); |
-} |
- |
-static void F16_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst, |
- int count, const SkAlpha aa[]) { |
- SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0]; |
- const SkPM4f* src = (const SkPM4f*)state->fStorage[1]; |
- proc(state->fXfer, dst.writable_addr64(x, y), src, count, aa); |
-} |
- |
-bool SkColorShader::ColorShaderContext::onChooseBlitProcs(const SkImageInfo& info, |
- BlitState* state) { |
- uint32_t flags = SkXfermode::kSrcIsSingle_D32Flag; |
- if (fPM4f.a() == 1) { |
- flags |= SkXfermode::kSrcIsOpaque_D32Flag; |
- } |
- switch (info.colorType()) { |
- case kN32_SkColorType: |
- if (info.isSRGB()) { |
- flags |= SkXfermode::kDstIsSRGB_D32Flag; |
- } |
- state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fXfer, flags); |
- state->fStorage[1] = &fPM4f; |
- state->fBlitBW = D32_BlitBW; |
- state->fBlitAA = D32_BlitAA; |
- return true; |
- case kRGBA_F16_SkColorType: |
- state->fStorage[0] = (void*)SkXfermode::GetF16Proc(state->fXfer, flags); |
- state->fStorage[1] = &fPM4f; |
- state->fBlitBW = F16_BlitBW; |
- state->fBlitAA = F16_BlitAA; |
- return true; |
- default: |
- return false; |
- } |
-} |
- |
-/////////////////////////////////////////////////////////////////////////////// |
+/////////////////////////////////////////////////////////////////////////////////////////////////// |
sk_sp<SkFlattenable> SkEmptyShader::CreateProc(SkReadBuffer&) { |
return SkShader::MakeEmptyShader(); |