aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/bleed.cpp8
-rw-r--r--include/gpu/GrCaps.h4
-rw-r--r--include/gpu/GrContextOptions.h4
-rw-r--r--src/gpu/GrCaps.cpp6
-rw-r--r--src/gpu/SkGpuDevice.cpp14
5 files changed, 24 insertions, 12 deletions
diff --git a/gm/bleed.cpp b/gm/bleed.cpp
index 5daa54e9ff..26dca803ef 100644
--- a/gm/bleed.cpp
+++ b/gm/bleed.cpp
@@ -215,7 +215,7 @@ protected:
// To exercise the GPU's tiling path we need a texture
// too big for the GPU to handle in one go
- gBleedRec[fBT].fBmpMaker(&fBitmapBig, 2*kMaxTextureSize, 2*kMaxTextureSize);
+ gBleedRec[fBT].fBmpMaker(&fBitmapBig, 2*kMaxTileSize, 2*kMaxTileSize);
fImageBig.reset(SkImage::NewFromBitmap(fBitmapBig));
fShader.reset(gBleedRec[fBT].fShaderMaker());
@@ -378,7 +378,7 @@ protected:
#if SK_SUPPORT_GPU
void modifyGrContextOptions(GrContextOptions* options) override {
- options->fMaxTextureSizeOverride = kMaxTextureSize;
+ options->fMaxTileSizeOverride = kMaxTileSize;
}
#endif
@@ -400,7 +400,7 @@ private:
static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize;
static const int kSmallTextureSize = 6;
- static const int kMaxTextureSize = 32;
+ static const int kMaxTileSize = 32;
SkBitmap fBitmapSmall;
SkBitmap fBitmapBig;
@@ -418,7 +418,5 @@ DEF_GM( return new BleedGM(kUseBitmap_BleedTest); )
DEF_GM( return new BleedGM(kUseImage_BleedTest); )
DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); )
DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); )
-#if 0 // Currently crashes GPU backend
DEF_GM(return new BleedGM(kUseAlphaBitmapShader_BleedTest); )
DEF_GM(return new BleedGM(kUseAlphaImageShader_BleedTest); )
-#endif
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index 811a74ff48..6893dc7b5e 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -189,6 +189,9 @@ public:
int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
int maxTextureSize() const { return fMaxTextureSize; }
+ /** This is the maximum tile size to use by GPU devices for rendering sw-backed images/bitmaps.
+ It is usually the max texture size, unless we're overriding it for testing. */
+ int maxTileSize() const { SkASSERT(fMaxTileSize <= fMaxTextureSize); return fMaxTileSize; }
// Will be 0 if MSAA is not supported
int maxSampleCount() const { return fMaxSampleCount; }
@@ -263,6 +266,7 @@ protected:
int fMaxRenderTargetSize;
int fMaxTextureSize;
+ int fMaxTileSize;
int fMaxSampleCount;
// The first entry for each config is without msaa and the second is with.
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index 4b70105559..5619e3063b 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -15,6 +15,7 @@ struct GrContextOptions {
: fDrawPathToCompressedTexture(false)
, fSuppressPrints(false)
, fMaxTextureSizeOverride(SK_MaxS32)
+ , fMaxTileSizeOverride(0)
, fSuppressDualSourceBlending(false)
, fGeometryBufferMapThreshold(-1)
, fUseDrawInsteadOfPartialRenderTargetWrite(false)
@@ -33,6 +34,9 @@ struct GrContextOptions {
detected values. */
int fMaxTextureSizeOverride;
+ /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
+ by SkGpuDevice. */
+ int fMaxTileSizeOverride;
bool fSuppressDualSourceBlending;
/** the threshold in bytes above which we will use a buffer mapping API to map vertex and index
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 4095f1ab10..75cecdfb8c 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -121,6 +121,12 @@ GrCaps::GrCaps(const GrContextOptions& options) {
void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride);
+ // If the max tile override is zero, it means we should use the max texture size.
+ if (!options.fMaxTileSizeOverride || options.fMaxTileSizeOverride > fMaxTextureSize) {
+ fMaxTileSize = fMaxTextureSize;
+ } else {
+ fMaxTileSize = options.fMaxTileSizeOverride;
+ }
}
static SkString map_flags_to_string(uint32_t flags) {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index cdbda58e62..725c26b248 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -827,7 +827,7 @@ bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr
}
params.setFilterMode(textureFilterMode);
- int maxTileSize = fContext->caps()->maxTextureSize() - 2 * tileFilterPad;
+ int maxTileSize = fContext->caps()->maxTileSize() - 2 * tileFilterPad;
// these are output, which we safely ignore, as we just want to know the predicate
int outTileSize;
@@ -1071,11 +1071,11 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
// FIXME: the tiled bitmap code path doesn't currently support
// anti-aliased edges, we work around that for now by drawing directly
// if the image size exceeds maximum texture size.
- int maxTextureSize = fContext->caps()->maxTextureSize();
+ int maxTileSize = fContext->caps()->maxTileSize();
bool drawAA = !fRenderTarget->isUnifiedMultisampled() &&
paint.isAntiAlias() &&
- bitmap.width() <= maxTextureSize &&
- bitmap.height() <= maxTextureSize;
+ bitmap.width() <= maxTileSize &&
+ bitmap.height() <= maxTileSize;
if (paint.getMaskFilter() || drawAA) {
// Convert the bitmap to a shader so that the rect can be drawn
@@ -1150,7 +1150,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
}
params.setFilterMode(textureFilterMode);
- int maxTileSize = fContext->caps()->maxTextureSize() - 2 * tileFilterPad;
+ maxTileSize = fContext->caps()->maxTileSize() - 2 * tileFilterPad;
int tileSize;
SkIRect clippedSrcRect;
@@ -1279,8 +1279,8 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
SkCanvas::SrcRectConstraint constraint,
bool bicubic,
bool needsTextureDomain) {
- SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() &&
- bitmap.height() <= fContext->caps()->maxTextureSize());
+ SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() &&
+ bitmap.height() <= fContext->caps()->maxTileSize());
GrTexture* texture;
AutoBitmapTexture abt(fContext, bitmap, params, &texture);