Remove params from Cacherator_GrTextureMaker

Review URL: https://codereview.chromium.org/1403313003
This commit is contained in:
bsalomon 2015-10-15 12:14:55 -07:00 committed by Commit bot
parent 41c054eeb0
commit 5f5527fb46
7 changed files with 21 additions and 28 deletions

View File

@ -220,8 +220,7 @@ public:
fTexture.reset(SkRef(image->getTexture()));
}
protected:
GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams& params,
const SkIRect* subset) override {
GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override {
if (ctx) {
SkASSERT(ctx == fCtx.get());
}

View File

@ -150,7 +150,7 @@ public:
* so the caller must inspect the texture's width/height and compare them to the generator's
* getInfo() width/height. For readback usage use GrTextureParams::ClampNoFilter()
*/
GrTexture* generateTexture(GrContext*, const GrTextureParams&, const SkIRect* subset = nullptr);
GrTexture* generateTexture(GrContext*, const SkIRect* subset = nullptr);
/**
* If the default image decoder system can interpret the specified (encoded) data, then
@ -195,7 +195,7 @@ protected:
virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
SkYUVColorSpace* colorSpace);
virtual GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, const SkIRect*) {
virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) {
return nullptr;
}

View File

@ -140,7 +140,7 @@ bool SkImageCacherator::lockAsBitmap(SkBitmap* bitmap, const SkImage* client) {
{
ScopedGenerator generator(this);
SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
tex.reset(generator->generateTexture(nullptr, GrTextureParams::ClampNoFilter(), &subset));
tex.reset(generator->generateTexture(nullptr, &subset));
}
if (!tex) {
bitmap->reset();
@ -217,8 +217,7 @@ static GrTexture* set_key_and_return(GrTexture* tex, const GrUniqueKey& key) {
* 4. Ask the generator to return YUV planes, which the GPU can convert
* 5. Ask the generator to return RGB(A) data, which the GPU can convert
*/
GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const GrTextureParams& params,
const SkImage* client) {
GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const SkImage* client) {
// textures (at least the texture-key) only support 16bit dimensions, so abort early
// if we're too big.
if (fInfo.width() > 0xFFFF || fInfo.height() > 0xFFFF) {
@ -226,8 +225,9 @@ GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const GrTex
}
GrUniqueKey key;
const GrTextureParams& noStretchParams = GrTextureParams::ClampNoFilter();
GrMakeKeyFromImageID(&key, fUniqueID, SkIRect::MakeWH(fInfo.width(), fInfo.height()),
*ctx->caps(), params);
*ctx->caps(), noStretchParams);
// 1. Check the cache for a pre-existing one
if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) {
@ -238,7 +238,7 @@ GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const GrTex
{
ScopedGenerator generator(this);
SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
if (GrTexture* tex = generator->generateTexture(ctx, params, &subset)) {
if (GrTexture* tex = generator->generateTexture(ctx, &subset)) {
return set_key_and_return(tex, key);
}
}
@ -267,7 +267,7 @@ GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const GrTex
// 5. Ask the generator to return RGB(A) data, which the GPU can convert
SkBitmap bitmap;
if (this->tryLockAsBitmap(&bitmap, client)) {
return GrRefCachedBitmapTexture(ctx, bitmap, params);
return GrRefCachedBitmapTexture(ctx, bitmap, noStretchParams);
}
return nullptr;
}
@ -278,11 +278,10 @@ GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const GrTex
class Cacherator_GrTextureMaker : public GrTextureMaker {
public:
Cacherator_GrTextureMaker(SkImageCacherator* cacher, const GrTextureParams& params,
const SkImage* client, const GrUniqueKey& unstretchedKey)
Cacherator_GrTextureMaker(SkImageCacherator* cacher, const SkImage* client,
const GrUniqueKey& unstretchedKey)
: INHERITED(cacher->info().width(), cacher->info().height())
, fCacher(cacher)
, fParams(params)
, fClient(client)
, fUnstretchedKey(unstretchedKey)
{}
@ -293,7 +292,7 @@ protected:
// GrTexture* onGenerateStretchedTexture(GrContext*, const SkGrStretch&) override;
GrTexture* onRefUnstretchedTexture(GrContext* ctx) override {
return fCacher->lockUnstretchedTexture(ctx, fParams, fClient);
return fCacher->lockUnstretchedTexture(ctx, fClient);
}
bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKey) override {
@ -312,7 +311,6 @@ protected:
private:
SkImageCacherator* fCacher;
const GrTextureParams& fParams;
const SkImage* fClient;
const GrUniqueKey fUnstretchedKey;
@ -328,9 +326,9 @@ GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
GrUniqueKey key;
GrMakeKeyFromImageID(&key, this->uniqueID(),
SkIRect::MakeWH(this->info().width(), this->info().height()),
*ctx->caps(), params);
*ctx->caps(), GrTextureParams::ClampNoFilter());
return Cacherator_GrTextureMaker(this, params, client, key).refCachedTexture(ctx, params);
return Cacherator_GrTextureMaker(this, client, key).refCachedTexture(ctx, params);
}
#else

View File

@ -60,7 +60,7 @@ private:
bool generateBitmap(SkBitmap*);
bool tryLockAsBitmap(SkBitmap*, const SkImage*);
#if SK_SUPPORT_GPU
GrTexture* lockUnstretchedTexture(GrContext*, const GrTextureParams&, const SkImage* client);
GrTexture* lockUnstretchedTexture(GrContext*, const SkImage* client);
#endif
class ScopedGenerator {

View File

@ -104,12 +104,11 @@ bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t
return this->onGetYUV8Planes(sizes, planes, rowBytes);
}
GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const GrTextureParams& params,
const SkIRect* subset) {
GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subset) {
if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subset)) {
return nullptr;
}
return this->onGenerateTexture(ctx, params, subset);
return this->onGenerateTexture(ctx, subset);
}
/////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -22,7 +22,7 @@ protected:
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[],
int* ctableCount) override;
#if SK_SUPPORT_GPU
GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, const SkIRect*) override;
GrTexture* onGenerateTexture(GrContext*, const SkIRect*) override;
#endif
private:
@ -88,8 +88,7 @@ SkImageGenerator* SkImageGenerator::NewFromPicture(const SkISize& size, const Sk
#if SK_SUPPORT_GPU
#include "GrTexture.h"
GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const GrTextureParams&,
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;

View File

@ -56,8 +56,7 @@ public:
{}
protected:
GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
const SkIRect* subset) override {
GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override {
if (ctx) {
SkASSERT(ctx == fCtx.get());
}
@ -113,8 +112,7 @@ protected:
return fImage->readPixels(info, pixels, rowBytes, 0, 0);
}
GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
const SkIRect* subset) override {
GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override {
// waiting on https://code.google.com/p/skia/issues/detail?id=4233
return nullptr;
}