diff options
author | Brian Osman <brianosman@google.com> | 2016-12-05 15:26:50 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-05 21:48:59 +0000 |
commit | 11970e56c10b49ad06adbe9e835d32c00a63dd7d (patch) | |
tree | 8e5f264ddc37121cc59277a768e7447bebc57ff0 | |
parent | 45565b676c86d6b4955b8643236880b016772e95 (diff) |
Add destination color space to shader ContextRec
BUG=skia:
Change-Id: Ib1920fffd5735ad54a5b785bbc2676ea240bdbfa
Reviewed-on: https://skia-review.googlesource.com/5611
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
-rw-r--r-- | bench/SkLinearBitmapPipelineBench.cpp | 3 | ||||
-rw-r--r-- | gm/SkLinearBitmapPipelineGM.cpp | 3 | ||||
-rw-r--r-- | include/core/SkShader.h | 6 | ||||
-rw-r--r-- | src/core/SkBlitter.cpp | 5 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 3 | ||||
-rw-r--r-- | src/core/SkNormalMapSource.cpp | 2 |
6 files changed, 14 insertions, 8 deletions
diff --git a/bench/SkLinearBitmapPipelineBench.cpp b/bench/SkLinearBitmapPipelineBench.cpp index 8582ce95b8..f34cb452e8 100644 --- a/bench/SkLinearBitmapPipelineBench.cpp +++ b/bench/SkLinearBitmapPipelineBench.cpp @@ -202,7 +202,8 @@ struct SkBitmapFPOrigShader : public CommonBitmapFPBenchmark { uint32_t storage[kSkBlitterContextSize]; const SkShader::ContextRec rec(fPaint, fM, nullptr, - SkShader::ContextRec::kPMColor_DstType); + SkShader::ContextRec::kPMColor_DstType, + nullptr); SkASSERT(fPaint.getShader()->contextSize(rec) <= sizeof(storage)); SkShader::Context* ctx = fPaint.getShader()->createContext(rec, storage); diff --git a/gm/SkLinearBitmapPipelineGM.cpp b/gm/SkLinearBitmapPipelineGM.cpp index bde8ee8022..43e4a247bb 100644 --- a/gm/SkLinearBitmapPipelineGM.cpp +++ b/gm/SkLinearBitmapPipelineGM.cpp @@ -71,7 +71,8 @@ static void draw_rect_orig(SkCanvas* canvas, const SkRect& r, SkColor c, const S } paint.setShader(std::move(shader)); const SkShader::ContextRec rec(paint, *mat, nullptr, - SkBlitter::PreferredShaderDest(pmsrc.info())); + SkBlitter::PreferredShaderDest(pmsrc.info()), + canvas->imageInfo().colorSpace()); SkASSERT(paint.getShader()->contextSize(rec) <= sizeof(storage)); SkShader::Context* ctx = paint.getShader()->createContext(rec, storage); diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 9e05a38899..cafeedd0d1 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -116,16 +116,18 @@ public: }; ContextRec(const SkPaint& paint, const SkMatrix& matrix, const SkMatrix* localM, - DstType dstType) + DstType dstType, SkColorSpace* dstColorSpace) : fPaint(&paint) , fMatrix(&matrix) , fLocalMatrix(localM) - , fPreferredDstType(dstType) {} + , fPreferredDstType(dstType) + , fDstColorSpace(dstColorSpace) {} const SkPaint* fPaint; // the current paint associated with the draw const SkMatrix* fMatrix; // the current matrix in the canvas const SkMatrix* fLocalMatrix; // optional local matrix const DstType fPreferredDstType; // the "natural" client dest type + SkColorSpace* fDstColorSpace; // the color space of the dest surface (if any) }; class Context : public ::SkNoncopyable { diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index a05c176bcd..c97956c20f 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -891,7 +891,8 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device, SkShader::Context* shaderContext = nullptr; if (shader) { const SkShader::ContextRec rec(*paint, matrix, nullptr, - PreferredShaderDest(device.info())); + PreferredShaderDest(device.info()), + device.colorSpace()); size_t contextSize = shader->contextSize(rec); if (contextSize) { // Try to create the ShaderContext @@ -978,7 +979,7 @@ public: SkZeroShaderContext(const SkShader& shader, const SkShader::ContextRec& rec) // Override rec with the identity matrix, so it is guaranteed to be invertible. : INHERITED(shader, SkShader::ContextRec(*rec.fPaint, SkMatrix::I(), nullptr, - rec.fPreferredDstType)) {} + rec.fPreferredDstType, rec.fDstColorSpace)) {} void shadeSpan(int x, int y, SkPMColor colors[], int count) override { sk_bzero(colors, count * sizeof(SkPMColor)); diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index a2d7a51dff..2f3dd3eccd 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1956,7 +1956,8 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count, SkMatrix tempM; if (texture_to_matrix(state, vertices, textures, &tempM)) { SkShader::ContextRec rec(p, *fMatrix, &tempM, - SkBlitter::PreferredShaderDest(fDst.info())); + SkBlitter::PreferredShaderDest(fDst.info()), + fDst.colorSpace()); if (!blitter->resetShaderContext(rec)) { continue; } diff --git a/src/core/SkNormalMapSource.cpp b/src/core/SkNormalMapSource.cpp index 04f6d5a651..204effab11 100644 --- a/src/core/SkNormalMapSource.cpp +++ b/src/core/SkNormalMapSource.cpp @@ -157,7 +157,7 @@ SkNormalSource::Provider* SkNormalMapSourceImpl::asProvider(const SkShader::Cont SkPaint* overridePaint = new (paintStorage) SkPaint(*(rec.fPaint)); overridePaint->setAlpha(0xFF); SkShader::ContextRec overrideRec(*overridePaint, *(rec.fMatrix), rec.fLocalMatrix, - rec.fPreferredDstType); + rec.fPreferredDstType, rec.fDstColorSpace); void* mapContextStorage = (char*) paintStorage + sizeof(SkPaint); SkShader::Context* context = fMapShader->createContext(overrideRec, mapContextStorage); |