From c87f99ef0649a525471971c4edd8b57fc0f7ef3c Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Fri, 9 Dec 2016 16:51:55 -0500 Subject: [PATCH] Make subset param to texture generation API non-optional We were always already supplying this, makes it simpler BUG=skia: Change-Id: I36ac35205df5ab2a0fb7ec26e83ddb1547154816 Reviewed-on: https://skia-review.googlesource.com/5778 Reviewed-by: Brian Salomon Commit-Queue: Brian Osman --- gm/image_pict.cpp | 11 ++++------- include/core/SkImageGenerator.h | 4 ++-- src/core/SkImageCacherator.cpp | 4 ++-- src/core/SkImageGenerator.cpp | 4 ++-- src/core/SkPictureImageGenerator.cpp | 10 ++++------ 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp index 76ea3d9..3a84905 100644 --- a/gm/image_pict.cpp +++ b/gm/image_pict.cpp @@ -221,7 +221,7 @@ public: } } protected: - GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override { + GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect& subset) override { if (ctx) { SkASSERT(ctx == fCtx.get()); } @@ -230,16 +230,13 @@ protected: return nullptr; } - if (!subset) { - return SkRef(fTexture.get()); - } // need to copy the subset into a new texture GrSurfaceDesc desc = fTexture->desc(); - desc.fWidth = subset->width(); - desc.fHeight = subset->height(); + desc.fWidth = subset.width(); + desc.fHeight = subset.height(); GrTexture* dst = fCtx->textureProvider()->createTexture(desc, SkBudgeted::kNo); - fCtx->copySurface(dst, fTexture.get(), *subset, SkIPoint::Make(0, 0)); + fCtx->copySurface(dst, fTexture.get(), subset, SkIPoint::Make(0, 0)); return dst; } private: diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index 7bb4669..5742c1e 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -128,7 +128,7 @@ public: * - its internal context is the same * - it can somehow convert its texture into one that is valid for the provided context. */ - GrTexture* generateTexture(GrContext*, const SkIRect* subset = nullptr); + GrTexture* generateTexture(GrContext*, const SkIRect& subset); struct SupportedSizes { SkISize fSizes[2]; @@ -259,7 +259,7 @@ protected: return false; } - virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { + virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect&) { return nullptr; } diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index 03624fd..f18eea3 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -235,7 +235,7 @@ bool SkImageCacherator::lockAsBitmap(SkBitmap* bitmap, const SkImage* client, ScopedGenerator generator(fSharedGenerator); SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), cacheInfo.width(), cacheInfo.height()); - tex.reset(generator->generateTexture(nullptr, &subset)); + tex.reset(generator->generateTexture(nullptr, subset)); } if (!tex) { bitmap->reset(); @@ -545,7 +545,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori { ScopedGenerator generator(fSharedGenerator); SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height()); - if (GrTexture* tex = generator->generateTexture(ctx, &subset)) { + if (GrTexture* tex = generator->generateTexture(ctx, subset)) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, kLockTexturePathCount); return set_key_and_return(tex, key); diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp index 377c873..410f681 100644 --- a/src/core/SkImageGenerator.cpp +++ b/src/core/SkImageGenerator.cpp @@ -77,8 +77,8 @@ bool SkImageGenerator::getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes return this->onGetYUV8Planes(sizeInfo, planes); } -GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subset) { - if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subset)) { +GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect& subset) { + if (!SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(subset)) { return nullptr; } return this->onGenerateTexture(ctx, subset); diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index b15fadd..bf6d53f 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -26,7 +26,7 @@ protected: bool onGenerateScaledPixels(const SkISize&, const SkIPoint&, const SkPixmap&) override; #if SK_SUPPORT_GPU - GrTexture* onGenerateTexture(GrContext*, const SkIRect*) override; + GrTexture* onGenerateTexture(GrContext*, const SkIRect&) override; #endif private: @@ -132,9 +132,9 @@ SkImageGenerator* SkImageGenerator::NewFromPicture(const SkISize& size, const Sk #if SK_SUPPORT_GPU #include "GrTexture.h" -GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIRect* subset) { +GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIRect& subset) { const SkImageInfo& info = this->getInfo(); - SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->height()) : info; + SkImageInfo surfaceInfo = info.makeWH(subset.width(), subset.height()); // // TODO: respect the usage, by possibly creating a different (pow2) surface @@ -145,9 +145,7 @@ GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIR } SkMatrix matrix = fMatrix; - if (subset) { - matrix.postTranslate(-subset->x(), -subset->y()); - } + matrix.postTranslate(-subset.x(), -subset.y()); surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this for us? surface->getCanvas()->drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull()); sk_sp image(surface->makeImageSnapshot()); -- 2.7.4