Remove image usage type enum. Use GrTextureParams instead.
BUG=skia:
Review URL: https://codereview.chromium.org/1404433002
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 53ae990..7259009 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -220,7 +220,8 @@
fTexture.reset(SkRef(image->getTexture()));
}
protected:
- GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect* subset) override {
+ GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams& params,
+ const SkIRect* subset) override {
if (ctx) {
SkASSERT(ctx == fCtx.get());
}
@@ -310,7 +311,7 @@
static void draw_as_tex(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) {
#if SK_SUPPORT_GPU
SkAutoTUnref<GrTexture> texture(cache->lockAsTexture(canvas->getGrContext(),
- kUntiled_SkImageUsageType,
+ GrTextureParams::ClampBilerp(),
nullptr));
if (!texture) {
// show placeholder if we have no texture
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 9952690..cf772f5 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -86,7 +86,8 @@
return;
}
- SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp, nullptr));
+ SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp,
+ GrTextureParams::ClampNoFilter()));
if (!texture) {
return;
}
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 2fb3eec..25dca35 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -85,9 +85,12 @@
}
SkAutoTUnref<GrTexture> texture[3];
- texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], nullptr));
- texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1], nullptr));
- texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[2], nullptr));
+ texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0],
+ GrTextureParams::ClampBilerp()));
+ texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1],
+ GrTextureParams::ClampBilerp()));
+ texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[2],
+ GrTextureParams::ClampBilerp()));
if (!texture[0] || !texture[1] || !texture[2]) {
return;
diff --git a/gyp/core.gypi b/gyp/core.gypi
index e321e15..500065c 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -133,6 +133,7 @@
'<(skia_src_path)/core/SkHalf.h',
'<(skia_src_path)/core/SkImageFilter.cpp',
'<(skia_src_path)/core/SkImageInfo.cpp',
+ '<(skia_src_path)/core/SkImageCacherator.h',
'<(skia_src_path)/core/SkImageCacherator.cpp',
'<(skia_src_path)/core/SkImageGenerator.cpp',
'<(skia_src_path)/core/SkImageGeneratorPriv.h',
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index ddb663c..b86e5d4 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -36,6 +36,7 @@
'<(skia_include_path)/gpu/GrShaderVar.h',
'<(skia_include_path)/gpu/GrSurface.h',
'<(skia_include_path)/gpu/GrTexture.h',
+ '<(skia_include_path)/gpu/GrTextureParams.h',
'<(skia_include_path)/gpu/GrTextureProvider.h',
'<(skia_include_path)/gpu/GrTextureAccess.h',
'<(skia_include_path)/gpu/GrTestUtils.h',
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 0e2a45e..e04e05e 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -13,9 +13,10 @@
#include "SkImageInfo.h"
class GrContext;
+class GrTexture;
+class GrTextureParams;
class SkBitmap;
class SkData;
-class GrTexture;
class SkImageGenerator;
class SkMatrix;
class SkPaint;
@@ -142,14 +143,14 @@
* - its internal context is the same
* - it can somehow convert its texture into one that is valid for the provided context.
*
- * Regarding the SkImageUsageType parameter:
+ * Regarding the GrTextureParams parameter:
*
* If the context (the provided one or the generator's intrinsic one) determines that to
* support the specified usage, it must return a different sized texture it may,
* so the caller must inspect the texture's width/height and compare them to the generator's
- * getInfo() width/height.
+ * getInfo() width/height. For readback usage use GrTextureParams::ClampNoFilter()
*/
- GrTexture* generateTexture(GrContext*, SkImageUsageType, const SkIRect* subset = nullptr);
+ GrTexture* generateTexture(GrContext*, const GrTextureParams&, const SkIRect* subset = nullptr);
/**
* If the default image decoder system can interpret the specified (encoded) data, then
@@ -194,7 +195,7 @@
virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
SkYUVColorSpace* colorSpace);
- virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkIRect*) {
+ virtual GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, const SkIRect*) {
return nullptr;
}
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 0218a74..4b82ae6 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -16,23 +16,7 @@
class SkWriteBuffer;
/**
- * This enum provides information about "how" an image will be used. For older GPUs that do not
- * support non-power-of-2 tiling, some routines need to know this information before they create
- * a texture.
- */
-enum SkImageUsageType {
- /* Image will not be tiled (regardless of filtering) */
- kUntiled_SkImageUsageType,
-
- /* Image will be tiled, but not filtered */
- kTiled_Unfiltered_SkImageUsageType,
-
- /* Image will be tiled and filtered */
- kTiled_Filtered_SkImageUsageType,
-};
-
-/**
- * Describes how to interpret the alpha compoent of a pixel.
+ * Describes how to interpret the alpha component of a pixel.
*/
enum SkAlphaType {
kUnknown_SkAlphaType,
diff --git a/include/gpu/GrTextureAccess.h b/include/gpu/GrTextureAccess.h
index df0bdfd..e3ded34 100644
--- a/include/gpu/GrTextureAccess.h
+++ b/include/gpu/GrTextureAccess.h
@@ -10,101 +10,10 @@
#include "GrGpuResourceRef.h"
#include "GrTexture.h"
+#include "GrTextureParams.h"
#include "SkRefCnt.h"
#include "SkShader.h"
-/**
- * Represents the filtering and tile modes used to access a texture. It is mostly used with
- * GrTextureAccess (defined below). Also, some of the texture cache methods require knowledge about
- * filtering and tiling to perform a cache lookup. If it wasn't for this latter usage this would
- * be folded into GrTextureAccess. The default is clamp tile modes and no filtering.
- */
-class GrTextureParams {
-public:
- GrTextureParams() {
- this->reset();
- }
-
- enum FilterMode {
- kNone_FilterMode,
- kBilerp_FilterMode,
- kMipMap_FilterMode
- };
-
- GrTextureParams(SkShader::TileMode tileXAndY, FilterMode filterMode) {
- this->reset(tileXAndY, filterMode);
- }
-
- GrTextureParams(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
- this->reset(tileModes, filterMode);
- }
-
- GrTextureParams(const GrTextureParams& params) {
- *this = params;
- }
-
- GrTextureParams& operator= (const GrTextureParams& params) {
- fTileModes[0] = params.fTileModes[0];
- fTileModes[1] = params.fTileModes[1];
- fFilterMode = params.fFilterMode;
- return *this;
- }
-
- void reset() {
- this->reset(SkShader::kClamp_TileMode, kNone_FilterMode);
- }
-
- void reset(SkShader::TileMode tileXAndY, FilterMode filterMode) {
- fTileModes[0] = fTileModes[1] = tileXAndY;
- fFilterMode = filterMode;
- }
-
- void reset(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
- fTileModes[0] = tileModes[0];
- fTileModes[1] = tileModes[1];
- fFilterMode = filterMode;
- }
-
- void setClampNoFilter() {
- fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
- fFilterMode = kNone_FilterMode;
- }
-
- void setClamp() {
- fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
- }
-
- void setFilterMode(FilterMode filterMode) { fFilterMode = filterMode; }
-
- void setTileModeX(const SkShader::TileMode tm) { fTileModes[0] = tm; }
- void setTileModeY(const SkShader::TileMode tm) { fTileModes[1] = tm; }
- void setTileModeXAndY(const SkShader::TileMode tm) { fTileModes[0] = fTileModes[1] = tm; }
-
- SkShader::TileMode getTileModeX() const { return fTileModes[0]; }
-
- SkShader::TileMode getTileModeY() const { return fTileModes[1]; }
-
- bool isTiled() const {
- return SkShader::kClamp_TileMode != fTileModes[0] ||
- SkShader::kClamp_TileMode != fTileModes[1];
- }
-
- FilterMode filterMode() const { return fFilterMode; }
-
- bool operator== (const GrTextureParams& other) const {
- return fTileModes[0] == other.fTileModes[0] &&
- fTileModes[1] == other.fTileModes[1] &&
- fFilterMode == other.fFilterMode;
- }
-
- bool operator!= (const GrTextureParams& other) const { return !(*this == other); }
-
-private:
-
- SkShader::TileMode fTileModes[2];
- FilterMode fFilterMode;
-};
-
/** A class representing the swizzle access pattern for a texture. Note that if the texture is
* an alpha-only texture then the alpha channel is substituted for other components. Any mangling
* to handle the r,g,b->a conversions for alpha textures is automatically included in the stage
diff --git a/include/gpu/GrTextureParams.h b/include/gpu/GrTextureParams.h
new file mode 100644
index 0000000..3186b1b
--- /dev/null
+++ b/include/gpu/GrTextureParams.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrTextureParams_DEFINED
+#define GrTextureParams_DEFINED
+
+#include "GrTypes.h"
+#include "SkShader.h"
+
+/**
+ * Represents the filtering and tile modes used to access a texture.
+ */
+class GrTextureParams {
+public:
+ static const GrTextureParams& ClampNoFilter() {
+ static const GrTextureParams gParams;
+ return gParams;
+ }
+ static const GrTextureParams& ClampBilerp() {
+ static const GrTextureParams gParams(SkShader::kClamp_TileMode, kBilerp_FilterMode);
+ return gParams;
+ }
+
+ GrTextureParams() {
+ this->reset();
+ }
+
+ enum FilterMode {
+ kNone_FilterMode,
+ kBilerp_FilterMode,
+ kMipMap_FilterMode
+ };
+
+ GrTextureParams(SkShader::TileMode tileXAndY, FilterMode filterMode) {
+ this->reset(tileXAndY, filterMode);
+ }
+
+ GrTextureParams(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
+ this->reset(tileModes, filterMode);
+ }
+
+ GrTextureParams(const GrTextureParams& params) {
+ *this = params;
+ }
+
+ GrTextureParams& operator= (const GrTextureParams& params) {
+ fTileModes[0] = params.fTileModes[0];
+ fTileModes[1] = params.fTileModes[1];
+ fFilterMode = params.fFilterMode;
+ return *this;
+ }
+
+ void reset() {
+ this->reset(SkShader::kClamp_TileMode, kNone_FilterMode);
+ }
+
+ void reset(SkShader::TileMode tileXAndY, FilterMode filterMode) {
+ fTileModes[0] = fTileModes[1] = tileXAndY;
+ fFilterMode = filterMode;
+ }
+
+ void reset(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
+ fTileModes[0] = tileModes[0];
+ fTileModes[1] = tileModes[1];
+ fFilterMode = filterMode;
+ }
+
+ void setClampNoFilter() {
+ fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
+ fFilterMode = kNone_FilterMode;
+ }
+
+ void setClamp() {
+ fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
+ }
+
+ void setFilterMode(FilterMode filterMode) { fFilterMode = filterMode; }
+
+ void setTileModeX(const SkShader::TileMode tm) { fTileModes[0] = tm; }
+ void setTileModeY(const SkShader::TileMode tm) { fTileModes[1] = tm; }
+ void setTileModeXAndY(const SkShader::TileMode tm) { fTileModes[0] = fTileModes[1] = tm; }
+
+ SkShader::TileMode getTileModeX() const { return fTileModes[0]; }
+
+ SkShader::TileMode getTileModeY() const { return fTileModes[1]; }
+
+ bool isTiled() const {
+ return SkShader::kClamp_TileMode != fTileModes[0] ||
+ SkShader::kClamp_TileMode != fTileModes[1];
+ }
+
+ FilterMode filterMode() const { return fFilterMode; }
+
+ bool operator== (const GrTextureParams& other) const {
+ return fTileModes[0] == other.fTileModes[0] &&
+ fTileModes[1] == other.fTileModes[1] &&
+ fFilterMode == other.fFilterMode;
+ }
+
+ bool operator!= (const GrTextureParams& other) const { return !(*this == other); }
+
+private:
+ SkShader::TileMode fTileModes[2];
+ FilterMode fFilterMode;
+};
+#endif
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index 8ea3af1..591d3d8 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -66,9 +66,8 @@
////////////////////////////////////////////////////////////////////////////////
-GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams*);
-GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, SkImageUsageType);
-
+GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams&);
+
// TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses).
GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType);
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 3dd528d..70f692a 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -392,7 +392,7 @@
GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(),
&doBicubic);
GrTextureParams params(tm, textureFilterMode);
- SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, ¶ms));
+ SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, params));
if (!texture) {
SkErrorInternals::SetError( kInternalError_SkError,
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index 03e358a..5c0d054 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -18,7 +18,7 @@
#include "GrContext.h"
#include "GrGpuResourcePriv.h"
#include "GrResourceKey.h"
-#include "GrTextureAccess.h"
+#include "GrTextureParams.h"
#include "GrYUVProvider.h"
#include "SkGr.h"
#include "SkGrPriv.h"
@@ -140,7 +140,7 @@
{
ScopedGenerator generator(this);
SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
- tex.reset(generator->generateTexture(nullptr, kUntiled_SkImageUsageType, &subset));
+ tex.reset(generator->generateTexture(nullptr, GrTextureParams::ClampNoFilter(), &subset));
}
if (!tex) {
bitmap->reset();
@@ -212,12 +212,12 @@
* We have a 5 ways to try to return a texture (in sorted order)
*
* 1. Check the cache for a pre-existing one
- * 2. Ask the genreator to natively create one
+ * 2. Ask the generator to natively create one
* 3. Ask the generator to return a compressed form that the GPU might support
* 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, SkImageUsageType usage,
+GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const GrTextureParams& params,
const SkImage* client) {
// textures (at least the texture-key) only support 16bit dimensions, so abort early
// if we're too big.
@@ -227,7 +227,7 @@
GrUniqueKey key;
GrMakeKeyFromImageID(&key, fUniqueID, SkIRect::MakeWH(fInfo.width(), fInfo.height()),
- *ctx->caps(), usage);
+ *ctx->caps(), params);
// 1. Check the cache for a pre-existing one
if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) {
@@ -238,7 +238,7 @@
{
ScopedGenerator generator(this);
SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
- if (GrTexture* tex = generator->generateTexture(ctx, usage, &subset)) {
+ if (GrTexture* tex = generator->generateTexture(ctx, params, &subset)) {
return set_key_and_return(tex, key);
}
}
@@ -267,7 +267,7 @@
// 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, usage);
+ return GrRefCachedBitmapTexture(ctx, bitmap, params);
}
return nullptr;
}
@@ -278,11 +278,11 @@
class Cacherator_GrTextureMaker : public GrTextureMaker {
public:
- Cacherator_GrTextureMaker(SkImageCacherator* cacher, SkImageUsageType usage,
+ Cacherator_GrTextureMaker(SkImageCacherator* cacher, const GrTextureParams& params,
const SkImage* client, const GrUniqueKey& unstretchedKey)
: INHERITED(cacher->info().width(), cacher->info().height())
, fCacher(cacher)
- , fUsage(usage)
+ , fParams(params)
, fClient(client)
, fUnstretchedKey(unstretchedKey)
{}
@@ -293,7 +293,7 @@
// GrTexture* onGenerateStretchedTexture(GrContext*, const SkGrStretch&) override;
GrTexture* onRefUnstretchedTexture(GrContext* ctx) override {
- return fCacher->lockUnstretchedTexture(ctx, fUsage, fClient);
+ return fCacher->lockUnstretchedTexture(ctx, fParams, fClient);
}
bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKey) override {
@@ -312,14 +312,14 @@
private:
SkImageCacherator* fCacher;
- const SkImageUsageType fUsage;
+ const GrTextureParams& fParams;
const SkImage* fClient;
const GrUniqueKey fUnstretchedKey;
typedef GrTextureMaker INHERITED;
};
-GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParams& params,
const SkImage* client) {
if (!ctx) {
return nullptr;
@@ -328,14 +328,14 @@
GrUniqueKey key;
GrMakeKeyFromImageID(&key, this->uniqueID(),
SkIRect::MakeWH(this->info().width(), this->info().height()),
- *ctx->caps(), usage);
+ *ctx->caps(), params);
- return Cacherator_GrTextureMaker(this, usage, client, key).refCachedTexture(ctx, usage);
+ return Cacherator_GrTextureMaker(this, params, client, key).refCachedTexture(ctx, params);
}
#else
-GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParams&,
const SkImage* client) {
return nullptr;
}
diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h
index c5c6549..1d00117 100644
--- a/src/core/SkImageCacherator.h
+++ b/src/core/SkImageCacherator.h
@@ -13,6 +13,7 @@
#include "SkTemplates.h"
class GrContext;
+class GrTextureParams;
class SkBitmap;
class SkImage;
@@ -45,7 +46,7 @@
*
* The caller is responsible for calling texture->unref() when they are done.
*/
- GrTexture* lockAsTexture(GrContext*, SkImageUsageType, const SkImage* client);
+ GrTexture* lockAsTexture(GrContext*, const GrTextureParams&, const SkImage* client);
/**
* If the underlying src naturally is represented by an encoded blob (in SkData), this returns
@@ -59,7 +60,7 @@
bool generateBitmap(SkBitmap*);
bool tryLockAsBitmap(SkBitmap*, const SkImage*);
#if SK_SUPPORT_GPU
- GrTexture* lockUnstretchedTexture(GrContext*, SkImageUsageType, const SkImage* client);
+ GrTexture* lockUnstretchedTexture(GrContext*, const GrTextureParams&, const SkImage* client);
#endif
class ScopedGenerator {
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 2920714..4ad7f0e 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -464,7 +464,8 @@
if (kUnknown_SkColorType == info.colorType()) {
return false;
}
- SkAutoTUnref<GrTexture> resultTex(GrRefCachedBitmapTexture(context, *result, nullptr));
+ SkAutoTUnref<GrTexture> resultTex(
+ GrRefCachedBitmapTexture(context, *result,GrTextureParams::ClampNoFilter()));
result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
}
return true;
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index 187b460..98a4014 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -104,12 +104,12 @@
return this->onGetYUV8Planes(sizes, planes, rowBytes);
}
-GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const GrTextureParams& params,
const SkIRect* subset) {
if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subset)) {
return nullptr;
}
- return this->onGenerateTexture(ctx, usage, subset);
+ return this->onGenerateTexture(ctx, params, subset);
}
/////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 6121f215..16441aa 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -382,7 +382,7 @@
// TODO: support other tile modes
GrTextureParams diffParams(kClamp_TileMode, diffFilterMode);
SkAutoTUnref<GrTexture> diffuseTexture(GrRefCachedBitmapTexture(context,
- fDiffuseMap, &diffParams));
+ fDiffuseMap, diffParams));
if (!diffuseTexture) {
SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
return nullptr;
@@ -390,7 +390,7 @@
GrTextureParams normParams(kClamp_TileMode, normFilterMode);
SkAutoTUnref<GrTexture> normalTexture(GrRefCachedBitmapTexture(context,
- fNormalMap, &normParams));
+ fNormalMap, normParams));
if (!normalTexture) {
SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
return nullptr;
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index 13d3cc8..a27291f 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -22,7 +22,7 @@
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[],
int* ctableCount) override;
#if SK_SUPPORT_GPU
- GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkIRect*) override;
+ GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, const SkIRect*) override;
#endif
private:
@@ -88,7 +88,7 @@
#if SK_SUPPORT_GPU
#include "GrTexture.h"
-GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const GrTextureParams&,
const SkIRect* subset) {
const SkImageInfo& info = this->getInfo();
SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->height()) : info;
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 86463f6..481d160 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -943,9 +943,11 @@
SkPerlinNoiseShader::PaintingData* paintingData =
new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
SkAutoTUnref<GrTexture> permutationsTexture(
- GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), nullptr));
+ GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(),
+ GrTextureParams::ClampNoFilter()));
SkAutoTUnref<GrTexture> noiseTexture(
- GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(), nullptr));
+ GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(),
+ GrTextureParams::ClampNoFilter()));
SkMatrix m = viewM;
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index f0ed7b4..8f1a4d7 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -475,8 +475,7 @@
SkAutoTUnref<GrTexture> texture;
if (-1 == row) {
atlas = nullptr;
- // Passing params=nullptr because this effect does no tiling or filtering.
- texture.reset(GrRefCachedBitmapTexture(context, bitmap, nullptr));
+ texture.reset(GrRefCachedBitmapTexture(context, bitmap, GrTextureParams::ClampNoFilter()));
} else {
texture.reset(SkRef(atlas->getTexture()));
}
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 88d650c..a96e09d 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1132,7 +1132,7 @@
fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture(), params.filterMode());
fTextureAccess.reset(fAtlas->getTexture(), params);
} else {
- SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap, ¶ms));
+ SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap, params));
if (!texture) {
return;
}
diff --git a/src/gpu/GrTextureMaker.h b/src/gpu/GrTextureMaker.h
index 1cbf63a..47141bd 100644
--- a/src/gpu/GrTextureMaker.h
+++ b/src/gpu/GrTextureMaker.h
@@ -24,8 +24,7 @@
int width() const { return fWidth; }
int height() const { return fHeight; }
- GrTexture* refCachedTexture(GrContext*, SkImageUsageType);
- GrTexture* refCachedTexture(GrContext*, const GrTextureParams*);
+ GrTexture* refCachedTexture(GrContext*, const GrTextureParams&);
protected:
/**
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9d129d5..4d15059 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -90,7 +90,7 @@
AutoBitmapTexture(GrContext* context,
const SkBitmap& bitmap,
- const GrTextureParams* params,
+ const GrTextureParams& params,
GrTexture** texture) {
SkASSERT(texture);
*texture = this->set(context, bitmap, params);
@@ -98,7 +98,7 @@
GrTexture* set(GrContext* context,
const SkBitmap& bitmap,
- const GrTextureParams* params) {
+ const GrTextureParams& params) {
// Either get the texture directly from the bitmap, or else use the cache and
// remember to unref it.
if (GrTexture* bmpTexture = bitmap.getTexture()) {
@@ -765,7 +765,7 @@
}
// if the entire image/bitmap is already in our cache then no reason to tile it
- if (GrIsImageInCache(fContext, imageID, imageRect, nullptr, ¶ms)) {
+ if (GrIsImageInCache(fContext, imageID, imageRect, nullptr, params)) {
return false;
}
@@ -983,7 +983,7 @@
// Setup texture to wrap bitmap
GrTextureParams params(tm, textureFilterMode);
- SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, *bitmapPtr, ¶ms));
+ SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, *bitmapPtr, params));
if (!texture) {
SkErrorInternals::SetError(kInternalError_SkError,
@@ -1288,7 +1288,7 @@
bitmap.height() <= fContext->caps()->maxTextureSize());
GrTexture* texture;
- AutoBitmapTexture abt(fContext, bitmap, ¶ms, &texture);
+ AutoBitmapTexture abt(fContext, bitmap, params, &texture);
if (nullptr == texture) {
return;
}
@@ -1419,8 +1419,8 @@
int h = bitmap.height();
GrTexture* texture;
- // draw sprite uses the default texture params
- AutoBitmapTexture abt(fContext, bitmap, nullptr, &texture);
+ // draw sprite neither filters nor tiles.
+ AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &texture);
if (!texture) {
return;
}
@@ -1621,7 +1621,7 @@
GrTexture* texture;
// We assume here that the filter will not attempt to tile the src. Otherwise, this cache lookup
// must be pushed upstack.
- AutoBitmapTexture abt(fContext, src, nullptr, &texture);
+ AutoBitmapTexture abt(fContext, src, GrTextureParams::ClampNoFilter(), &texture);
if (!texture) {
return false;
}
@@ -1631,7 +1631,8 @@
}
static bool wrap_as_bm(GrContext* ctx, const SkImage* image, SkBitmap* bm) {
- SkAutoTUnref<GrTexture> tex(as_IB(image)->asTextureRef(ctx, kUntiled_SkImageUsageType));
+ // TODO: It is wrong to assume these texture params here.
+ SkAutoTUnref<GrTexture> tex(as_IB(image)->asTextureRef(ctx, GrTextureParams::ClampNoFilter()));
if (tex) {
GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpaque(), bm);
return true;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 8f9555a..ce4af0b 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -38,33 +38,6 @@
# include "etc1.h"
#endif
-bool GrTextureUsageSupported(const GrCaps& caps, int width, int height, SkImageUsageType usage) {
- if (caps.npotTextureTileSupport()) {
- return true;
- }
- const bool is_pow2 = SkIsPow2(width) && SkIsPow2(height);
- return is_pow2 || kUntiled_SkImageUsageType == usage;
-}
-
-GrTextureParams GrImageUsageToTextureParams(SkImageUsageType usage) {
- // Just need a params that will trigger the correct cache key / etc, since the usage doesn't
- // tell us the specifics about filter level or specific tiling.
-
- const SkShader::TileMode tiles[] = {
- SkShader::kClamp_TileMode, // kUntiled_SkImageUsageType
- SkShader::kRepeat_TileMode, // kTiled_Unfiltered_SkImageUsageType
- SkShader::kRepeat_TileMode, // kTiled_Filtered_SkImageUsageType
- };
-
- const GrTextureParams::FilterMode filters[] = {
- GrTextureParams::kNone_FilterMode, // kUntiled_SkImageUsageType
- GrTextureParams::kNone_FilterMode, // kTiled_Unfiltered_SkImageUsageType
- GrTextureParams::kBilerp_FilterMode, // kTiled_Filtered_SkImageUsageType
- };
-
- return GrTextureParams(tiles[usage], filters[usage]);
-}
-
/* Fill out buffer with the compressed format Ganesh expects from a colortable
based bitmap. [palette (colortable) + indices].
@@ -124,35 +97,31 @@
////////////////////////////////////////////////////////////////////////////////
-static void get_stretch(const GrContext* ctx, int width, int height,
- const GrTextureParams* params, SkGrStretch* stretch) {
+static void get_stretch(const GrCaps& caps, int width, int height,
+ const GrTextureParams& params, SkGrStretch* stretch) {
stretch->fType = SkGrStretch::kNone_Type;
bool doStretch = false;
- if (params && params->isTiled() && !ctx->caps()->npotTextureTileSupport() &&
+ if (params.isTiled() && !caps.npotTextureTileSupport() &&
(!SkIsPow2(width) || !SkIsPow2(height))) {
doStretch = true;
- stretch->fWidth = GrNextPow2(SkTMax(width, ctx->caps()->minTextureSize()));
- stretch->fHeight = GrNextPow2(SkTMax(height, ctx->caps()->minTextureSize()));
- } else if (width < ctx->caps()->minTextureSize() || height < ctx->caps()->minTextureSize()) {
+ stretch->fWidth = GrNextPow2(SkTMax(width, caps.minTextureSize()));
+ stretch->fHeight = GrNextPow2(SkTMax(height, caps.minTextureSize()));
+ } else if (width < caps.minTextureSize() || height < caps.minTextureSize()) {
// The small texture issues appear to be with tiling. Hence it seems ok to scale them
// up using the GPU. If issues persist we may need to CPU-stretch.
doStretch = true;
- stretch->fWidth = SkTMax(width, ctx->caps()->minTextureSize());
- stretch->fHeight = SkTMax(height, ctx->caps()->minTextureSize());
+ stretch->fWidth = SkTMax(width, caps.minTextureSize());
+ stretch->fHeight = SkTMax(height, caps.minTextureSize());
}
if (doStretch) {
- if (params) {
- switch(params->filterMode()) {
- case GrTextureParams::kNone_FilterMode:
- stretch->fType = SkGrStretch::kNearest_Type;
- break;
- case GrTextureParams::kBilerp_FilterMode:
- case GrTextureParams::kMipMap_FilterMode:
- stretch->fType = SkGrStretch::kBilerp_Type;
- break;
- }
- } else {
- stretch->fType = SkGrStretch::kBilerp_Type;
+ switch(params.filterMode()) {
+ case GrTextureParams::kNone_FilterMode:
+ stretch->fType = SkGrStretch::kNearest_Type;
+ break;
+ case GrTextureParams::kBilerp_FilterMode:
+ case GrTextureParams::kMipMap_FilterMode:
+ stretch->fType = SkGrStretch::kBilerp_Type;
+ break;
}
} else {
stretch->fWidth = -1;
@@ -190,26 +159,16 @@
}
void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& subset,
- const GrCaps& caps, SkImageUsageType usage) {
- const SkGrStretch::Type stretches[] = {
- SkGrStretch::kNone_Type, // kUntiled_SkImageUsageType
- SkGrStretch::kNearest_Type, // kTiled_Unfiltered_SkImageUsageType
- SkGrStretch::kBilerp_Type, // kTiled_Filtered_SkImageUsageType
- };
-
- if (!GrTextureUsageSupported(caps, subset.width(), subset.height(), usage)) {
+ const GrCaps& caps, const GrTextureParams& params) {
+ SkGrStretch stretch;
+ get_stretch(caps, subset.width(), subset.height(), params, &stretch);
+ if (SkGrStretch::kNone_Type != stretch.fType) {
GrUniqueKey tmpKey;
make_unstretched_key(&tmpKey, imageID, subset);
-
- SkGrStretch stretch;
- stretch.fType = stretches[usage];
- stretch.fWidth = SkNextPow2(subset.width());
- stretch.fHeight = SkNextPow2(subset.height());
if (!GrMakeStretchedKey(tmpKey, stretch, key)) {
- goto UNSTRETCHED;
+ *key = tmpKey;
}
} else {
- UNSTRETCHED:
make_unstretched_key(key, imageID, subset);
}
}
@@ -519,9 +478,9 @@
}
bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
- GrTexture* nativeTexture, const GrTextureParams* params) {
+ GrTexture* nativeTexture, const GrTextureParams& params) {
SkGrStretch stretch;
- get_stretch(ctx, subset.width(), subset.height(), params, &stretch);
+ get_stretch(*ctx->caps(), subset.width(), subset.height(), params, &stretch);
// Handle the case where the bitmap/image is explicitly texture backed.
if (nativeTexture) {
@@ -593,19 +552,10 @@
};
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
- const GrTextureParams* params) {
+ const GrTextureParams& params) {
return Bitmap_GrTextureMaker(bitmap).refCachedTexture(ctx, params);
}
-// TODO: make this be the canonical signature, and turn the version that takes GrTextureParams*
-// into a wrapper that contains the inverse of these tables.
-GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
- const SkBitmap& bitmap,
- SkImageUsageType usage) {
- GrTextureParams params = GrImageUsageToTextureParams(usage);
- return GrRefCachedBitmapTexture(ctx, bitmap, ¶ms);
-}
-
///////////////////////////////////////////////////////////////////////////////
// alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
@@ -928,14 +878,9 @@
////////////////////////////////////////////////////////////////////////////////////////////////
-GrTexture* GrTextureMaker::refCachedTexture(GrContext* ctx, SkImageUsageType usage) {
- GrTextureParams params = GrImageUsageToTextureParams(usage);
- return this->refCachedTexture(ctx, ¶ms);
-}
-
-GrTexture* GrTextureMaker::refCachedTexture(GrContext* ctx, const GrTextureParams* params) {
+GrTexture* GrTextureMaker::refCachedTexture(GrContext* ctx, const GrTextureParams& params) {
SkGrStretch stretch;
- get_stretch(ctx, this->width(), this->height(), params, &stretch);
+ get_stretch(*ctx->caps(), this->width(), this->height(), params, &stretch);
if (SkGrStretch::kNone_Type == stretch.fType) {
return this->onRefUnstretchedTexture(ctx);
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index 88bee5c..6c9f731 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -10,8 +10,8 @@
#include "GrTypes.h"
#include "GrBlend.h"
-#include "GrTextureAccess.h"
#include "SkImageInfo.h"
+#include "SkMatrix.h"
#include "SkXfermode.h"
class GrCaps;
@@ -19,9 +19,11 @@
class GrFragmentProcessor;
class GrPaint;
class GrTexture;
+class GrTextureParams;
class GrUniqueKey;
+class SkData;
class SkPaint;
-class SkMatrix;
+class SkPixelRef;
struct SkIRect;
struct SkGrStretch {
@@ -34,8 +36,6 @@
int fHeight;
};
-GrTextureParams GrImageUsageToTextureParams(SkImageUsageType);
-
/**
* Our key includes the offset, width, and height so that bitmaps created by extractSubset()
* are unique.
@@ -48,7 +48,7 @@
* Note: width/height must fit in 16bits for this impl.
*/
void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& imageBounds,
- const GrCaps&, SkImageUsageType);
+ const GrCaps&, const GrTextureParams&);
/**
* Given an "unstretched" key, and a stretch rec, produce a stretched key.
@@ -98,8 +98,6 @@
//////////////////////////////////////////////////////////////////////////////
-bool GrTextureUsageSupported(const GrCaps&, int width, int height, SkImageUsageType);
-
GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*);
@@ -117,7 +115,7 @@
const void** outStartOfDataToUpload);
bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
- GrTexture* nativeTexture, const GrTextureParams*);
+ GrTexture* nativeTexture, const GrTextureParams&);
GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey, GrSurfaceDesc,
SkPixelRef* pixelRefForInvalidationNotificationOrNull,
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index cf613e8..56af179 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -113,17 +113,7 @@
GrTextureParams::FilterMode textureFilterMode =
GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(), &doBicubic);
GrTextureParams params(tm, textureFilterMode);
-
- SkImageUsageType usageType;
- if (kClamp_TileMode == fTileModeX && kClamp_TileMode == fTileModeY) {
- usageType = kUntiled_SkImageUsageType;
- } else if (GrTextureParams::kNone_FilterMode == textureFilterMode) {
- usageType = kTiled_Unfiltered_SkImageUsageType;
- } else {
- usageType = kTiled_Filtered_SkImageUsageType;
- }
-
- SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, usageType));
+ SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params));
if (!texture) {
return nullptr;
}
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 20df0bc..7819e9c 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -14,6 +14,8 @@
#include <new>
+class GrTextureParams;
+
enum {
kNeedNewImageUniqueID = 0
};
@@ -36,7 +38,7 @@
virtual bool getROPixels(SkBitmap*) const = 0;
// Caller must call unref when they are done.
- virtual GrTexture* asTextureRef(GrContext*, SkImageUsageType) const = 0;
+ virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const = 0;
virtual SkImage* onNewSubset(const SkIRect&) const = 0;
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index 5ce552c..3465289 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -27,7 +27,7 @@
bool isOpaque() const override { return fCache->info().isOpaque(); }
SkImage* onNewSubset(const SkIRect&) const override;
bool getROPixels(SkBitmap*) const override;
- GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override;
+ GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
bool onIsLazyGenerated() const override { return true; }
private:
@@ -59,8 +59,8 @@
return fCache->lockAsBitmap(bitmap, this);
}
-GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, SkImageUsageType usage) const {
- return fCache->lockAsTexture(ctx, usage, this);
+GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
+ return fCache->lockAsTexture(ctx, params, this);
}
SkImage* SkImage_Generator::onNewSubset(const SkIRect& subset) const {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 72b98cd..ccb27ee 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -109,8 +109,8 @@
typedef GrTextureMaker INHERITED;
};
-GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, SkImageUsageType usage) const {
- return Texture_GrTextureMaker(this, fTexture).refCachedTexture(ctx, usage);
+GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
+ return Texture_GrTextureMaker(this, fTexture).refCachedTexture(ctx, params);
}
bool SkImage_Gpu::isOpaque() const {
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 8bfdfa7..530c044 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -36,7 +36,7 @@
}
bool getROPixels(SkBitmap*) const override;
- GrTexture* asTextureRef(GrContext* ctx, SkImageUsageType usage) const override;
+ GrTexture* asTextureRef(GrContext* ctx, const GrTextureParams& params) const override;
SkImage* onNewSubset(const SkIRect&) const override;
GrTexture* peekTexture() const override { return fTexture; }
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index b6c62e8..b78818d 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -70,7 +70,7 @@
const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
SkData* onRefEncoded() const override;
bool getROPixels(SkBitmap*) const override;
- GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override;
+ GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
SkImage* onNewSubset(const SkIRect&) const override;
// exposed for SkSurface_Raster via SkNewImageFromPixelRef
@@ -167,7 +167,7 @@
return true;
}
-GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, SkImageUsageType usage) const {
+GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
#if SK_SUPPORT_GPU
if (!ctx) {
return nullptr;
@@ -182,12 +182,12 @@
GrUniqueKey key;
GrMakeKeyFromImageID(&key, fBitmap.getGenerationID(),
SkIRect::MakeWH(fBitmap.width(), fBitmap.height()),
- *ctx->caps(), usage);
+ *ctx->caps(), params);
if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) {
return tex;
}
- return GrRefCachedBitmapTexture(ctx, fBitmap, usage);
+ return GrRefCachedBitmapTexture(ctx, fBitmap, params);
#endif
return nullptr;
diff --git a/src/utils/SkImageGeneratorUtils.cpp b/src/utils/SkImageGeneratorUtils.cpp
index 42a0fe5..8202dbe 100644
--- a/src/utils/SkImageGeneratorUtils.cpp
+++ b/src/utils/SkImageGeneratorUtils.cpp
@@ -56,7 +56,8 @@
{}
protected:
- GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect* subset) override {
+ GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
+ const SkIRect* subset) override {
if (ctx) {
SkASSERT(ctx == fCtx.get());
}
@@ -112,7 +113,8 @@
return fImage->readPixels(info, pixels, rowBytes, 0, 0);
}
- GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect* subset) override {
+ GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
+ const SkIRect* subset) override {
// waiting on https://code.google.com/p/skia/issues/detail?id=4233
return nullptr;
}
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index b5f8417..969617d 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -576,7 +576,7 @@
// ... one from a texture-subset
SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctx, bitmap,
- kUntiled_SkImageUsageType));
+ GrTextureParams::ClampNoFilter()));
SkBitmap tx_full;
GrWrapTextureInBitmap(fullTx, bitmap.width(), bitmap.height(), true, &tx_full);
tx_full.extractSubset(&tx_subset, subset);
@@ -585,7 +585,7 @@
SkBitmap tmp_subset;
bitmap.extractSubset(&tmp_subset, subset);
SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(ctx, tmp_subset,
- kUntiled_SkImageUsageType));
+ GrTextureParams::ClampNoFilter()));
GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), true, &bm_subset);
// did we get the same subset?