diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkColorShader.h | 5 | ||||
-rw-r--r-- | src/core/SkPictureCommon.h | 3 | ||||
-rw-r--r-- | src/core/SkPictureShader.cpp | 14 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 6 | ||||
-rw-r--r-- | src/device/xps/SkXPSDevice.cpp | 39 | ||||
-rw-r--r-- | src/effects/gradients/SkLinearGradient.cpp | 16 | ||||
-rw-r--r-- | src/effects/gradients/SkLinearGradient.h | 1 | ||||
-rw-r--r-- | src/effects/gradients/SkRadialGradient.cpp | 17 | ||||
-rw-r--r-- | src/effects/gradients/SkRadialGradient.h | 1 | ||||
-rw-r--r-- | src/effects/gradients/SkSweepGradient.cpp | 15 | ||||
-rw-r--r-- | src/effects/gradients/SkSweepGradient.h | 2 | ||||
-rw-r--r-- | src/effects/gradients/SkTwoPointConicalGradient.cpp | 29 | ||||
-rw-r--r-- | src/effects/gradients/SkTwoPointConicalGradient.h | 1 | ||||
-rw-r--r-- | src/pdf/SkPDFShader.cpp | 8 | ||||
-rw-r--r-- | src/utils/SkLua.cpp | 23 | ||||
-rw-r--r-- | src/utils/android/SkAndroidSDKCanvas.cpp | 2 |
16 files changed, 38 insertions, 144 deletions
diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h index ee196c09ff..6702ef6085 100644 --- a/src/core/SkColorShader.h +++ b/src/core/SkColorShader.h @@ -47,11 +47,6 @@ public: typedef SkShader::Context INHERITED; }; - // we return false for this, use asAGradient - virtual BitmapType asABitmap(SkBitmap* outTexture, - SkMatrix* outMatrix, - TileMode xy[2]) const override; - GradientType asAGradient(GradientInfo* info) const override; bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, diff --git a/src/core/SkPictureCommon.h b/src/core/SkPictureCommon.h index 827bf117de..3d64888641 100644 --- a/src/core/SkPictureCommon.h +++ b/src/core/SkPictureCommon.h @@ -59,8 +59,7 @@ struct SkBitmapHunter { const SkPaint* paint = AsPtr(r.paint); if (paint) { const SkShader* shader = paint->getShader(); - if (shader && - shader->asABitmap(nullptr, nullptr, nullptr) == SkShader::kDefault_BitmapType) { + if (shader && shader->isABitmap()) { return true; } } diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index e04e248756..f8c2ab09f8 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -83,12 +83,14 @@ struct BitmapShaderRec : public SkResourceCache::Rec { result->reset(SkRef(rec.fShader.get())); SkBitmap tile; - rec.fShader.get()->asABitmap(&tile, NULL, NULL); - // FIXME: this doesn't protect the pixels from being discarded as soon as we unlock. - // Should be handled via a pixel ref generator instead - // (https://code.google.com/p/skia/issues/detail?id=3220). - SkAutoLockPixels alp(tile, true); - return tile.getPixels() != NULL; + if (rec.fShader.get()->isABitmap(&tile, NULL, NULL)) { + // FIXME: this doesn't protect the pixels from being discarded as soon as we unlock. + // Should be handled via a pixel ref generator instead + // (https://code.google.com/p/skia/issues/detail?id=3220). + SkAutoLockPixels alp(tile, true); + return tile.getPixels() != NULL; + } + return false; } }; diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index e5c879eecb..41724d9048 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -325,12 +325,6 @@ void SkColorShader::ColorShaderContext::shadeSpanAlpha(int x, int y, uint8_t alp memset(alpha, SkGetPackedA32(fPMColor), count); } -// if we had a asAColor method, that would be more efficient... -SkShader::BitmapType SkColorShader::asABitmap(SkBitmap* bitmap, SkMatrix* matrix, - TileMode modes[]) const { - return kNone_BitmapType; -} - SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { if (info) { if (info->fColors && info->fColorCount >= 1) { diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp index 56800d1540..2b15cd9f4a 100644 --- a/src/device/xps/SkXPSDevice.cpp +++ b/src/device/xps/SkXPSDevice.cpp @@ -1071,33 +1071,24 @@ HRESULT SkXPSDevice::createXpsBrush(const SkPaint& skPaint, SkBitmap outTexture; SkMatrix outMatrix; SkShader::TileMode xy[2]; - SkShader::BitmapType bitmapType = shader->asABitmap(&outTexture, - &outMatrix, - xy); - switch (bitmapType) { - case SkShader::kDefault_BitmapType: { - //TODO: outMatrix?? - SkMatrix localMatrix = shader->getLocalMatrix(); - if (parentTransform) { - localMatrix.preConcat(*parentTransform); - } - - SkTScopedComPtr<IXpsOMTileBrush> tileBrush; - HR(this->createXpsImageBrush(outTexture, - localMatrix, - xy, - skPaint.getAlpha(), - &tileBrush)); + if (shader->isABitmap(&outTexture, &outMatrix, xy)) { + //TODO: outMatrix?? + SkMatrix localMatrix = shader->getLocalMatrix(); + if (parentTransform) { + localMatrix.preConcat(*parentTransform); + } - HRM(tileBrush->QueryInterface<IXpsOMBrush>(brush), "QI failed."); + SkTScopedComPtr<IXpsOMTileBrush> tileBrush; + HR(this->createXpsImageBrush(outTexture, + localMatrix, + xy, + skPaint.getAlpha(), + &tileBrush)); - return S_OK; - } - default: - break; + HRM(tileBrush->QueryInterface<IXpsOMBrush>(brush), "QI failed."); + } else { + HR(this->createXpsSolidColorBrush(skPaint.getColor(), 0xFF, brush)); } - - HR(this->createXpsSolidColorBrush(skPaint.getColor(), 0xFF, brush)); return S_OK; } diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index fb0aa9836a..d9b4a5c9b0 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -261,22 +261,6 @@ void SkLinearGradient::LinearGradientContext::shadeSpan(int x, int y, SkPMColor* } } -SkShader::BitmapType SkLinearGradient::asABitmap(SkBitmap* bitmap, - SkMatrix* matrix, - TileMode xy[]) const { - if (bitmap) { - this->getGradientTableBitmap(bitmap); - } - if (matrix) { - matrix->preConcat(fPtsToUnit); - } - if (xy) { - xy[0] = fTileMode; - xy[1] = kClamp_TileMode; - } - return kLinear_BitmapType; -} - SkShader::GradientType SkLinearGradient::asAGradient(GradientInfo* info) const { if (info) { commonAsAGradient(info); diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h index 2330f5be06..eddb35512f 100644 --- a/src/effects/gradients/SkLinearGradient.h +++ b/src/effects/gradients/SkLinearGradient.h @@ -28,7 +28,6 @@ public: typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; }; - BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; GradientType asAGradient(GradientInfo* info) const override; bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, const SkMatrix*, GrColor*, GrProcessorDataManager*, diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 4ff635ab47..a6a00cdf7b 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -225,23 +225,6 @@ void SkRadialGradient::RadialGradientContext::shadeSpan16(int x, int y, uint16_t } } -SkShader::BitmapType SkRadialGradient::asABitmap(SkBitmap* bitmap, - SkMatrix* matrix, SkShader::TileMode* xy) const { - if (bitmap) { - this->getGradientTableBitmap(bitmap); - } - if (matrix) { - matrix->setScale(SkIntToScalar(kCache32Count), - SkIntToScalar(kCache32Count)); - matrix->preConcat(fPtsToUnit); - } - if (xy) { - xy[0] = fTileMode; - xy[1] = kClamp_TileMode; - } - return kRadial_BitmapType; -} - SkShader::GradientType SkRadialGradient::asAGradient(GradientInfo* info) const { if (info) { commonAsAGradient(info); diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h index 0e3a893eae..d0f63ac54d 100644 --- a/src/effects/gradients/SkRadialGradient.h +++ b/src/effects/gradients/SkRadialGradient.h @@ -28,7 +28,6 @@ public: typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; }; - BitmapType asABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* xy) const override; GradientType asAGradient(GradientInfo* info) const override; bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, const SkMatrix*, GrColor*, GrProcessorDataManager*, diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 1881690494..22bf68eaea 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -22,21 +22,6 @@ SkSweepGradient::SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor& des fTileMode = SkShader::kClamp_TileMode; } -SkShader::BitmapType SkSweepGradient::asABitmap(SkBitmap* bitmap, - SkMatrix* matrix, SkShader::TileMode* xy) const { - if (bitmap) { - this->getGradientTableBitmap(bitmap); - } - if (matrix) { - *matrix = fPtsToUnit; - } - if (xy) { - xy[0] = fTileMode; - xy[1] = kClamp_TileMode; - } - return kSweep_BitmapType; -} - SkShader::GradientType SkSweepGradient::asAGradient(GradientInfo* info) const { if (info) { commonAsAGradient(info); diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h index e9d5fb781f..bc465bdc44 100644 --- a/src/effects/gradients/SkSweepGradient.h +++ b/src/effects/gradients/SkSweepGradient.h @@ -28,8 +28,6 @@ public: typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; }; - BitmapType asABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* xy) const override; - GradientType asAGradient(GradientInfo* info) const override; bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 56b9458605..1cdb19e1b9 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -292,35 +292,6 @@ void SkTwoPointConicalGradient::TwoPointConicalGradientContext::shadeSpan( } } -SkShader::BitmapType SkTwoPointConicalGradient::asABitmap( - SkBitmap* bitmap, SkMatrix* matrix, SkShader::TileMode* xy) const { - SkPoint diff = fCenter2 - fCenter1; - SkScalar diffLen = 0; - - if (bitmap) { - this->getGradientTableBitmap(bitmap); - } - if (matrix) { - diffLen = diff.length(); - } - if (matrix) { - if (diffLen) { - SkScalar invDiffLen = SkScalarInvert(diffLen); - // rotate to align circle centers with the x-axis - matrix->setSinCos(-SkScalarMul(invDiffLen, diff.fY), - SkScalarMul(invDiffLen, diff.fX)); - } else { - matrix->reset(); - } - matrix->preTranslate(-fCenter1.fX, -fCenter1.fY); - } - if (xy) { - xy[0] = fTileMode; - xy[1] = kClamp_TileMode; - } - return kTwoPointConical_BitmapType; -} - // Returns the original non-sorted version of the gradient SkShader::GradientType SkTwoPointConicalGradient::asAGradient( GradientInfo* info) const { diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h index 010857c55e..8bba9e1b7f 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.h +++ b/src/effects/gradients/SkTwoPointConicalGradient.h @@ -58,7 +58,6 @@ public: typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; }; - BitmapType asABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* xy) const override; SkShader::GradientType asAGradient(GradientInfo* info) const override; bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, const SkMatrix*, GrColor*, GrProcessorDataManager*, diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index c627c14257..e518bcf89c 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -1110,10 +1110,10 @@ SkPDFShader::State::State(const SkShader& shader, const SkMatrix& canvasTransfor fType = shader.asAGradient(&fInfo); if (fType == SkShader::kNone_GradientType) { - SkShader::BitmapType bitmapType; SkMatrix matrix; - bitmapType = shader.asABitmap(&fImage, &matrix, fImageTileModes); - if (bitmapType != SkShader::kDefault_BitmapType) { + if (shader.isABitmap(&fImage, &matrix, fImageTileModes)) { + SkASSERT(matrix.isIdentity()); + } else { // Generic fallback for unsupported shaders: // * allocate a bbox-sized bitmap // * shade the whole area @@ -1153,8 +1153,6 @@ SkPDFShader::State::State(const SkShader& shader, const SkMatrix& canvasTransfor fShaderTransform.setTranslate(shaderRect.x(), shaderRect.y()); fShaderTransform.preScale(1 / scale.width(), 1 / scale.height()); - } else { - SkASSERT(matrix.isIdentity()); } fPixelGeneration = fImage.getGenerationID(); } else { diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp index 7c378c9b81..e5d4c2b3a4 100644 --- a/src/utils/SkLua.cpp +++ b/src/utils/SkLua.cpp @@ -1200,23 +1200,20 @@ static int lshader_isOpaque(lua_State* L) { return shader && shader->isOpaque(); } -static int lshader_asABitmap(lua_State* L) { +static int lshader_isABitmap(lua_State* L) { SkShader* shader = get_ref<SkShader>(L, 1); if (shader) { SkBitmap bm; SkMatrix matrix; SkShader::TileMode modes[2]; - switch (shader->asABitmap(&bm, &matrix, modes)) { - case SkShader::kDefault_BitmapType: - lua_newtable(L); - setfield_number(L, "genID", bm.pixelRef() ? bm.pixelRef()->getGenerationID() : 0); - setfield_number(L, "width", bm.width()); - setfield_number(L, "height", bm.height()); - setfield_string(L, "tileX", mode2string(modes[0])); - setfield_string(L, "tileY", mode2string(modes[1])); - return 1; - default: - break; + if (shader->isABitmap(&bm, &matrix, modes)) { + lua_newtable(L); + setfield_number(L, "genID", bm.pixelRef() ? bm.pixelRef()->getGenerationID() : 0); + setfield_number(L, "width", bm.width()); + setfield_number(L, "height", bm.height()); + setfield_string(L, "tileX", mode2string(modes[0])); + setfield_string(L, "tileY", mode2string(modes[1])); + return 1; } } return 0; @@ -1260,7 +1257,7 @@ static int lshader_gc(lua_State* L) { static const struct luaL_Reg gSkShader_Methods[] = { { "isOpaque", lshader_isOpaque }, - { "asABitmap", lshader_asABitmap }, + { "isABitmap", lshader_isABitmap }, { "asAGradient", lshader_asAGradient }, { "__gc", lshader_gc }, { NULL, NULL } diff --git a/src/utils/android/SkAndroidSDKCanvas.cpp b/src/utils/android/SkAndroidSDKCanvas.cpp index b05605bbf9..2eec95f66c 100644 --- a/src/utils/android/SkAndroidSDKCanvas.cpp +++ b/src/utils/android/SkAndroidSDKCanvas.cpp @@ -23,7 +23,7 @@ void CheckShader(SkPaint* paint) { return; } - if (shader->asABitmap(NULL, NULL, NULL) == SkShader::kDefault_BitmapType) { + if (shader->isABitmap()) { return; } if (shader->asACompose(NULL)) { |