diff options
author | bsalomon <bsalomon@google.com> | 2015-10-28 08:37:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-28 08:37:44 -0700 |
commit | 100b8f8c079510a6b7572f9ed8058c1d4a2bfeba (patch) | |
tree | b18472cdce2080a6d2a781f0906d6d570b977b19 /src | |
parent | 018fb62d12d1febf121fe265da5b6117b86a6541 (diff) |
Remove min texture size support
BUG=skia:4524
Review URL: https://codereview.chromium.org/1430643002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkImageCacherator.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrCaps.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrGpu.cpp | 17 | ||||
-rw-r--r-- | src/gpu/GrTextureParamsAdjuster.cpp | 43 | ||||
-rw-r--r-- | src/gpu/GrTextureParamsAdjuster.h | 16 | ||||
-rw-r--r-- | src/gpu/GrTextureProvider.cpp | 6 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 13 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 16 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 6 |
10 files changed, 20 insertions, 111 deletions
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index 71afc0e68a..bf9bea0af4 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -287,8 +287,6 @@ public: } protected: - GrTexture* peekOriginalTexture() override { return nullptr; } - // TODO: consider overriding this, for the case where the underlying generator might be // able to efficiently produce a "stretched" texture natively (e.g. picture-backed) // GrTexture* generateTextureForParams(GrContext*, const SkGrStretch&) override; @@ -309,10 +307,6 @@ protected: } } - bool getROBitmap(SkBitmap* bitmap) override { - return fCacher->lockAsBitmap(bitmap, fClient); - } - private: SkImageCacherator* fCacher; const SkImage* fClient; diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index cab44b97ce..4095f1ab10 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -106,7 +106,6 @@ GrCaps::GrCaps(const GrContextOptions& options) { fMaxRenderTargetSize = 1; fMaxTextureSize = 1; - fMinTextureSize = 1; fMaxSampleCount = 0; memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); @@ -122,7 +121,6 @@ GrCaps::GrCaps(const GrContextOptions& options) { void GrCaps::applyOptionsOverrides(const GrContextOptions& options) { fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride); - fMinTextureSize = SkTMax(fMinTextureSize, options.fMinTextureSizeOverride); } static SkString map_flags_to_string(uint32_t flags) { @@ -172,7 +170,6 @@ SkString GrCaps::dump() const { } r.appendf("Max Texture Size : %d\n", fMaxTextureSize); - r.appendf("Min Texture Size : %d\n", fMinTextureSize); r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); r.appendf("Max Sample Count : %d\n", fMaxSampleCount); diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 48fc740ae0..4970a63d16 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -57,21 +57,11 @@ void GrGpu::contextAbandoned() {} bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParams& textureParams, GrTextureParamsAdjuster::CopyParams* copyParams) const { - bool doCopy = false; const GrCaps& caps = *this->caps(); if (textureParams.isTiled() && !caps.npotTextureTileSupport() && (!SkIsPow2(width) || !SkIsPow2(height))) { - doCopy = true; - copyParams->fWidth = GrNextPow2(SkTMax(width, caps.minTextureSize())); - copyParams->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. - doCopy = true; - copyParams->fWidth = SkTMax(width, caps.minTextureSize()); - copyParams->fHeight = SkTMax(height, caps.minTextureSize()); - } - if (doCopy) { + copyParams->fWidth = GrNextPow2(width); + copyParams->fHeight = GrNextPow2(height); switch (textureParams.filterMode()) { case GrTextureParams::kNone_FilterMode: copyParams->fFilter = GrTextureParams::kNone_FilterMode; @@ -82,8 +72,9 @@ bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParam copyParams->fFilter = GrTextureParams::kBilerp_FilterMode; break; } + return true; } - return doCopy; + return false; } static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) { diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp index 9940f9e7d6..ee3d1351d7 100644 --- a/src/gpu/GrTextureParamsAdjuster.cpp +++ b/src/gpu/GrTextureParamsAdjuster.cpp @@ -79,28 +79,6 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const CopyParams& copyPar return copy.detach(); } -static SkBitmap copy_on_cpu(const SkBitmap& bmp, const CopyParams& copyParams) { - SkBitmap stretched; - stretched.allocN32Pixels(copyParams.fWidth, copyParams.fHeight); - SkCanvas canvas(stretched); - SkPaint paint; - switch (copyParams.fFilter) { - case GrTextureParams::kNone_FilterMode: - paint.setFilterQuality(kNone_SkFilterQuality); - break; - case GrTextureParams::kBilerp_FilterMode: - paint.setFilterQuality(kLow_SkFilterQuality); - break; - case GrTextureParams::kMipMap_FilterMode: - paint.setFilterQuality(kMedium_SkFilterQuality); - break; - } - SkRect dstRect = SkRect::MakeWH(SkIntToScalar(copyParams.fWidth), - SkIntToScalar(copyParams.fHeight)); - canvas.drawBitmapRect(bmp, dstRect, &paint); - return stretched; -} - GrTexture* GrTextureParamsAdjuster::refTextureForParams(GrContext* ctx, const GrTextureParams& params) { CopyParams copyParams; @@ -131,22 +109,9 @@ GrTexture* GrTextureParamsAdjuster::refTextureForParams(GrContext* ctx, GrTexture* GrTextureParamsAdjuster::generateTextureForParams(GrContext* ctx, const CopyParams& copyParams) { - if ((this->width() < ctx->caps()->minTextureSize() || - this->height() < ctx->caps()->minTextureSize()) && !this->peekOriginalTexture()) - { - // we can't trust our ability to use HW to perform the stretch, so we request - // a raster instead, and perform the stretch on the CPU. - SkBitmap bitmap; - if (!this->getROBitmap(&bitmap)) { - return nullptr; - } - SkBitmap stretchedBmp = copy_on_cpu(bitmap, copyParams); - return GrUploadBitmapToTexture(ctx, stretchedBmp); - } else { - SkAutoTUnref<GrTexture> original(this->refOriginalTexture(ctx)); - if (!original) { - return nullptr; - } - return copy_on_gpu(original, copyParams); + SkAutoTUnref<GrTexture> original(this->refOriginalTexture(ctx)); + if (!original) { + return nullptr; } + return copy_on_gpu(original, copyParams); } diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h index c244aaf2df..bc08c71af5 100644 --- a/src/gpu/GrTextureParamsAdjuster.h +++ b/src/gpu/GrTextureParamsAdjuster.h @@ -43,10 +43,6 @@ public: GrTexture* refTextureForParams(GrContext*, const GrTextureParams&); protected: - /** If the original is a inherently texture that can be returned for "free" then return it - without ref'ing it. Otherwise, return null. */ - virtual GrTexture* peekOriginalTexture() = 0; - /** * Return the maker's "original" texture. It is the responsibility of the maker * to make this efficient ... if the texture is being generated, the maker must handle @@ -66,9 +62,8 @@ protected: * Return a new (uncached) texture that is the stretch of the maker's original. * * The base-class handles general logic for this, and only needs access to the following - * methods: - * - onRefOriginalTexture() - * - onGetROBitmap() + * method: + * - refOriginalTexture() * * Subclass may override this if they can handle creating the texture more directly than * by copying. @@ -82,13 +77,6 @@ protected: */ virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0; - /** - * Some GPUs are unreliable w/ very small texture sizes. If we run into that case, this - * method will be called (in service of onGenerateParamsTexture) to return a raster version - * of the original texture. - */ - virtual bool getROBitmap(SkBitmap*) = 0; - /** Helper for creating a key for a copy from an original key. */ static void MakeCopyKeyFromOrigKey(const GrUniqueKey& origKey, const CopyParams& copyParams, diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp index 26384abbd2..cb652f7a7f 100644 --- a/src/gpu/GrTextureProvider.cpp +++ b/src/gpu/GrTextureProvider.cpp @@ -70,10 +70,10 @@ GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_GrSurfaceFlag)) { if (!(kExact_ScratchTextureFlag & flags)) { // bin by pow2 with a reasonable min - const int minSize = SkTMin(16, fGpu->caps()->minTextureSize()); + const int kMinSize = 16; GrSurfaceDesc* wdesc = desc.writable(); - wdesc->fWidth = SkTMax(minSize, GrNextPow2(desc->fWidth)); - wdesc->fHeight = SkTMax(minSize, GrNextPow2(desc->fHeight)); + wdesc->fWidth = SkTMax(kMinSize, GrNextPow2(desc->fWidth)); + wdesc->fHeight = SkTMax(kMinSize, GrNextPow2(desc->fHeight)); } GrScratchKey key; diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 3c3f3e8fab..1ffd256026 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -217,11 +217,6 @@ static GrTexture* load_etc1_texture(GrContext* ctx, const SkBitmap &bm, GrSurfac GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) { SkASSERT(!bmp.getTexture()); - if (bmp.width() < ctx->caps()->minTextureSize() || - bmp.height() < ctx->caps()->minTextureSize()) { - return nullptr; - } - SkBitmap tmpBitmap; const SkBitmap* bitmap = &bmp; @@ -291,8 +286,6 @@ public: } protected: - GrTexture* peekOriginalTexture() override { return fBitmap.getTexture(); } - GrTexture* refOriginalTexture(GrContext* ctx) override { GrTexture* tex = fBitmap.getTexture(); if (tex) { @@ -324,12 +317,6 @@ protected: InstallInvalidator(copyKey, fBitmap.pixelRef()); } - bool getROBitmap(SkBitmap* bitmap) override { - SkASSERT(!fBitmap.getTexture()); - *bitmap = fBitmap; - return true; - } - private: static void InstallInvalidator(const GrUniqueKey& key, SkPixelRef* pixelRef) { class Invalidator : public SkPixelRef::GenIDChangeListener { diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index ec945ea3e9..9879846ef2 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -424,11 +424,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, // attachment, hence this min: fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize); - // This GPU seems to have problems when tiling small textures - if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer()) { - fMinTextureSize = 16; - } - fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker"); // Disable scratch texture reuse on Mali and Adreno devices diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index feeac933dd..a0809c1d7a 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1184,7 +1184,7 @@ void inline get_stencil_rb_sizes(const GrGLInterface* gl, } int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { - int size = this->caps()->minTextureSize(); + static const int kSize = 16; if (kUnknownStencilIndex == fPixelConfigToStencilIndex[config]) { // Default to unsupported fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex; @@ -1226,8 +1226,8 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D, 0, internalFormat, - size, - size, + kSize, + kSize, 0, externalFormat, externalType, @@ -1266,7 +1266,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERBUFFER, sFmt.fInternalFormat, - size, size)); + kSize, kSize)); if (GR_GL_NO_ERROR == GR_GL_GET_ERROR(this->glInterface())) { GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, GR_GL_STENCIL_ATTACHMENT, @@ -1818,8 +1818,8 @@ static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL } // If the read is really small or smaller than the min texture size, don't force a draw. - int minSize = SkTMax(32, caps.minTextureSize()); - if (width < minSize || height < minSize) { + static const int kMinSize = 32; + if (width < kMinSize || height < kMinSize) { return false; } @@ -1857,9 +1857,7 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height, tempDrawInfo->fTempSurfaceDesc.fHeight = height; tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 0; tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL. - tempDrawInfo->fUseExactScratch = this->glCaps().partialFBOReadIsSlow() && - width >= this->caps()->minTextureSize() && - height >= this->caps()->minTextureSize(); + tempDrawInfo->fUseExactScratch = this->glCaps().partialFBOReadIsSlow(); // Start off assuming that any temp draw should be to the readConfig, then check if that will // be inefficient. diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index e5f3aeea25..8e5ce4564c 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -87,8 +87,6 @@ public: {} protected: - GrTexture* peekOriginalTexture() override { return fOriginal; } - GrTexture* refOriginalTexture(GrContext* ctx) override { return SkRef(fOriginal); } @@ -101,10 +99,6 @@ protected: as_IB(fImage)->notifyAddedToCache(); } - bool getROBitmap(SkBitmap* bitmap) override { - return as_IB(fImage)->getROPixels(bitmap); - } - private: const SkImage* fImage; GrTexture* fOriginal; |