Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: src/core/SkShader.cpp

Issue 1793883002: add blitprocs to shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkColorShader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkShader.cpp
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 1413a6ee7336aecd60762c71c11889def7f7c04d..cb0517bf64073e43389e4b4868a9ffeeaf253237 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -361,6 +361,46 @@ void SkColorShader::toString(SkString* str) const {
///////////////////////////////////////////////////////////////////////////////
+static void D32_BlitProc(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 D64_BlitProc(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
+ int count, const SkAlpha aa[]) {
+ SkXfermode::D64Proc proc = (SkXfermode::D64Proc)state->fStorage[0];
+ const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
+ proc(state->fXfer, dst.writable_addr64(x, y), src, count, aa);
+}
+
+SkShader::Context::BlitProc
+SkColorShader::ColorShaderContext::onChooseBlitProc(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;
+ return D32_BlitProc;
+ case kRGBA_F16_SkColorType:
+ flags |= SkXfermode::kDstIsFloat16_D64Flag;
+ state->fStorage[0] = (void*)SkXfermode::GetD64Proc(state->fXfer, flags);
+ state->fStorage[1] = &fPM4f;
+ return D64_BlitProc;
+ default:
+ return nullptr;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) {
return SkShader::MakeEmptyShader().release();
}
« no previous file with comments | « src/core/SkColorShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698