diff options
author | bsalomon <bsalomon@google.com> | 2016-02-25 06:33:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-25 06:33:27 -0800 |
commit | 57599fe6c0336feaeeeb9b1996e77b70219b483c (patch) | |
tree | 5387b10428f64c8e5e56427b24a589489d746440 /src | |
parent | ddb347b63c72141378fc8bd25fa40d6dac9fe916 (diff) |
Move Budgeted enum out of SkSurface, use in GrTextureProvider
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1728093005
DOCS_PREVIEW= https://skia.org/?cl=1728093005
Review URL: https://codereview.chromium.org/1728093005
Diffstat (limited to 'src')
37 files changed, 94 insertions, 93 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index f0476cd183..a628105001 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1146,7 +1146,8 @@ static void draw_filter_into_device(SkBaseDevice* src, const SkImageFilter* filt // TODO: we should actually only copy the portion of the source needed to apply the image // filter GrContext* context = srcRT->getContext(); - SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture(srcRT->desc(), true)); + SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture(srcRT->desc(), + SkBudgeted::kYes)); context->copySurface(tex, srcRT); diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index dc831d7cbf..155eb82242 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -203,7 +203,7 @@ static GrTexture* load_compressed_into_texture(GrContext* ctx, SkData* data, GrS } desc.fConfig = config; - return ctx->textureProvider()->createTexture(desc, true, rawStart, 0); + return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, rawStart, 0); } class Generator_GrYUVProvider : public GrYUVProvider { diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index 398c6eb5df..db192a36e2 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -138,8 +138,7 @@ GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIR // // TODO: respect the usage, by possibly creating a different (pow2) surface // - SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, - SkSurface::kYes_Budgeted, + SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo)); if (!surface.get()) { return nullptr; diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp index 39e3947049..50fbbac601 100644 --- a/src/effects/GrCircleBlurFragmentProcessor.cpp +++ b/src/effects/GrCircleBlurFragmentProcessor.cpp @@ -247,7 +247,7 @@ GrTexture* GrCircleBlurFragmentProcessor::CreateCircleBlurProfileTexture( if (!blurProfile) { SkAutoTDeleteArray<uint8_t> profile(create_profile(halfWH, sigma)); - blurProfile = textureProvider->createTexture(texDesc, true, profile.get(), 0); + blurProfile = textureProvider->createTexture(texDesc, SkBudgeted::kYes, profile.get(), 0); if (blurProfile) { textureProvider->assignUniqueKeyToTexture(key, blurProfile); } diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 6679e8aa41..1be030baf6 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -794,7 +794,7 @@ GrTexture* GrRectBlurEffect::CreateBlurProfileTexture(GrTextureProvider* texture if (!blurProfile) { SkAutoTDeleteArray<uint8_t> profile(SkBlurMask::ComputeBlurProfile(sigma)); - blurProfile = textureProvider->createTexture(texDesc, true, profile.get(), 0); + blurProfile = textureProvider->createTexture(texDesc, SkBudgeted::kYes, profile.get(), 0); if (blurProfile) { textureProvider->assignUniqueKeyToTexture(key, blurProfile); } @@ -999,7 +999,7 @@ const GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvi texDesc.fConfig = kAlpha_8_GrPixelConfig; blurNinePatchTexture.reset( - texProvider->createTexture(texDesc, true, blurredMask.fImage, 0)); + texProvider->createTexture(texDesc, SkBudgeted::kYes , blurredMask.fImage, 0)); SkMask::FreeImage(blurredMask.fImage); if (!blurNinePatchTexture) { return nullptr; diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp index 4ddbc0c30f..1d2f839f5b 100644 --- a/src/effects/SkColorCubeFilter.cpp +++ b/src/effects/SkColorCubeFilter.cpp @@ -315,7 +315,7 @@ const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* con context->textureProvider()->findAndRefTextureByUniqueKey(key)); if (!textureCube) { textureCube.reset(context->textureProvider()->createTexture( - desc, true, fCubeData->data(), 0)); + desc, SkBudgeted::kYes, fCubeData->data(), 0)); if (textureCube) { context->textureProvider()->assignUniqueKeyToTexture(key, textureCube); } else { diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 2174b8569f..8844f1ac83 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -423,7 +423,8 @@ bool GrContext::readSurfacePixels(GrSurface* src, } SkAutoTUnref<GrTexture> temp; if (tempDrawInfo.fUseExactScratch) { - temp.reset(this->textureProvider()->createTexture(tempDrawInfo.fTempSurfaceDesc, true)); + temp.reset(this->textureProvider()->createTexture(tempDrawInfo.fTempSurfaceDesc, + SkBudgeted::kYes)); } else { temp.reset(this->textureProvider()->createApproxTexture(tempDrawInfo.fTempSurfaceDesc)); } diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 4fcd4d57af..8548e54a17 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -88,7 +88,7 @@ static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) } } -GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, bool budgeted, +GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budgeted, const void* srcData, size_t rowBytes) { GrSurfaceDesc desc = origDesc; @@ -120,8 +120,9 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, bool budgeted, } } - GrGpuResource::LifeCycle lifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : - GrGpuResource::kUncached_LifeCycle; + GrGpuResource::LifeCycle lifeCycle = SkBudgeted::kYes == budgeted ? + GrGpuResource::kCached_LifeCycle : + GrGpuResource::kUncached_LifeCycle; desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); // Attempt to catch un- or wrongly initialized sample counts; diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index fd134eae2c..0fef7a2015 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -93,7 +93,7 @@ public: * * @return The texture object if successful, otherwise nullptr. */ - GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, + GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData, size_t rowBytes); /** diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp index a227fd2c0f..98cea1c9a8 100644 --- a/src/gpu/GrGpuResource.cpp +++ b/src/gpu/GrGpuResource.cpp @@ -119,7 +119,7 @@ void GrGpuResource::setUniqueKey(const GrUniqueKey& key) { SkASSERT(key.isValid()); // Wrapped and uncached resources can never have a unique key. - if (!this->resourcePriv().isBudgeted()) { + if (SkBudgeted::kNo == this->resourcePriv().isBudgeted()) { return; } diff --git a/src/gpu/GrGpuResourceCacheAccess.h b/src/gpu/GrGpuResourceCacheAccess.h index 8c272420a7..70fe08503e 100644 --- a/src/gpu/GrGpuResourceCacheAccess.h +++ b/src/gpu/GrGpuResourceCacheAccess.h @@ -27,7 +27,7 @@ private: */ bool isScratch() const { return !fResource->getUniqueKey().isValid() && fResource->fScratchKey.isValid() && - fResource->resourcePriv().isBudgeted(); + SkBudgeted::kYes == fResource->resourcePriv().isBudgeted(); } /** diff --git a/src/gpu/GrGpuResourcePriv.h b/src/gpu/GrGpuResourcePriv.h index 5324dccc22..62dc85059a 100644 --- a/src/gpu/GrGpuResourcePriv.h +++ b/src/gpu/GrGpuResourcePriv.h @@ -44,10 +44,10 @@ public: /** * Does the resource count against the resource budget? */ - bool isBudgeted() const { + SkBudgeted isBudgeted() const { bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle; SkASSERT(ret || !fResource->getUniqueKey().isValid()); - return ret; + return SkBudgeted(ret); } /** diff --git a/src/gpu/GrLayerAtlas.cpp b/src/gpu/GrLayerAtlas.cpp index 9beb509f86..df8215a607 100644 --- a/src/gpu/GrLayerAtlas.cpp +++ b/src/gpu/GrLayerAtlas.cpp @@ -66,7 +66,7 @@ void GrLayerAtlas::createBackingTexture() { desc.fHeight = fBackingTextureSize.height(); desc.fConfig = fPixelConfig; - fTexture.reset(fTexProvider->createTexture(desc, true, nullptr, 0)); + fTexture.reset(fTexProvider->createTexture(desc, SkBudgeted::kYes, nullptr, 0)); fTexture->resourcePriv().setUniqueKey(get_layer_atlas_key()); } diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp index 105ee04e53..c2facbb12d 100644 --- a/src/gpu/GrLayerCache.cpp +++ b/src/gpu/GrLayerCache.cpp @@ -255,7 +255,7 @@ bool GrLayerCache::lock(GrCachedLayer* layer, const GrSurfaceDesc& desc, bool* n // TODO: make the test for exact match depend on the image filters themselves SkAutoTUnref<GrTexture> tex; if (layer->fFilter) { - tex.reset(fContext->textureProvider()->createTexture(desc, true)); + tex.reset(fContext->textureProvider()->createTexture(desc, SkBudgeted::kYes)); } else { tex.reset(fContext->textureProvider()->createApproxTexture(desc)); } diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index 4a0c9b2b36..005b6c4ccd 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -136,7 +136,7 @@ void GrResourceCache::insertResource(GrGpuResource* resource) { fHighWaterCount = SkTMax(this->getResourceCount(), fHighWaterCount); fHighWaterBytes = SkTMax(fBytes, fHighWaterBytes); #endif - if (resource->resourcePriv().isBudgeted()) { + if (SkBudgeted::kYes == resource->resourcePriv().isBudgeted()) { ++fBudgetedCount; fBudgetedBytes += size; TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used", @@ -167,7 +167,7 @@ void GrResourceCache::removeResource(GrGpuResource* resource) { size_t size = resource->gpuMemorySize(); SkDEBUGCODE(--fCount;) fBytes -= size; - if (resource->resourcePriv().isBudgeted()) { + if (SkBudgeted::kYes == resource->resourcePriv().isBudgeted()) { --fBudgetedCount; fBudgetedBytes -= size; TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used", @@ -375,7 +375,7 @@ void GrResourceCache::notifyCntReachedZero(GrGpuResource* resource, uint32_t fla this->removeFromNonpurgeableArray(resource); fPurgeableQueue.insert(resource); - if (!resource->resourcePriv().isBudgeted()) { + if (SkBudgeted::kNo == resource->resourcePriv().isBudgeted()) { // Check whether this resource could still be used as a scratch resource. if (!resource->cacheAccess().isExternal() && resource->resourcePriv().getScratchKey().isValid()) { @@ -414,7 +414,7 @@ void GrResourceCache::didChangeGpuMemorySize(const GrGpuResource* resource, size #if GR_CACHE_STATS fHighWaterBytes = SkTMax(fBytes, fHighWaterBytes); #endif - if (resource->resourcePriv().isBudgeted()) { + if (SkBudgeted::kYes == resource->resourcePriv().isBudgeted()) { fBudgetedBytes += delta; TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used", fBudgetedBytes, "free", fMaxBytes - fBudgetedBytes); @@ -433,7 +433,7 @@ void GrResourceCache::didChangeBudgetStatus(GrGpuResource* resource) { size_t size = resource->gpuMemorySize(); - if (resource->resourcePriv().isBudgeted()) { + if (SkBudgeted::kYes == resource->resourcePriv().isBudgeted()) { ++fBudgetedCount; fBudgetedBytes += size; #if GR_CACHE_STATS @@ -664,7 +664,7 @@ void GrResourceCache::validate() const { SkASSERT(fScratchMap->countForKey(resource->resourcePriv().getScratchKey())); SkASSERT(!resource->cacheAccess().isExternal()); } else if (resource->resourcePriv().getScratchKey().isValid()) { - SkASSERT(!resource->resourcePriv().isBudgeted() || + SkASSERT(SkBudgeted::kNo == resource->resourcePriv().isBudgeted() || resource->getUniqueKey().isValid()); ++fCouldBeScratch; SkASSERT(fScratchMap->countForKey(resource->resourcePriv().getScratchKey())); @@ -675,10 +675,10 @@ void GrResourceCache::validate() const { ++fContent; SkASSERT(fUniqueHash->find(uniqueKey) == resource); SkASSERT(!resource->cacheAccess().isExternal()); - SkASSERT(resource->resourcePriv().isBudgeted()); + SkASSERT(SkBudgeted::kYes == resource->resourcePriv().isBudgeted()); } - if (resource->resourcePriv().isBudgeted()) { + if (SkBudgeted::kYes == resource->resourcePriv().isBudgeted()) { ++fBudgetedCount; fBudgetedBytes += resource->gpuMemorySize(); } diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index adbfb7919f..8321289dff 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -220,7 +220,7 @@ public: if (resource->cacheAccess().isAdopted()) { ++fAdopted; } - if (!resource->resourcePriv().isBudgeted()) { + if (SkBudgeted::kNo == resource->resourcePriv().isBudgeted()) { fUnbudgetedSize += resource->gpuMemorySize(); } } diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index f082a8693a..dc14016973 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -74,8 +74,8 @@ void GrContext::getTestTarget(GrTestTarget* tar, GrRenderTarget* rt) { desc.fConfig = kRGBA_8888_GrPixelConfig; desc.fSampleCnt = 0; - SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(desc, false, - nullptr, 0)); + SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture( + desc, SkBudgeted::kNo, nullptr, 0)); if (nullptr == texture) { return; } diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp index fd17d2adb4..a78987cfb7 100644 --- a/src/gpu/GrTextureParamsAdjuster.cpp +++ b/src/gpu/GrTextureParamsAdjuster.cpp @@ -63,7 +63,8 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, } } - SkAutoTUnref<GrTexture> copy(context->textureProvider()->createTexture(rtDesc, true)); + SkAutoTUnref<GrTexture> copy(context->textureProvider()->createTexture(rtDesc, + SkBudgeted::kYes)); if (!copy) { return nullptr; } diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp index 7d720eb121..01c8a8e7a2 100644 --- a/src/gpu/GrTextureProvider.cpp +++ b/src/gpu/GrTextureProvider.cpp @@ -29,7 +29,7 @@ GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingl { } -GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budgeted, +GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData, size_t rowBytes) { ASSERT_SINGLE_OWNER if (this->isAbandoned()) { @@ -46,7 +46,7 @@ GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, srcData, rowBytes)) { - if (!budgeted) { + if (SkBudgeted::kNo == budgeted) { texture->resourcePriv().makeUnbudgeted(); } return texture; @@ -117,7 +117,7 @@ GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, } if (!(kNoCreate_ScratchTextureFlag & flags)) { - return fGpu->createTexture(*desc, true, nullptr, 0); + return fGpu->createTexture(*desc, SkBudgeted::kYes, nullptr, 0); } return nullptr; diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp index 844849a575..f889641849 100644 --- a/src/gpu/GrYUVProvider.cpp +++ b/src/gpu/GrYUVProvider.cpp @@ -98,7 +98,7 @@ GrTexture* GrYUVProvider::refAsTexture(GrContext* ctx, const GrSurfaceDesc& desc bool needsExactTexture = (yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) || (yuvDesc.fHeight != yuvInfo.fSize[0].fHeight); if (needsExactTexture) { - yuvTextures[i].reset(ctx->textureProvider()->createTexture(yuvDesc, true)); + yuvTextures[i].reset(ctx->textureProvider()->createTexture(yuvDesc, SkBudgeted::kYes)); } else { yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuvDesc)); } @@ -112,7 +112,8 @@ GrTexture* GrYUVProvider::refAsTexture(GrContext* ctx, const GrSurfaceDesc& desc GrSurfaceDesc rtDesc = desc; rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; - SkAutoTUnref<GrTexture> result(ctx->textureProvider()->createTexture(rtDesc, true, nullptr, 0)); + SkAutoTUnref<GrTexture> result(ctx->textureProvider()->createTexture(rtDesc, SkBudgeted::kYes, + nullptr, 0)); if (!result) { return nullptr; } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 0b44a4281a..cf613a9cac 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -147,7 +147,7 @@ SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height, return new SkGpuDevice(rt, width, height, props, flags); } -SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgeted, +SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkBudgeted budgeted, const SkImageInfo& info, int sampleCount, const SkSurfaceProps* props, InitContents init, GrTextureStorageAllocator customAllocator) { @@ -185,7 +185,7 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, } GrRenderTarget* SkGpuDevice::CreateRenderTarget( - GrContext* context, SkSurface::Budgeted budgeted, const SkImageInfo& origInfo, + GrContext* context, SkBudgeted budgeted, const SkImageInfo& origInfo, int sampleCount, GrTextureStorageAllocator textureStorageAllocator) { if (kUnknown_SkColorType == origInfo.colorType() || origInfo.width() < 0 || origInfo.height() < 0) { @@ -216,8 +216,7 @@ GrRenderTarget* SkGpuDevice::CreateRenderTarget( desc.fConfig = SkImageInfo2GrPixelConfig(info); desc.fSampleCnt = sampleCount; desc.fTextureStorageAllocator = textureStorageAllocator; - GrTexture* texture = context->textureProvider()->createTexture( - desc, SkToBool(budgeted), nullptr, 0); + GrTexture* texture = context->textureProvider()->createTexture(desc, budgeted, nullptr, 0); if (nullptr == texture) { return nullptr; } @@ -321,9 +320,7 @@ void SkGpuDevice::clearAll() { void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { ASSERT_SINGLE_OWNER - SkSurface::Budgeted budgeted = - fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgeted - : SkSurface::kNo_Budgeted; + SkBudgeted budgeted = fRenderTarget->resourcePriv().isBudgeted(); SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSampleCnt, @@ -1784,7 +1781,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint if (kNever_TileUsage == cinfo.fTileUsage) { texture.reset(fContext->textureProvider()->createApproxTexture(desc)); } else { - texture.reset(fContext->textureProvider()->createTexture(desc, true)); + texture.reset(fContext->textureProvider()->createTexture(desc, SkBudgeted::kYes)); } if (texture) { @@ -1802,7 +1799,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) { ASSERT_SINGLE_OWNER // TODO: Change the signature of newSurface to take a budgeted parameter. - static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; + static const SkBudgeted kBudgeted = SkBudgeted::kNo; return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget->desc().fSampleCnt, &props); } diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index ec3e158706..8fae408f87 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -52,7 +52,7 @@ public: * sampleCount. The Budgeted param controls whether the device's backing store counts against * the resource cache budget. On failure, returns nullptr. */ - static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInfo&, + static SkGpuDevice* Create(GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount, const SkSurfaceProps*, InitContents, GrTextureStorageAllocator = GrTextureStorageAllocator()); @@ -256,7 +256,7 @@ private: bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); - static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, const SkImageInfo&, + static GrRenderTarget* CreateRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount, GrTextureStorageAllocator); friend class GrAtlasTextContext; diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index df65e451fe..85f36d9381 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -212,7 +212,7 @@ static GrTexture* load_etc1_texture(GrContext* ctx, const SkBitmap &bm, GrSurfac return nullptr; } - return ctx->textureProvider()->createTexture(desc, true, startOfTexData, 0); + return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, startOfTexData, 0); } GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) { @@ -233,7 +233,7 @@ GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) { // our compressed data will be trimmed, so pass width() for its // "rowBytes", since they are the same now. - return ctx->textureProvider()->createTexture(desc, true, storage.get(), + return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, storage.get(), bitmap->width()); } else { bmp.copyTo(&tmpBitmap, kN32_SkColorType); @@ -265,7 +265,7 @@ GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) { return nullptr; } - return ctx->textureProvider()->createTexture(desc, true, bitmap->getPixels(), + return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, bitmap->getPixels(), bitmap->rowBytes()); } diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp index e48cbf5d15..6b75e6343c 100644 --- a/src/gpu/SkGrPixelRef.cpp +++ b/src/gpu/SkGrPixelRef.cpp @@ -78,7 +78,7 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT); desc.fTextureStorageAllocator = texture->desc().fTextureStorageAllocator; - GrTexture* dst = context->textureProvider()->createTexture(desc, false, nullptr, 0); + GrTexture* dst = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0); if (nullptr == dst) { return nullptr; } diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index 4e168cd827..2725e5631d 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -176,16 +176,19 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context desc.fHeight = 256; desc.fConfig = kRGBA_8888_GrPixelConfig; - SkAutoTUnref<GrTexture> readTex(context->textureProvider()->createTexture(desc, true, nullptr, 0)); + SkAutoTUnref<GrTexture> readTex(context->textureProvider()->createTexture( + desc, SkBudgeted::kYes, nullptr, 0)); if (!readTex.get()) { return; } - SkAutoTUnref<GrTexture> tempTex(context->textureProvider()->createTexture(desc, true, nullptr, 0)); + SkAutoTUnref<GrTexture> tempTex(context->textureProvider()->createTexture( + desc, SkBudgeted::kYes, nullptr, 0)); if (!tempTex.get()) { return; } desc.fFlags = kNone_GrSurfaceFlags; - SkAutoTUnref<GrTexture> dataTex(context->textureProvider()->createTexture(desc, true, data, 0)); + SkAutoTUnref<GrTexture> dataTex(context->textureProvider()->createTexture( + desc, SkBudgeted::kYes, data, 0)); if (!dataTex.get()) { return; } diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 39bc3899b3..01d2679e6f 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -203,7 +203,8 @@ void GrTextureStripAtlas::lockTexture() { fTexture = fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(key); if (nullptr == fTexture) { - fTexture = fDesc.fContext->textureProvider()->createTexture(texDesc, true, nullptr, 0); + fTexture = fDesc.fContext->textureProvider()->createTexture(texDesc, SkBudgeted::kYes, + nullptr, 0); if (!fTexture) { return; } diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 1070f53c5c..8e6fbadc7b 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -2197,7 +2197,7 @@ bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConf desc.fConfig = rtConfig; desc.fWidth = desc.fHeight = 16; desc.fFlags = kRenderTarget_GrSurfaceFlag; - SkAutoTUnref<GrTexture> temp(this->createTexture(desc, false, nullptr, 0)); + SkAutoTUnref<GrTexture> temp(this->createTexture(desc, SkBudgeted::kNo, nullptr, 0)); if (!temp) { return false; } diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index e6ea9bd121..5521b6e305 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -288,8 +288,7 @@ SkImage* SkImage::NewFromBitmap(const SkBitmap& bm) { if (GrTexture* tex = pr->getTexture()) { SkAutoTUnref<GrTexture> unrefCopy; if (!bm.isImmutable()) { - const bool notBudgeted = false; - tex = GrDeepCopyTexture(tex, notBudgeted); + tex = GrDeepCopyTexture(tex, SkBudgeted::kNo); if (nullptr == tex) { return nullptr; } @@ -297,7 +296,7 @@ SkImage* SkImage::NewFromBitmap(const SkBitmap& bm) { } const SkImageInfo info = bm.info(); return new SkImage_Gpu(info.width(), info.height(), bm.getGenerationID(), info.alphaType(), - tex, SkSurface::kNo_Budgeted); + tex, SkBudgeted::kNo); } #endif diff --git a/src/image/SkImagePriv.h b/src/image/SkImagePriv.h index 7518bbe808..acd0beb475 100644 --- a/src/image/SkImagePriv.h +++ b/src/image/SkImagePriv.h @@ -56,6 +56,6 @@ extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); // surface needs to perform a copy-on-write extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); -GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); +GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted); #endif diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index c502fc0092..e28a31d4bf 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -20,7 +20,7 @@ #include "SkPixelRef.h" SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex, - SkSurface::Budgeted budgeted) + SkBudgeted budgeted) : INHERITED(w, h, uniqueID) , fTexture(SkRef(tex)) , fAlphaType(at) @@ -140,8 +140,7 @@ SkImage* SkImage_Gpu::onNewSubset(const SkIRect& subset) const { desc.fWidth = subset.width(); desc.fHeight = subset.height(); - GrTexture* subTx = ctx->textureProvider()->createTexture(desc, - SkSurface::kYes_Budgeted == fBudgeted); + GrTexture* subTx = ctx->textureProvider()->createTexture(desc, fBudgeted); if (!subTx) { return nullptr; } @@ -167,7 +166,7 @@ static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextur tex->setRelease(releaseProc, releaseCtx); } - const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted; + const SkBudgeted budgeted = SkBudgeted::kNo; return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex, budgeted); } @@ -193,22 +192,20 @@ SkImage* SkImage::NewFromTextureCopy(GrContext* ctx, const GrBackendTextureDesc& return nullptr; } - const bool isBudgeted = true; - SkAutoTUnref<GrTexture> dst(GrDeepCopyTexture(src, isBudgeted)); + SkAutoTUnref<GrTexture> dst(GrDeepCopyTexture(src, SkBudgeted::kYes)); if (!dst) { return nullptr; } - const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst, - budgeted); + SkBudgeted::kYes); } SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorSpace, const GrBackendObject yuvTextureHandles[3], const SkISize yuvSizes[3], GrSurfaceOrigin origin) { - const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; + const SkBudgeted budgeted = SkBudgeted::kYes; if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 || yuvSizes[1].fWidth <= 0 || yuvSizes[1].fHeight <= 0 || @@ -259,7 +256,7 @@ SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS dstDesc.fConfig = kRGBA_8888_GrPixelConfig; dstDesc.fSampleCnt = 0; - SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, true)); + SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, SkBudgeted::kYes)); if (!dst) { return nullptr; } @@ -288,7 +285,7 @@ static SkImage* create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, u return nullptr; } return new SkImage_Gpu(texture->width(), texture->height(), id, at, texture, - SkSurface::kNo_Budgeted); + SkBudgeted::kNo); } SkImage* SkImage::newTextureImage(GrContext *context) const { @@ -315,7 +312,7 @@ SkImage* SkImage::newTextureImage(GrContext *context) const { /////////////////////////////////////////////////////////////////////////////////////////////////// -GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { +GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) { GrContext* ctx = src->getContext(); GrSurfaceDesc desc = src->desc(); diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h index a36c8ebc13..d4640d4afc 100644 --- a/src/image/SkImage_Gpu.h +++ b/src/image/SkImage_Gpu.h @@ -22,13 +22,13 @@ public: * An "image" can be a subset/window into a larger texture, so we explicit take the * width and height. */ - SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, SkSurface::Budgeted); + SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, SkBudgeted); ~SkImage_Gpu() override; void applyBudgetDecision() const { GrTexture* tex = this->getTexture(); SkASSERT(tex); - if (fBudgeted) { + if (SkBudgeted::kYes == fBudgeted) { tex->resourcePriv().makeBudgeted(); } else { tex->resourcePriv().makeUnbudgeted(); @@ -45,7 +45,7 @@ public: int srcX, int srcY, CachingHint) const override; SkSurface* onNewSurface(const SkImageInfo& info) const override { - return SkSurface::NewRenderTarget(fTexture->getContext(), SkSurface::kNo_Budgeted, info); + return SkSurface::NewRenderTarget(fTexture->getContext(), SkBudgeted::kNo, info); } bool asBitmapForImageFilters(SkBitmap* bitmap) const override; @@ -53,7 +53,7 @@ public: private: SkAutoTUnref<GrTexture> fTexture; const SkAlphaType fAlphaType; - const SkSurface::Budgeted fBudgeted; + const SkBudgeted fBudgeted; mutable SkAtomic<bool> fAddedRasterVersionToCache; diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index 4fc904539b..b018ef9756 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -79,7 +79,7 @@ SkSurface_Base::~SkSurface_Base() { } void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) { - SkImage* image = this->newImageSnapshot(kYes_Budgeted); + SkImage* image = this->newImageSnapshot(SkBudgeted::kYes); if (image) { canvas->drawImage(image, x, y, paint); image->unref(); @@ -163,12 +163,12 @@ SkCanvas* SkSurface::getCanvas() { return asSB(this)->getCachedCanvas(); } -SkImage* SkSurface::newImageSnapshot(Budgeted budgeted) { +SkImage* SkSurface::newImageSnapshot(SkBudgeted budgeted) { // the caller will call unref() to balance this return asSB(this)->refCachedImage(budgeted, kNo_ForceUnique); } -SkImage* SkSurface::newImageSnapshot(Budgeted budgeted, ForceUnique unique) { +SkImage* SkSurface::newImageSnapshot(SkBudgeted budgeted, ForceUnique unique) { // the caller will call unref() to balance this return asSB(this)->refCachedImage(budgeted, unique); } @@ -211,7 +211,7 @@ SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp return nullptr; } -SkSurface* SkSurface::NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&, int, +SkSurface* SkSurface::NewRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int, const SkSurfaceProps*, GrTextureStorageAllocator) { return nullptr; } diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h index 159780b33a..0519a9b3c0 100644 --- a/src/image/SkSurface_Base.h +++ b/src/image/SkSurface_Base.h @@ -43,7 +43,7 @@ public: * must faithfully represent the current contents, even if the surface * is changed after this called (e.g. it is drawn to via its canvas). */ - virtual SkImage* onNewImageSnapshot(Budgeted, ForceCopyMode) = 0; + virtual SkImage* onNewImageSnapshot(SkBudgeted, ForceCopyMode) = 0; /** * Default implementation: @@ -81,7 +81,7 @@ public: virtual void onPrepareForExternalIO() {} inline SkCanvas* getCachedCanvas(); - inline SkImage* refCachedImage(Budgeted, ForceUnique); + inline SkImage* refCachedImage(SkBudgeted, ForceUnique); bool hasCachedImage() const { return fCachedImage != nullptr; } @@ -114,7 +114,7 @@ SkCanvas* SkSurface_Base::getCachedCanvas() { return fCachedCanvas; } -SkImage* SkSurface_Base::refCachedImage(Budgeted budgeted, ForceUnique unique) { +SkImage* SkSurface_Base::refCachedImage(SkBudgeted budgeted, ForceUnique unique) { SkImage* snap = fCachedImage; if (kYes_ForceUnique == unique && snap && !snap->unique()) { snap = nullptr; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index d1544630cc..5345ceee20 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -72,12 +72,12 @@ SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { GrRenderTarget* rt = fDevice->accessRenderTarget(); int sampleCount = rt->numColorSamples(); // TODO: Make caller specify this (change virtual signature of onNewSurface). - static const Budgeted kBudgeted = kNo_Budgeted; + static const SkBudgeted kBudgeted = SkBudgeted::kNo; return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampleCount, &this->props()); } -SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted, ForceCopyMode forceCopyMode) { +SkImage* SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode forceCopyMode) { GrRenderTarget* rt = fDevice->accessRenderTarget(); SkASSERT(rt); GrTexture* tex = rt->asTexture(); @@ -87,7 +87,7 @@ SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted, ForceCopyMode forc GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); GrContext* ctx = fDevice->context(); desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag; - copy.reset(ctx->textureProvider()->createTexture(desc, kYes_Budgeted == budgeted)); + copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); if (!copy) { return nullptr; } @@ -112,7 +112,7 @@ void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { GrRenderTarget* rt = fDevice->accessRenderTarget(); // are we sharing our render target with the image? Note this call should never create a new // image because onCopyOnWrite is only called when there is a cached image. - SkAutoTUnref<SkImage> image(this->refCachedImage(kNo_Budgeted, kNo_ForceUnique)); + SkAutoTUnref<SkImage> image(this->refCachedImage(SkBudgeted::kNo, kNo_ForceUnique)); SkASSERT(image); if (rt->asTexture() == as_IB(image)->getTexture()) { this->fDevice->replaceRenderTarget(SkSurface::kRetain_ContentChangeMode == mode); @@ -141,7 +141,7 @@ SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf return new SkSurface_Gpu(device); } -SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, Budgeted budgeted, const SkImageInfo& info, +SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, SkBudgeted budgeted, const SkImageInfo& info, int sampleCount, const SkSurfaceProps* props, GrTextureStorageAllocator customAllocator) { SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create( diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h index dff7970d46..72e9caf462 100644 --- a/src/image/SkSurface_Gpu.h +++ b/src/image/SkSurface_Gpu.h @@ -23,7 +23,7 @@ public: bool onGetRenderTargetHandle(GrBackendObject*, BackendHandleAccess) override; SkCanvas* onNewCanvas() override; SkSurface* onNewSurface(const SkImageInfo&) override; - SkImage* onNewImageSnapshot(Budgeted, ForceCopyMode) override; + SkImage* onNewImageSnapshot(SkBudgeted, ForceCopyMode) override; void onCopyOnWrite(ContentChangeMode) override; void onDiscard() override; void onPrepareForExternalIO() override; diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index 37790a0dd9..d07e94998f 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -24,7 +24,7 @@ public: SkCanvas* onNewCanvas() override; SkSurface* onNewSurface(const SkImageInfo&) override; - SkImage* onNewImageSnapshot(Budgeted, ForceCopyMode) override; + SkImage* onNewImageSnapshot(SkBudgeted, ForceCopyMode) override; void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override; void onCopyOnWrite(ContentChangeMode) override; void onRestoreBackingMutability() override; @@ -118,7 +118,7 @@ void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, canvas->drawBitmap(fBitmap, x, y, paint); } -SkImage* SkSurface_Raster::onNewImageSnapshot(Budgeted, ForceCopyMode forceCopyMode) { +SkImage* SkSurface_Raster::onNewImageSnapshot(SkBudgeted, ForceCopyMode forceCopyMode) { if (fWeOwnThePixels) { // SkImage_raster requires these pixels are immutable for its full lifetime. // We'll undo this via onRestoreBackingMutability() if we can avoid the COW. @@ -143,7 +143,7 @@ void SkSurface_Raster::onRestoreBackingMutability() { void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { // are we sharing pixelrefs with the image? - SkAutoTUnref<SkImage> cached(this->refCachedImage(kNo_Budgeted, kNo_ForceUnique)); + SkAutoTUnref<SkImage> cached(this->refCachedImage(SkBudgeted::kNo, kNo_ForceUnique)); SkASSERT(cached); if (SkBitmapImageGetPixelRef(cached) == fBitmap.pixelRef()) { SkASSERT(fWeOwnThePixels); diff --git a/src/utils/SkImageGeneratorUtils.cpp b/src/utils/SkImageGeneratorUtils.cpp index 928d052ec6..ebffb30b3f 100644 --- a/src/utils/SkImageGeneratorUtils.cpp +++ b/src/utils/SkImageGeneratorUtils.cpp @@ -69,7 +69,7 @@ protected: desc.fWidth = subset->width(); desc.fHeight = subset->height(); - GrTexture* dst = fCtx->textureProvider()->createTexture(desc, false); + GrTexture* dst = fCtx->textureProvider()->createTexture(desc, SkBudgeted::kNo); fCtx->copySurface(dst, fTexture, *subset, SkIPoint::Make(0, 0)); return dst; } |