aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2016-09-28 17:13:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-09-28 21:42:04 +0000
commit627778d5ba4fd6f4a4a1238bbf7a1b561469fe21 (patch)
tree25438c2d6f388c4b93c03100c44b20e8fa22f36e /src
parente95ea08cf4134eff0fa1f7afe624b4a49e3c5ba4 (diff)
isABitmap is deprecated, use isAImage
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2748 Change-Id: I7006a3231ff0e9e39b187deae550364bc97f49d6 Reviewed-on: https://skia-review.googlesource.com/2748 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkLocalMatrixShader.h6
-rw-r--r--src/core/SkPictureCommon.h2
-rw-r--r--src/image/SkImageShader.cpp2
-rw-r--r--src/image/SkImageShader.h2
-rw-r--r--src/utils/SkLua.cpp13
-rw-r--r--src/xps/SkXPSDevice.cpp4
6 files changed, 20 insertions, 9 deletions
diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h
index 786ccec788..849d9af91d 100644
--- a/src/core/SkLocalMatrixShader.h
+++ b/src/core/SkLocalMatrixShader.h
@@ -47,9 +47,15 @@ protected:
return fProxyShader->contextSize(rec);
}
+ SkImage* onIsAImage(SkMatrix* matrix, TileMode* mode) const override {
+ return fProxyShader->isAImage(matrix, mode);
+ }
+
+#ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
bool onIsABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* mode) const override {
return fProxyShader->isABitmap(bitmap, matrix, mode);
}
+#endif
private:
SkAutoTUnref<SkShader> fProxyShader;
diff --git a/src/core/SkPictureCommon.h b/src/core/SkPictureCommon.h
index 0a0c6b5ca9..9b0a2f7c04 100644
--- a/src/core/SkPictureCommon.h
+++ b/src/core/SkPictureCommon.h
@@ -58,7 +58,7 @@ private:
static bool PaintHasBitmap(const SkPaint* paint) {
if (paint) {
const SkShader* shader = paint->getShader();
- if (shader && shader->isABitmap()) {
+ if (shader && shader->isAImage()) {
return true;
}
}
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index e52deff270..8407f10086 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -65,6 +65,7 @@ SkImage* SkImageShader::onIsAImage(SkMatrix* texM, TileMode xy[]) const {
return const_cast<SkImage*>(fImage.get());
}
+#ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
bool SkImageShader::onIsABitmap(SkBitmap* texture, SkMatrix* texM, TileMode xy[]) const {
const SkBitmap* bm = as_IB(fImage)->onPeekBitmap();
if (!bm) {
@@ -83,6 +84,7 @@ bool SkImageShader::onIsABitmap(SkBitmap* texture, SkMatrix* texM, TileMode xy[]
}
return true;
}
+#endif
static bool bitmap_is_too_big(int w, int h) {
// SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it
diff --git a/src/image/SkImageShader.h b/src/image/SkImageShader.h
index 213d5e8a8d..8905881a99 100644
--- a/src/image/SkImageShader.h
+++ b/src/image/SkImageShader.h
@@ -32,7 +32,9 @@ protected:
void flatten(SkWriteBuffer&) const override;
size_t onContextSize(const ContextRec&) const override;
Context* onCreateContext(const ContextRec&, void* storage) const override;
+#ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode*) const override;
+#endif
SkImage* onIsAImage(SkMatrix*, TileMode*) const override;
sk_sp<SkImage> fImage;
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index d9beaed2eb..e80708c71c 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -1248,17 +1248,16 @@ static int lshader_isOpaque(lua_State* L) {
return shader && shader->isOpaque();
}
-static int lshader_isABitmap(lua_State* L) {
+static int lshader_isAImage(lua_State* L) {
SkShader* shader = get_ref<SkShader>(L, 1);
if (shader) {
- SkBitmap bm;
SkMatrix matrix;
SkShader::TileMode modes[2];
- if (shader->isABitmap(&bm, &matrix, modes)) {
+ if (SkImage* image = shader->isAImage(&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_number(L, "id", image->uniqueID());
+ setfield_number(L, "width", image->width());
+ setfield_number(L, "height", image->height());
setfield_string(L, "tileX", mode2string(modes[0]));
setfield_string(L, "tileY", mode2string(modes[1]));
return 1;
@@ -1305,7 +1304,7 @@ static int lshader_gc(lua_State* L) {
static const struct luaL_Reg gSkShader_Methods[] = {
{ "isOpaque", lshader_isOpaque },
- { "isABitmap", lshader_isABitmap },
+ { "isAImage", lshader_isAImage },
{ "asAGradient", lshader_asAGradient },
{ "__gc", lshader_gc },
{ nullptr, nullptr }
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index 566651e5d9..7757cb8774 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -30,6 +30,7 @@
#include "SkGeometry.h"
#include "SkGlyphCache.h"
#include "SkHRESULT.h"
+#include "SkImage.h"
#include "SkImageEncoder.h"
#include "SkIStream.h"
#include "SkMaskFilter.h"
@@ -1080,7 +1081,8 @@ HRESULT SkXPSDevice::createXpsBrush(const SkPaint& skPaint,
SkBitmap outTexture;
SkMatrix outMatrix;
SkShader::TileMode xy[2];
- if (shader->isABitmap(&outTexture, &outMatrix, xy)) {
+ SkImage* image = shader->isAImage(&outMatrix, xy);
+ if (image && image->asLegacyBitmap(&outTexture, SkImage::kRO_LegacyBitmapMode)) {
//TODO: outMatrix??
SkMatrix localMatrix = shader->getLocalMatrix();
if (parentTransform) {