diff options
author | Android Chromium Automerger <chromium-automerger@android> | 2014-05-07 11:18:19 +0000 |
---|---|---|
committer | Android Chromium Automerger <chromium-automerger@android> | 2014-05-07 11:18:19 +0000 |
commit | d60f7edf0fa7eb2eb7c99de486abfe61ad3dcd69 (patch) | |
tree | ad988be7ad87928b7b98c44f2def4cce7d3330b6 | |
parent | 8a8bbe67c60d28430d0a52a68f2ebc67574f3b33 (diff) | |
parent | 1ffcf188ba353bf82876a8d55a127ea6e1dcb27a (diff) | |
download | src-d60f7edf0fa7eb2eb7c99de486abfe61ad3dcd69.tar.gz |
Merge third_party/skia/src from https://chromium.googlesource.com/external/skia/src.git at 1ffcf188ba353bf82876a8d55a127ea6e1dcb27a
This commit was generated by merge_from_chromium.py.
Change-Id: I1bb3256d62017f06f9b6266f5c21e715f807d337
-rw-r--r-- | core/SkBitmapProcShader.h | 5 | ||||
-rw-r--r-- | core/SkBlitter.cpp | 13 | ||||
-rw-r--r-- | core/SkBlitter.h | 3 | ||||
-rw-r--r-- | core/SkCoreBlitters.h | 3 | ||||
-rw-r--r-- | core/SkDraw.cpp | 26 | ||||
-rw-r--r-- | core/SkPictureShader.cpp | 11 | ||||
-rw-r--r-- | core/SkPictureShader.h | 2 | ||||
-rw-r--r-- | core/SkShader.cpp | 8 | ||||
-rw-r--r-- | gpu/GrPictureUtils.h | 6 | ||||
-rw-r--r-- | gpu/SkGpuDevice.cpp | 2 |
10 files changed, 39 insertions, 40 deletions
diff --git a/core/SkBitmapProcShader.h b/core/SkBitmapProcShader.h index 0a036d31..8d312564 100644 --- a/core/SkBitmapProcShader.h +++ b/core/SkBitmapProcShader.h @@ -71,10 +71,7 @@ private: // an Sk3DBlitter in SkDraw.cpp // Note that some contexts may contain other contexts (e.g. for compose shaders), but we've not // yet found a situation where the size below isn't big enough. -typedef SkSmallAllocator<3, sizeof(SkBitmapProcShader) + - sizeof(SkBitmapProcShader::BitmapProcShaderContext) + - sizeof(SkBitmapProcState) + - sizeof(void*) * 2> SkTBlitterAllocator; +typedef SkSmallAllocator<3, 768> SkTBlitterAllocator; // If alloc is non-NULL, it will be used to allocate the returned SkShader, and MUST outlive // the SkShader. diff --git a/core/SkBlitter.cpp b/core/SkBlitter.cpp index 0e12a627..81e46c56 100644 --- a/core/SkBlitter.cpp +++ b/core/SkBlitter.cpp @@ -1,4 +1,3 @@ - /* * Copyright 2006 The Android Open Source Project * @@ -6,7 +5,6 @@ * found in the LICENSE file. */ - #include "SkBlitter.h" #include "SkAntiRun.h" #include "SkColor.h" @@ -26,8 +24,7 @@ SkBlitter::~SkBlitter() {} bool SkBlitter::isNullBlitter() const { return false; } -bool SkBlitter::resetShaderContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix) { +bool SkBlitter::resetShaderContext(const SkShader::ContextRec&) { return true; } @@ -1030,10 +1027,7 @@ SkShaderBlitter::~SkShaderBlitter() { fShader->unref(); } -bool SkShaderBlitter::resetShaderContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix) { - SkShader::ContextRec rec(device, paint, matrix); - +bool SkShaderBlitter::resetShaderContext(const SkShader::ContextRec& rec) { // Only destroy the old context if we have a new one. We need to ensure to have a // live context in fShaderContext because the storage is owned by an SkSmallAllocator // outside of this class. @@ -1045,6 +1039,7 @@ bool SkShaderBlitter::resetShaderContext(const SkBitmap& device, const SkPaint& // Need a valid context in fShaderContext's storage, so we can later (or our caller) call // the in-place destructor. SkNEW_PLACEMENT_ARGS(fShaderContext, SkTransparentShaderContext, (*fShader, rec)); + return false; } - return ctx != NULL; + return true; } diff --git a/core/SkBlitter.h b/core/SkBlitter.h index f76839e8..a3a21961 100644 --- a/core/SkBlitter.h +++ b/core/SkBlitter.h @@ -64,8 +64,7 @@ public: /** * Special methods for SkShaderBlitter. On all other classes this is a no-op. */ - virtual bool resetShaderContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix); + virtual bool resetShaderContext(const SkShader::ContextRec&); virtual SkShader::Context* getShaderContext() const; ///@name non-virtual helpers diff --git a/core/SkCoreBlitters.h b/core/SkCoreBlitters.h index 2d22d38e..20f9437a 100644 --- a/core/SkCoreBlitters.h +++ b/core/SkCoreBlitters.h @@ -41,8 +41,7 @@ public: * Will create the context at the same location as the old one (this is safe * because the shader itself is unchanged). */ - virtual bool resetShaderContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix) SK_OVERRIDE; + virtual bool resetShaderContext(const SkShader::ContextRec&) SK_OVERRIDE; virtual SkShader::Context* getShaderContext() const SK_OVERRIDE { return fShaderContext; } diff --git a/core/SkDraw.cpp b/core/SkDraw.cpp index 9347efe4..24c80557 100644 --- a/core/SkDraw.cpp +++ b/core/SkDraw.cpp @@ -2403,7 +2403,13 @@ bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S if (!m.invert(&im)) { return false; } - fDstToUnit.setConcat(im, this->getTotalInverse()); + // We can't call getTotalInverse(), because we explicitly don't want to look at the localmatrix + // as our interators are intrinsically tied to the vertices, and nothing else. + SkMatrix ctmInv; + if (!this->getCTM().invert(&ctmInv)) { + return false; + } + fDstToUnit.setConcat(im, ctmInv); return true; } @@ -2556,18 +2562,13 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count, VertState::Proc vertProc = state.chooseProc(vmode); if (NULL != textures || NULL != colors) { - SkMatrix tempM; - SkMatrix savedLocalM; - if (shader) { - savedLocalM = shader->getLocalMatrix(); - } - while (vertProc(&state)) { if (NULL != textures) { + SkMatrix tempM; if (texture_to_matrix(state, vertices, textures, &tempM)) { - tempM.postConcat(savedLocalM); - shader->setLocalMatrix(tempM); - if (!blitter->resetShaderContext(*fBitmap, p, *fMatrix)) { + SkShader::ContextRec rec(*fBitmap, p, *fMatrix); + rec.fLocalMatrix = &tempM; + if (!blitter->resetShaderContext(rec)) { continue; } } @@ -2603,11 +2604,6 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count, }; SkScan::FillTriangle(tmp, *fRC, blitter.get()); } - - // now restore the shader's original local matrix - if (NULL != shader) { - shader->setLocalMatrix(savedLocalM); - } } else { // no colors[] and no texture HairProc hairProc = ChooseHairProc(paint.isAntiAlias()); diff --git a/core/SkPictureShader.cpp b/core/SkPictureShader.cpp index 9555624f..9655e85b 100644 --- a/core/SkPictureShader.cpp +++ b/core/SkPictureShader.cpp @@ -52,7 +52,7 @@ void SkPictureShader::flatten(SkWriteBuffer& buffer) const { fPicture->flatten(buffer); } -SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix) const { +SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatrix* localM) const { SkASSERT(fPicture && fPicture->width() > 0 && fPicture->height() > 0); SkMatrix m; @@ -61,6 +61,9 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix) const { } else { m = matrix; } + if (localM) { + m.preConcat(*localM); + } // Use a rotation-invariant scale SkPoint scale; @@ -115,11 +118,11 @@ size_t SkPictureShader::contextSize() const { } SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const { - SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix)); + SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix, rec.fLocalMatrix)); if (NULL == bitmapShader.get()) { return NULL; } - return PictureShaderContext::Create(storage, *this, rec, bitmapShader.detach()); + return PictureShaderContext::Create(storage, *this, rec, bitmapShader); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -190,7 +193,7 @@ void SkPictureShader::toString(SkString* str) const { #if SK_SUPPORT_GPU GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint) const { - SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix())); + SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix(), NULL)); if (!bitmapShader) { return NULL; } diff --git a/core/SkPictureShader.h b/core/SkPictureShader.h index 0fbfbee4..27fb674b 100644 --- a/core/SkPictureShader.h +++ b/core/SkPictureShader.h @@ -41,7 +41,7 @@ protected: private: SkPictureShader(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL); - SkShader* refBitmapShader(const SkMatrix&) const; + SkShader* refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix) const; SkPicture* fPicture; TileMode fTmx, fTmy; diff --git a/core/SkShader.cpp b/core/SkShader.cpp index 8e6112ae..0c954f86 100644 --- a/core/SkShader.cpp +++ b/core/SkShader.cpp @@ -53,6 +53,10 @@ bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse total.setConcat(*m, this->getLocalMatrix()); m = &total; } + if (rec.fLocalMatrix) { + total.setConcat(*m, *rec.fLocalMatrix); + m = &total; + } return m->invert(totalInverse); } @@ -63,7 +67,7 @@ SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage) return this->onCreateContext(rec, storage); } -SkShader::Context* SkShader::onCreateContext(const ContextRec&, void*) const { +SkShader::Context* SkShader::onCreateContext(const ContextRec& rec, void*) const { return NULL; } @@ -72,7 +76,7 @@ size_t SkShader::contextSize() const { } SkShader::Context::Context(const SkShader& shader, const ContextRec& rec) - : fShader(shader) + : fShader(shader), fCTM(*rec.fMatrix) { // Because the context parameters must be valid at this point, we know that the matrix is // invertible. diff --git a/gpu/GrPictureUtils.h b/gpu/GrPictureUtils.h index 8fdb3b85..c6252986 100644 --- a/gpu/GrPictureUtils.h +++ b/gpu/GrPictureUtils.h @@ -45,6 +45,12 @@ public: GPUAccelData(Key key) : INHERITED(key) { } + virtual ~GPUAccelData() { + for (int i = 0; i < fSaveLayerInfo.count(); ++i) { + SkDELETE(fSaveLayerInfo[i].fPaint); + } + } + void addSaveLayerInfo(const SaveLayerInfo& info) { SkASSERT(info.fSaveLayerOpID < info.fRestoreOpID); *fSaveLayerInfo.push() = info; diff --git a/gpu/SkGpuDevice.cpp b/gpu/SkGpuDevice.cpp index 3119a9e7..517f082a 100644 --- a/gpu/SkGpuDevice.cpp +++ b/gpu/SkGpuDevice.cpp @@ -1913,7 +1913,7 @@ SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) { SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); - GPUAccelData* data = SkNEW_ARGS(GPUAccelData, (key)); + SkAutoTUnref<GPUAccelData> data(SkNEW_ARGS(GPUAccelData, (key))); picture->EXPERIMENTAL_addAccelData(data); |