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 Committed: https://skia.googlesource.com/skia/+/57599fe6c0336feaeeeb9b1996e77b70219b483c CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1728093005
This commit is contained in:
parent
f7e865a33a
commit
5ec26ae9bf
@ -185,7 +185,7 @@ struct GPUTarget : public Target {
|
||||
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->config.ctxType,
|
||||
this->config.ctxOptions),
|
||||
SkSurface::kNo_Budgeted, info,
|
||||
SkBudgeted::kNo, info,
|
||||
this->config.samples, &props));
|
||||
this->gl = gGrFactory->getContextInfo(this->config.ctxType,
|
||||
this->config.ctxOptions).fGLContext;
|
||||
|
@ -54,7 +54,7 @@ static std::shared_ptr<SkSurface> create_opengl_surface(int w, int h) {
|
||||
std::cout << "Using opengl surface" << std::endl;
|
||||
std::shared_ptr<GrContext> grContext = adopt(GrContext::Create(kOpenGL_GrBackend, 0));
|
||||
return adopt(SkSurface::NewRenderTarget(grContext.get(),
|
||||
SkSurface::kNo_Budgeted,
|
||||
SkBudgeted::kNo,
|
||||
SkImageInfo::MakeN32Premul(w,h)));
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory,
|
||||
bool useDIText) {
|
||||
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
|
||||
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
return SkSurface::NewRenderTarget(grFactory->get(type, options), SkSurface::kNo_Budgeted,
|
||||
return SkSurface::NewRenderTarget(grFactory->get(type, options), SkBudgeted::kNo,
|
||||
info, samples, &props);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ int main() {
|
||||
SkAutoTUnref<SkSurface> surface(
|
||||
SkSurface::NewRenderTarget(
|
||||
grContext,
|
||||
SkSurface::kNo_Budgeted,
|
||||
SkBudgeted::kNo,
|
||||
SkImageInfo::MakeN32Premul(options.size)));
|
||||
if (!surface) {
|
||||
fputs("Unable to get render surface.\n", stderr);
|
||||
|
@ -236,8 +236,8 @@ bool make_oversized_texture_bitmap(GrContext* ctx, TestPixels* result, int width
|
||||
desc.fConfig = config;
|
||||
desc.fWidth = width + kXPad;
|
||||
desc.fHeight = height + kYPad;
|
||||
SkAutoTUnref<GrTexture> texture(ctx->textureProvider()->createTexture(desc, true, pixels.get(),
|
||||
rowBytes));
|
||||
SkAutoTUnref<GrTexture> texture(ctx->textureProvider()->createTexture(
|
||||
desc, SkBudgeted::kYes, pixels.get(), rowBytes));
|
||||
|
||||
if (!texture) {
|
||||
return false;
|
||||
|
@ -51,7 +51,7 @@ protected:
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(onISize());
|
||||
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
||||
SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted,
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo,
|
||||
info, 0, &props));
|
||||
SkCanvas* canvas = surface.get() ? surface->getCanvas() : inputCanvas;
|
||||
// init our new canvas with the old canvas's matrix
|
||||
|
@ -45,7 +45,7 @@ protected:
|
||||
size.fWidth /= 10;
|
||||
size.fHeight /= 10;
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(size);
|
||||
SkSurface* surface = SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info);
|
||||
SkSurface* surface = SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info);
|
||||
|
||||
if (nullptr == surface) {
|
||||
return;
|
||||
|
@ -177,7 +177,7 @@ protected:
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
surf2.reset(SkSurface::NewRenderTarget(canvas->getGrContext(),
|
||||
SkSurface::kNo_Budgeted, info));
|
||||
SkBudgeted::kNo, info));
|
||||
#endif
|
||||
|
||||
test_surface(canvas, surf0, true);
|
||||
@ -262,7 +262,7 @@ static SkImage* make_codec(const SkImageInfo& info, GrContext*, void (*draw)(SkC
|
||||
|
||||
static SkImage* make_gpu(const SkImageInfo& info, GrContext* ctx, void (*draw)(SkCanvas*)) {
|
||||
if (!ctx) { return nullptr; }
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info));
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info));
|
||||
draw(surface->getCanvas());
|
||||
return surface->newImageSnapshot();
|
||||
}
|
||||
@ -487,7 +487,7 @@ DEF_SIMPLE_GM(new_texture_image, canvas, 225, 60) {
|
||||
// Create a texture image
|
||||
[context, render_image]() -> SkImage* {
|
||||
SkAutoTUnref<SkSurface> surface(
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted,
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
|
||||
SkImageInfo::MakeN32Premul(kSize, kSize)));
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
|
@ -211,7 +211,7 @@ public:
|
||||
: SkImageGenerator(info)
|
||||
, fCtx(SkRef(ctx))
|
||||
{
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted,
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo,
|
||||
info, 0));
|
||||
surface->getCanvas()->clear(0);
|
||||
surface->getCanvas()->translate(-100, -100);
|
||||
@ -233,7 +233,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;
|
||||
}
|
||||
@ -326,7 +326,7 @@ protected:
|
||||
// No API to draw a GrTexture directly, so we cheat and create a private image subclass
|
||||
SkAutoTUnref<SkImage> image(new SkImage_Gpu(cache->info().width(), cache->info().height(),
|
||||
cache->uniqueID(), kPremul_SkAlphaType, texture,
|
||||
SkSurface::kNo_Budgeted));
|
||||
SkBudgeted::kNo));
|
||||
canvas->drawImage(image, x, y);
|
||||
#endif
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ static SkImage* make_texture(GrContext* ctx, const SkPicture* pic, const SkImage
|
||||
if (!ctx) {
|
||||
return nullptr;
|
||||
}
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted,
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo,
|
||||
info, 0));
|
||||
surface->getCanvas()->clear(0);
|
||||
surface->getCanvas()->drawPicture(pic);
|
||||
|
@ -16,7 +16,7 @@ static SkImage* create_image(GrContext* context, int width, int height) {
|
||||
SkAutoTUnref<SkSurface> surface;
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
|
||||
if (context) {
|
||||
surface.reset(SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted, info, 0));
|
||||
surface.reset(SkSurface::NewRenderTarget(context, SkBudgeted::kYes, info, 0));
|
||||
} else {
|
||||
surface.reset(SkSurface::NewRaster(info));
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelG
|
||||
|
||||
SkSurfaceProps props(flags, geo);
|
||||
if (ctx) {
|
||||
return SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info, 0, &props);
|
||||
return SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
|
||||
} else {
|
||||
return SkSurface::NewRaster(info, &props);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
|
||||
desc.fWidth = 2 * S;
|
||||
desc.fHeight = 2 * S;
|
||||
GrTexture* texture = ctx->textureProvider()->createTexture(
|
||||
desc, false, gTextureData.get(), 0);
|
||||
desc, SkBudgeted::kNo, gTextureData.get(), 0);
|
||||
|
||||
if (!texture) {
|
||||
return;
|
||||
|
@ -99,7 +99,7 @@ protected:
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(onISize());
|
||||
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
||||
SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
surface.reset(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info, 0,
|
||||
surface.reset(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info, 0,
|
||||
&props));
|
||||
canvas = surface.get() ? surface->getCanvas() : inputCanvas;
|
||||
// init our new canvas with the old canvas's matrix
|
||||
|
@ -128,7 +128,7 @@ private:
|
||||
SkImageInfo baseInfo = baseCanvas->imageInfo();
|
||||
SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInfo.alphaType(),
|
||||
baseInfo.profileType());
|
||||
return SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0, nullptr);
|
||||
return SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
@ -30,18 +30,10 @@ class GrRenderTarget;
|
||||
*/
|
||||
class SK_API SkSurface : public SkRefCnt {
|
||||
public:
|
||||
/**
|
||||
* Indicates whether a new surface or image should count against a cache budget. Currently this
|
||||
* is only used by the GPU backend (sw-raster surfaces and images are never counted against the
|
||||
* resource cache budget.)
|
||||
*/
|
||||
enum Budgeted {
|
||||
/** The surface or image does not count against the cache budget. */
|
||||
kNo_Budgeted,
|
||||
/** The surface or image counts against the cache budget. */
|
||||
kYes_Budgeted
|
||||
};
|
||||
|
||||
static const SkBudgeted kYes_Budgeted = SkBudgeted::kYes;
|
||||
static const SkBudgeted kNo_Budgeted = SkBudgeted::kNo;
|
||||
using Budgeted = SkBudgeted;
|
||||
|
||||
/**
|
||||
* Create a new surface, using the specified pixels/rowbytes as its
|
||||
* backend.
|
||||
@ -135,10 +127,10 @@ public:
|
||||
* additional textures.
|
||||
*/
|
||||
static SkSurface* NewRenderTarget(
|
||||
GrContext*, Budgeted, const SkImageInfo&, int sampleCount, const SkSurfaceProps* = NULL,
|
||||
GrTextureStorageAllocator = GrTextureStorageAllocator());
|
||||
GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount,
|
||||
const SkSurfaceProps* = NULL, GrTextureStorageAllocator = GrTextureStorageAllocator());
|
||||
|
||||
static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageInfo& info) {
|
||||
static SkSurface* NewRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) {
|
||||
return NewRenderTarget(gr, b, info, 0);
|
||||
}
|
||||
|
||||
@ -244,7 +236,7 @@ public:
|
||||
* parameter controls whether it counts against the resource budget
|
||||
* (currently for the gpu backend only).
|
||||
*/
|
||||
SkImage* newImageSnapshot(Budgeted = kYes_Budgeted);
|
||||
SkImage* newImageSnapshot(SkBudgeted = SkBudgeted::kYes);
|
||||
|
||||
/**
|
||||
* In rare instances a client may want a unique copy of the SkSurface's contents in an image
|
||||
@ -256,7 +248,7 @@ public:
|
||||
kNo_ForceUnique,
|
||||
kYes_ForceUnique
|
||||
};
|
||||
SkImage* newImageSnapshot(Budgeted, ForceUnique);
|
||||
SkImage* newImageSnapshot(SkBudgeted, ForceUnique);
|
||||
|
||||
/**
|
||||
* Though the caller could get a snapshot image explicitly, and draw that,
|
||||
|
@ -439,6 +439,17 @@ template <typename T> static inline const T& SkTPin(const T& value, const T& min
|
||||
return SkTMax(SkTMin(value, max), min);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates whether an allocation should count against a cache budget.
|
||||
*/
|
||||
enum class SkBudgeted : bool {
|
||||
kNo = false,
|
||||
kYes = true
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Use to combine multiple bits in a bitmask in a type safe way.
|
||||
|
@ -29,11 +29,11 @@ public:
|
||||
* implies tightly packed rows. For compressed pixel configs, this
|
||||
* field is ignored.
|
||||
*/
|
||||
GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, const void* srcData,
|
||||
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData,
|
||||
size_t rowBytes);
|
||||
|
||||
/** Shortcut for creating a texture with no initial data to upload. */
|
||||
GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted) {
|
||||
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted) {
|
||||
return this->createTexture(desc, budgeted, NULL, 0);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public:
|
||||
if (kApprox_ScratchTexMatch == match) {
|
||||
return this->createApproxTexture(desc);
|
||||
} else {
|
||||
return this->createTexture(desc, true);
|
||||
return this->createTexture(desc, SkBudgeted::kYes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ example, we use a `GrContextFactory` to create a context.
|
||||
GrContext* context = grFactory.get(GrContextFactory::kNative_GLContextType);
|
||||
SkImageInfo info = SkImageInfo:: MakeN32Premul(width, height);
|
||||
SkAutoTUnref<SkSurface> gpuSurface(
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info));
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info));
|
||||
if (!gpuSurface) {
|
||||
SkDebugf("SkSurface::NewRenderTarget returned null\n");
|
||||
return;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ private:
|
||||
*/
|
||||
bool isScratch() const {
|
||||
return !fResource->getUniqueKey().isValid() && fResource->fScratchKey.isValid() &&
|
||||
fResource->resourcePriv().isBudgeted();
|
||||
SkBudgeted::kYes == fResource->resourcePriv().isBudgeted();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ public:
|
||||
if (resource->cacheAccess().isAdopted()) {
|
||||
++fAdopted;
|
||||
}
|
||||
if (!resource->resourcePriv().isBudgeted()) {
|
||||
if (SkBudgeted::kNo == resource->resourcePriv().isBudgeted()) {
|
||||
fUnbudgetedSize += resource->gpuMemorySize();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(BitmapCopy_Texture, reporter, ctx) {
|
||||
const void* srcData = (kSkia8888_GrPixelConfig == desc.fConfig) ? kData : swizData;
|
||||
|
||||
SkAutoTUnref<GrTexture> texture(
|
||||
ctx->textureProvider()->createTexture(desc, false, srcData, 0));
|
||||
ctx->textureProvider()->createTexture(desc, SkBudgeted::kNo, srcData, 0));
|
||||
|
||||
if (!texture) {
|
||||
continue;
|
||||
|
@ -565,7 +565,7 @@ DEF_TEST(BlurAsABlur, reporter) {
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SmallBoxBlurBug, reporter, ctx) {
|
||||
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info));
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info));
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
|
||||
SkRect r = SkRect::MakeXYWH(10, 10, 100, 100);
|
||||
|
@ -55,7 +55,7 @@ static bool reset_dc(SkAutoTUnref<GrDrawContext>* dc, SkAutoTUnref<GrSurface>* r
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
|
||||
rtKeepAlive->reset(context->textureProvider()->createTexture(desc, true));
|
||||
rtKeepAlive->reset(context->textureProvider()->createTexture(desc, SkBudgeted::kYes));
|
||||
if (!(*rtKeepAlive)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, context) {
|
||||
desc.fHeight = kYSize;
|
||||
|
||||
SkAutoTUnref<GrTexture> texture(
|
||||
context->textureProvider()->createTexture(desc, false, nullptr, 0));
|
||||
context->textureProvider()->createTexture(desc, SkBudgeted::kYes, nullptr, 0));
|
||||
if (!texture) {
|
||||
return;
|
||||
}
|
||||
|
@ -68,11 +68,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, context) {
|
||||
dstDesc.fFlags = dFlags;
|
||||
|
||||
SkAutoTUnref<GrTexture> src(
|
||||
context->textureProvider()->createTexture(srcDesc, false,
|
||||
context->textureProvider()->createTexture(srcDesc, SkBudgeted::kNo,
|
||||
srcPixels.get(),
|
||||
kRowBytes));
|
||||
SkAutoTUnref<GrTexture> dst(
|
||||
context->textureProvider()->createTexture(dstDesc, false,
|
||||
context->textureProvider()->createTexture(dstDesc, SkBudgeted::kNo,
|
||||
dstPixels.get(),
|
||||
kRowBytes));
|
||||
if (!src || !dst) {
|
||||
|
@ -73,7 +73,8 @@ static void test_copy_surface(skiatest::Reporter* reporter, GrContext* context,
|
||||
copyDesc.fWidth = externalTexture->width();
|
||||
copyDesc.fHeight = externalTexture->height();
|
||||
copyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
SkAutoTUnref<GrTexture> copy(context->textureProvider()->createTexture(copyDesc, true));
|
||||
SkAutoTUnref<GrTexture> copy(context->textureProvider()->createTexture(
|
||||
copyDesc, SkBudgeted::kYes));
|
||||
context->copySurface(copy, externalTexture);
|
||||
test_read_pixels(reporter, context, copy, expectedPixelValues);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context,
|
||||
desc.fOrigin = 0 == origin ?
|
||||
kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
|
||||
SkAutoTUnref<GrTexture> fpTexture(context->textureProvider()->createTexture(
|
||||
desc, false, controlPixelData.begin(), 0));
|
||||
desc, SkBudgeted::kNo, controlPixelData.begin(), 0));
|
||||
// Floating point textures are NOT supported everywhere
|
||||
if (nullptr == fpTexture) {
|
||||
continue;
|
||||
|
@ -170,7 +170,7 @@ static GrRenderTarget* random_render_target(GrTextureProvider* textureProvider,
|
||||
|
||||
GrTexture* texture = textureProvider->findAndRefTextureByUniqueKey(key);
|
||||
if (!texture) {
|
||||
texture = textureProvider->createTexture(texDesc, true);
|
||||
texture = textureProvider->createTexture(texDesc, SkBudgeted::kYes);
|
||||
if (texture) {
|
||||
textureProvider->assignUniqueKeyToTexture(key, texture);
|
||||
}
|
||||
@ -310,13 +310,13 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
||||
dummyDesc.fWidth = 34;
|
||||
dummyDesc.fHeight = 18;
|
||||
SkAutoTUnref<GrTexture> dummyTexture1(
|
||||
context->textureProvider()->createTexture(dummyDesc, false, nullptr, 0));
|
||||
context->textureProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0));
|
||||
dummyDesc.fFlags = kNone_GrSurfaceFlags;
|
||||
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
|
||||
dummyDesc.fWidth = 16;
|
||||
dummyDesc.fHeight = 22;
|
||||
SkAutoTUnref<GrTexture> dummyTexture2(
|
||||
context->textureProvider()->createTexture(dummyDesc, false, nullptr, 0));
|
||||
context->textureProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0));
|
||||
|
||||
if (!dummyTexture1 || ! dummyTexture2) {
|
||||
SkDebugf("Could not allocate dummy textures");
|
||||
@ -373,7 +373,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
||||
rtDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
rtDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
SkAutoTUnref<GrRenderTarget> rt(
|
||||
context->textureProvider()->createTexture(rtDesc, false)->asRenderTarget());
|
||||
context->textureProvider()->createTexture(rtDesc, SkBudgeted::kNo)->asRenderTarget());
|
||||
int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count();
|
||||
for (int i = 0; i < fpFactoryCnt; ++i) {
|
||||
// Since FP factories internally randomize, call each 10 times.
|
||||
|
@ -82,7 +82,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) {
|
||||
for (auto& sampleCount : {0, 4, 16}) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
|
||||
SkAutoTUnref<SkSurface> surface(
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info,
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info,
|
||||
sampleCount, nullptr));
|
||||
if (!surface) {
|
||||
continue;
|
||||
|
@ -25,7 +25,8 @@ DEF_GPUTEST_FOR_NULL_CONTEXT(GrSurface, reporter, context) {
|
||||
desc.fWidth = 256;
|
||||
desc.fHeight = 256;
|
||||
desc.fSampleCnt = 0;
|
||||
GrSurface* texRT1 = context->textureProvider()->createTexture(desc, false, nullptr, 0);
|
||||
GrSurface* texRT1 = context->textureProvider()->createTexture(
|
||||
desc, SkBudgeted::kNo, nullptr, 0);
|
||||
|
||||
REPORTER_ASSERT(reporter, texRT1 == texRT1->asRenderTarget());
|
||||
REPORTER_ASSERT(reporter, texRT1 == texRT1->asTexture());
|
||||
@ -37,7 +38,7 @@ DEF_GPUTEST_FOR_NULL_CONTEXT(GrSurface, reporter, context) {
|
||||
static_cast<GrSurface*>(texRT1->asTexture()));
|
||||
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
GrSurface* tex1 = context->textureProvider()->createTexture(desc, false, nullptr, 0);
|
||||
GrSurface* tex1 = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0);
|
||||
REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
|
||||
REPORTER_ASSERT(reporter, tex1 == tex1->asTexture());
|
||||
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTexture());
|
||||
|
@ -26,8 +26,10 @@ DEF_GPUTEST_FOR_NULL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, context)
|
||||
desc.fWidth = 256;
|
||||
desc.fHeight = 256;
|
||||
desc.fSampleCnt = 0;
|
||||
GrSurface* texRT1 = context->textureProvider()->createTexture(desc, false, nullptr, 0);
|
||||
GrSurface* texRT2 = context->textureProvider()->createTexture(desc, false, nullptr, 0);
|
||||
GrSurface* texRT1 = context->textureProvider()->createTexture(
|
||||
desc, SkBudgeted::kNo, nullptr, 0);
|
||||
GrSurface* texRT2 = context->textureProvider()->createTexture(
|
||||
desc, SkBudgeted::kNo, nullptr, 0);
|
||||
REPORTER_ASSERT(reporter, nullptr != texRT1);
|
||||
REPORTER_ASSERT(reporter, nullptr != texRT2);
|
||||
GrTexture* tex = texRT1->asTexture();
|
||||
|
@ -184,7 +184,7 @@ static GrTexture* create_texture(GrContext* context) {
|
||||
desc.fWidth = kFullSize;
|
||||
desc.fHeight = kFullSize;
|
||||
|
||||
return context->textureProvider()->createTexture(desc, false, srcBM.getPixels(), 0);
|
||||
return context->textureProvider()->createTexture(desc, SkBudgeted::kNo, srcBM.getPixels(), 0);
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, context) {
|
||||
|
@ -1329,7 +1329,7 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(ImageFilterCropRect_Gpu, reporter, context) {
|
||||
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkSurface::kNo_Budgeted,
|
||||
SkBudgeted::kNo,
|
||||
SkImageInfo::MakeN32Premul(100, 100),
|
||||
0,
|
||||
&props,
|
||||
@ -1343,7 +1343,7 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(HugeBlurImageFilter_Gpu, reporter, context) {
|
||||
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkSurface::kNo_Budgeted,
|
||||
SkBudgeted::kNo,
|
||||
SkImageInfo::MakeN32Premul(100, 100),
|
||||
0,
|
||||
&props,
|
||||
@ -1357,7 +1357,7 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(XfermodeImageFilterCroppedInput_Gpu, reporter, co
|
||||
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkSurface::kNo_Budgeted,
|
||||
SkBudgeted::kNo,
|
||||
SkImageInfo::MakeN32Premul(1, 1),
|
||||
0,
|
||||
&props,
|
||||
@ -1371,7 +1371,7 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(TestNegativeBlurSigma_Gpu, reporter, context) {
|
||||
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkSurface::kNo_Budgeted,
|
||||
SkBudgeted::kNo,
|
||||
SkImageInfo::MakeN32Premul(1, 1),
|
||||
0,
|
||||
&props,
|
||||
@ -1383,7 +1383,7 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(TestNegativeBlurSigma_Gpu, reporter, context) {
|
||||
|
||||
DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
|
||||
SkAutoTUnref<SkSurface> surface(
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted,
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
|
||||
SkImageInfo::MakeN32Premul(100, 100)));
|
||||
test_large_blur_input(reporter, surface->getCanvas());
|
||||
}
|
||||
|
@ -68,12 +68,12 @@ DEF_TEST(ImageIsOpaqueTest, reporter) {
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageIsOpaqueTest_Gpu, reporter, context) {
|
||||
SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
|
||||
SkAutoTUnref<SkSurface> surfaceTransparent(
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, infoTransparent));
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kNo, infoTransparent));
|
||||
check_isopaque(reporter, surfaceTransparent, false);
|
||||
|
||||
SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
|
||||
SkAutoTUnref<SkSurface> surfaceOpaque(
|
||||
SkSurface::NewRenderTarget(context,SkSurface::kNo_Budgeted, infoOpaque));
|
||||
SkSurface::NewRenderTarget(context,SkBudgeted::kNo, infoOpaque));
|
||||
|
||||
check_isopaque(reporter, surfaceOpaque, true);
|
||||
}
|
||||
|
@ -116,9 +116,9 @@ void gpuToGpu(skiatest::Reporter* reporter, GrContext* context) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
|
||||
|
||||
SkAutoTUnref<SkSurface> sourceSurface(
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info));
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info));
|
||||
SkAutoTUnref<SkSurface> destinationSurface(
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info));
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info));
|
||||
|
||||
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
|
||||
}
|
||||
@ -127,7 +127,7 @@ void gpuToRaster(skiatest::Reporter* reporter, GrContext* context) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
|
||||
|
||||
SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRenderTarget(context,
|
||||
SkSurface::kNo_Budgeted, info));
|
||||
SkBudgeted::kNo, info));
|
||||
SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRaster(info));
|
||||
|
||||
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
|
||||
@ -138,7 +138,7 @@ void rasterToGpu(skiatest::Reporter* reporter, GrContext* context) {
|
||||
|
||||
SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRaster(info));
|
||||
SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(context,
|
||||
SkSurface::kNo_Budgeted, info));
|
||||
SkBudgeted::kNo, info));
|
||||
|
||||
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ static SkImage* create_codec_image() {
|
||||
#if SK_SUPPORT_GPU
|
||||
static SkImage* create_gpu_image(GrContext* context) {
|
||||
const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted,
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkBudgeted::kNo,
|
||||
info));
|
||||
draw_image_test_pattern(surface->getCanvas());
|
||||
return surface->newImageSnapshot();
|
||||
@ -696,7 +696,7 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(SkImage_NewFromTexture, reporter, context) {
|
||||
desc.fHeight = h;
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fSampleCnt = 0;
|
||||
SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, false, storage, w * 4));
|
||||
SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, SkBudgeted::kNo, storage, w * 4));
|
||||
if (!tex) {
|
||||
REPORTER_ASSERT(reporter, false);
|
||||
return;
|
||||
|
@ -109,7 +109,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PremulAlphaRoundTrip_Gpu, reporter, context)
|
||||
const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
|
||||
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
SkAutoTUnref<SkBaseDevice> device(
|
||||
SkGpuDevice::Create(context, SkSurface::kNo_Budgeted, info, 0, &props,
|
||||
SkGpuDevice::Create(context, SkBudgeted::kNo, info, 0, &props,
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
test_premul_alpha_roundtrip(reporter, device);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, context) {
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fOrigin = origin;
|
||||
SkAutoTUnref<GrTexture> surfaceTexture(
|
||||
context->textureProvider()->createTexture(desc, false));
|
||||
context->textureProvider()->createTexture(desc, SkBudgeted::kNo));
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(surfaceTexture->asRenderTarget()));
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
test_readpixels(reporter, surface, kLast_BitmapInit);
|
||||
@ -452,7 +452,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, context) {
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fOrigin = origin;
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
texture.reset(context->textureProvider()->createTexture(desc, false));
|
||||
texture.reset(context->textureProvider()->createTexture(desc, SkBudgeted::kNo));
|
||||
test_readpixels_texture(reporter, texture);
|
||||
}
|
||||
}
|
||||
@ -603,8 +603,8 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(ReadPixels_Subset_Gpu, reporter, context) {
|
||||
|
||||
// do they draw the same?
|
||||
const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
|
||||
SkAutoTUnref<SkSurface> surfA(SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0));
|
||||
SkAutoTUnref<SkSurface> surfB(SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0));
|
||||
SkAutoTUnref<SkSurface> surfA(SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0));
|
||||
SkAutoTUnref<SkSurface> surfB(SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0));
|
||||
|
||||
if (false) {
|
||||
//
|
||||
|
@ -50,7 +50,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, context) {
|
||||
// We are initializing the texture with zeros here
|
||||
memset(alphaData, 0, X_SIZE * Y_SIZE);
|
||||
SkAutoTUnref<GrTexture> texture(
|
||||
context->textureProvider()->createTexture(desc, false, alphaData, 0));
|
||||
context->textureProvider()->createTexture(desc, SkBudgeted::kNo , alphaData, 0));
|
||||
if (!texture) {
|
||||
if (!rt) {
|
||||
ERRORF(reporter, "Could not create alpha texture.");
|
||||
@ -150,7 +150,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, context) {
|
||||
}
|
||||
}
|
||||
SkAutoTUnref<GrTexture> texture(
|
||||
context->textureProvider()->createTexture(desc, false, rgbaData, 0));
|
||||
context->textureProvider()->createTexture(desc, SkBudgeted::kNo, rgbaData, 0));
|
||||
if (!texture) {
|
||||
// We always expect to be able to create a RGBA texture
|
||||
if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {
|
||||
|
@ -124,7 +124,8 @@ void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace
|
||||
desc.fHeight = kHeight;
|
||||
desc.fSampleCnt = 0;
|
||||
|
||||
texture.reset(context->textureProvider()->createTexture(desc, false, nullptr, 0));
|
||||
texture.reset(context->textureProvider()->createTexture(
|
||||
desc, SkBudgeted::kNo, nullptr, 0));
|
||||
layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight), false);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,8 @@ static void test_copy_surface_src(skiatest::Reporter* reporter, GrContext* conte
|
||||
copyDstDesc.fWidth = rectangleTexture->width();
|
||||
copyDstDesc.fHeight = rectangleTexture->height();
|
||||
copyDstDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture(copyDstDesc, true));
|
||||
SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture(
|
||||
copyDstDesc, SkBudgeted::kYes));
|
||||
context->copySurface(dst, rectangleTexture);
|
||||
test_read_pixels(reporter, context, dst, expectedPixelValues);
|
||||
}
|
||||
@ -78,8 +79,8 @@ static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* conte
|
||||
copySrcDesc.fWidth = rectangleTexture->width();
|
||||
copySrcDesc.fHeight = rectangleTexture->height();
|
||||
copySrcDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture(copySrcDesc, true,
|
||||
pixels.get(), 0));
|
||||
SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture(
|
||||
copySrcDesc, SkBudgeted::kYes, pixels.get(), 0));
|
||||
|
||||
context->copySurface(rectangleTexture, src);
|
||||
test_read_pixels(reporter, context, rectangleTexture, pixels.get());
|
||||
|
@ -38,7 +38,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheCache, reporter, context) {
|
||||
desc.fHeight = gHeight;
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight);
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context,
|
||||
SkSurface::kNo_Budgeted, info));
|
||||
SkBudgeted::kNo, info));
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
|
||||
const SkIRect size = SkIRect::MakeWH(gWidth, gHeight);
|
||||
@ -91,12 +91,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
|
||||
GrTextureProvider* cache = context->textureProvider();
|
||||
GrResourceProvider* resourceProvider = context->resourceProvider();
|
||||
// Test that two budgeted RTs with the same desc share a stencil buffer.
|
||||
SkAutoTUnref<GrTexture> smallRT0(cache->createTexture(smallDesc, true));
|
||||
SkAutoTUnref<GrTexture> smallRT0(cache->createTexture(smallDesc, SkBudgeted::kYes));
|
||||
if (smallRT0 && smallRT0->asRenderTarget()) {
|
||||
resourceProvider->attachStencilAttachment(smallRT0->asRenderTarget());
|
||||
}
|
||||
|
||||
SkAutoTUnref<GrTexture> smallRT1(cache->createTexture(smallDesc, true));
|
||||
SkAutoTUnref<GrTexture> smallRT1(cache->createTexture(smallDesc, SkBudgeted::kYes));
|
||||
if (smallRT1 && smallRT1->asRenderTarget()) {
|
||||
resourceProvider->attachStencilAttachment(smallRT1->asRenderTarget());
|
||||
}
|
||||
@ -108,7 +108,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
|
||||
resourceProvider->attachStencilAttachment(smallRT1->asRenderTarget()));
|
||||
|
||||
// An unbudgeted RT with the same desc should also share.
|
||||
SkAutoTUnref<GrTexture> smallRT2(cache->createTexture(smallDesc, false));
|
||||
SkAutoTUnref<GrTexture> smallRT2(cache->createTexture(smallDesc, SkBudgeted::kNo));
|
||||
if (smallRT2 && smallRT2->asRenderTarget()) {
|
||||
resourceProvider->attachStencilAttachment(smallRT2->asRenderTarget());
|
||||
}
|
||||
@ -125,7 +125,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
|
||||
bigDesc.fWidth = 400;
|
||||
bigDesc.fHeight = 200;
|
||||
bigDesc.fSampleCnt = 0;
|
||||
SkAutoTUnref<GrTexture> bigRT(cache->createTexture(bigDesc, false));
|
||||
SkAutoTUnref<GrTexture> bigRT(cache->createTexture(bigDesc, SkBudgeted::kNo));
|
||||
if (bigRT && bigRT->asRenderTarget()) {
|
||||
resourceProvider->attachStencilAttachment(bigRT->asRenderTarget());
|
||||
}
|
||||
@ -139,7 +139,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
|
||||
// An RT with a different sample count should not share.
|
||||
GrSurfaceDesc smallMSAADesc = smallDesc;
|
||||
smallMSAADesc.fSampleCnt = 4;
|
||||
SkAutoTUnref<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc, false));
|
||||
SkAutoTUnref<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc, SkBudgeted::kNo));
|
||||
if (smallMSAART0 && smallMSAART0->asRenderTarget()) {
|
||||
resourceProvider->attachStencilAttachment(smallMSAART0->asRenderTarget());
|
||||
}
|
||||
@ -155,7 +155,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
|
||||
resourceProvider->attachStencilAttachment(smallRT0->asRenderTarget()) !=
|
||||
resourceProvider->attachStencilAttachment(smallMSAART0->asRenderTarget()));
|
||||
// A second MSAA RT should share with the first MSAA RT.
|
||||
SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAADesc, false));
|
||||
SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAADesc, SkBudgeted::kNo));
|
||||
if (smallMSAART1 && smallMSAART1->asRenderTarget()) {
|
||||
resourceProvider->attachStencilAttachment(smallMSAART1->asRenderTarget());
|
||||
}
|
||||
@ -171,8 +171,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
|
||||
smallMSAART0 && smallMSAART0->asRenderTarget() &&
|
||||
smallMSAART0->asRenderTarget()->numColorSamples() < 8) {
|
||||
smallMSAADesc.fSampleCnt = 8;
|
||||
smallMSAART1.reset(cache->createTexture(smallMSAADesc, false));
|
||||
SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAADesc, false));
|
||||
smallMSAART1.reset(cache->createTexture(smallMSAADesc, SkBudgeted::kNo));
|
||||
SkAutoTUnref<GrTexture> smallMSAART1(
|
||||
cache->createTexture(smallMSAADesc, SkBudgeted::kNo));
|
||||
if (smallMSAART1 && smallMSAART1->asRenderTarget()) {
|
||||
resourceProvider->attachStencilAttachment(smallMSAART1->asRenderTarget());
|
||||
}
|
||||
@ -569,7 +570,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
|
||||
// Since this resource is unbudgeted, it should not be reachable as scratch.
|
||||
REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key);
|
||||
REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch());
|
||||
REPORTER_ASSERT(reporter, !resource->resourcePriv().isBudgeted());
|
||||
REPORTER_ASSERT(reporter, SkBudgeted::kNo == resource->resourcePriv().isBudgeted());
|
||||
REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(key, TestResource::kDefaultSize, 0));
|
||||
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, size == cache->getResourceBytes());
|
||||
@ -586,7 +587,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
|
||||
REPORTER_ASSERT(reporter, resource);
|
||||
REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key);
|
||||
REPORTER_ASSERT(reporter, resource->cacheAccess().isScratch());
|
||||
REPORTER_ASSERT(reporter, resource->resourcePriv().isBudgeted());
|
||||
REPORTER_ASSERT(reporter, SkBudgeted::kYes == resource->resourcePriv().isBudgeted());
|
||||
|
||||
if (0 == i) {
|
||||
// If made unbudgeted, it should return to original state: ref'ed and unbudgeted. Try
|
||||
@ -601,7 +602,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
|
||||
REPORTER_ASSERT(reporter, size == cache->getBudgetedResourceBytes());
|
||||
REPORTER_ASSERT(reporter, !resource->resourcePriv().getScratchKey().isValid());
|
||||
REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch());
|
||||
REPORTER_ASSERT(reporter, resource->resourcePriv().isBudgeted());
|
||||
REPORTER_ASSERT(reporter, SkBudgeted::kYes == resource->resourcePriv().isBudgeted());
|
||||
|
||||
// now when it is unrefed it should die since it has no key.
|
||||
resource->unref();
|
||||
|
@ -161,7 +161,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, context) {
|
||||
desc.fConfig = kSRGBA_8888_GrPixelConfig;
|
||||
if (context->caps()->isConfigRenderable(desc.fConfig, false) &&
|
||||
context->caps()->isConfigTexturable(desc.fConfig)) {
|
||||
SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture(desc, false));
|
||||
SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture(
|
||||
desc, SkBudgeted::kNo));
|
||||
if (!tex) {
|
||||
ERRORF(reporter, "Could not create SRGBA texture.");
|
||||
return;
|
||||
@ -200,7 +201,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, context) {
|
||||
}
|
||||
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
tex.reset(context->textureProvider()->createTexture(desc, false));
|
||||
tex.reset(context->textureProvider()->createTexture(desc, SkBudgeted::kNo));
|
||||
if (!tex) {
|
||||
ERRORF(reporter, "Could not create RGBA texture.");
|
||||
return;
|
||||
|
@ -135,7 +135,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, context) {
|
||||
desc.fWidth = kFullSize;
|
||||
desc.fHeight = kFullSize;
|
||||
|
||||
SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc, false,
|
||||
SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc, SkBudgeted::kNo,
|
||||
bm.getPixels(), 0));
|
||||
if (!texture) {
|
||||
return;
|
||||
|
@ -54,7 +54,7 @@ static SkSurface* create_gpu_surface(GrContext* context, SkAlphaType at = kPremu
|
||||
if (requestedInfo) {
|
||||
*requestedInfo = info;
|
||||
}
|
||||
return SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0, nullptr);
|
||||
return SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
|
||||
}
|
||||
static SkSurface* create_gpu_scratch_surface(GrContext* context,
|
||||
SkAlphaType at = kPremul_SkAlphaType,
|
||||
@ -63,7 +63,7 @@ static SkSurface* create_gpu_scratch_surface(GrContext* context,
|
||||
if (requestedInfo) {
|
||||
*requestedInfo = info;
|
||||
}
|
||||
return SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted, info, 0, nullptr);
|
||||
return SkSurface::NewRenderTarget(context, SkBudgeted::kYes, info, 0, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -77,7 +77,7 @@ DEF_TEST(SurfaceEmpty, reporter) {
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceEmpty_Gpu, reporter, context) {
|
||||
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
|
||||
REPORTER_ASSERT(reporter, nullptr ==
|
||||
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0, nullptr));
|
||||
SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -340,7 +340,7 @@ static void test_unique_image_snap(skiatest::Reporter* reporter, SkSurface* surf
|
||||
std::function<intptr_t(SkSurface*)> surfaceBackingStore) {
|
||||
std::function<intptr_t(SkImage*)> ibs = imageBackingStore;
|
||||
std::function<intptr_t(SkSurface*)> sbs = surfaceBackingStore;
|
||||
static const SkSurface::Budgeted kB = SkSurface::kNo_Budgeted;
|
||||
static const SkBudgeted kB = SkBudgeted::kNo;
|
||||
{
|
||||
SkAutoTUnref<SkImage> image(surface->newImageSnapshot(kB, SkSurface::kYes_ForceUnique));
|
||||
REPORTER_ASSERT(reporter, !same_image_surf(image, surface, ibs, sbs));
|
||||
@ -699,22 +699,18 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceGetTexture_Gpu, reporter, context) {
|
||||
#include "SkImage_Gpu.h"
|
||||
#include "SkSurface_Gpu.h"
|
||||
|
||||
static SkSurface::Budgeted is_budgeted(SkSurface* surf) {
|
||||
return ((SkSurface_Gpu*)surf)->getDevice()->accessRenderTarget()->resourcePriv().isBudgeted() ?
|
||||
SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted;
|
||||
static SkBudgeted is_budgeted(SkSurface* surf) {
|
||||
return ((SkSurface_Gpu*)surf)->getDevice()->accessRenderTarget()->resourcePriv().isBudgeted();
|
||||
}
|
||||
|
||||
static SkSurface::Budgeted is_budgeted(SkImage* image) {
|
||||
return ((SkImage_Gpu*)image)->getTexture()->resourcePriv().isBudgeted() ?
|
||||
SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted;
|
||||
static SkBudgeted is_budgeted(SkImage* image) {
|
||||
return ((SkImage_Gpu*)image)->getTexture()->resourcePriv().isBudgeted();
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBudget, reporter, context) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(8,8);
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
SkSurface::Budgeted sbudgeted = i ? SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted;
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
SkSurface::Budgeted ibudgeted = j ? SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted;
|
||||
for (auto sbudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
|
||||
for (auto ibudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
|
||||
SkAutoTUnref<SkSurface>
|
||||
surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0));
|
||||
SkASSERT(surface);
|
||||
|
@ -66,7 +66,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
|
||||
}
|
||||
|
||||
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPremul_SkAlphaType);
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info,
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info,
|
||||
0, &props));
|
||||
REPORTER_ASSERT(reporter, surface);
|
||||
if (!surface) {
|
||||
|
@ -67,7 +67,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTexture, reporter, context, glContext)
|
||||
grAllocator.fCtx = &allocator;
|
||||
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget(
|
||||
context, SkSurface_Gpu::kNo_Budgeted, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
|
||||
context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
|
||||
NULL, grAllocator));
|
||||
REPORTER_ASSERT(reporter, surface);
|
||||
GrGLuint id = allocator.m_mostRecentlyAllocatedStorage;
|
||||
@ -101,7 +101,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, context, glCo
|
||||
grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateTextureStorage;
|
||||
grAllocator.fCtx = &allocator;
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget(
|
||||
context, SkSurface_Gpu::kNo_Budgeted, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
|
||||
context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
|
||||
NULL, grAllocator));
|
||||
REPORTER_ASSERT(reporter, !surface);
|
||||
}
|
||||
|
@ -413,7 +413,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixels_Gpu, reporter, context) {
|
||||
desc.fHeight = DEV_H;
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fOrigin = origin;
|
||||
SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc, false));
|
||||
SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc,
|
||||
SkBudgeted::kNo));
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(texture->asRenderTarget()));
|
||||
test_write_pixels(reporter, surface);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
private:
|
||||
void setupOffScreen(SkCanvas* canvas) override {
|
||||
fOffScreen.reset(SkSurface::NewRenderTarget(canvas->getGrContext(),
|
||||
SkSurface::kNo_Budgeted,
|
||||
SkBudgeted::kNo,
|
||||
canvas->imageInfo(),
|
||||
fNumSamples,
|
||||
&this->surfaceProps()));
|
||||
|
@ -193,7 +193,7 @@ struct GPUTarget {
|
||||
0;
|
||||
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
fSurface.reset(SkSurface::NewRenderTarget(context,
|
||||
SkSurface::kNo_Budgeted, info,
|
||||
SkBudgeted::kNo, info,
|
||||
numSamples, &props));
|
||||
fGL = factory->getContextInfo(ctxType, ctxOptions).fGLContext;
|
||||
if (!fSurface.get()) {
|
||||
|
@ -174,7 +174,7 @@ SkSurface* createGPUSurface(Request* request) {
|
||||
kN32_SkColorType, kPremul_SkAlphaType);
|
||||
uint32_t flags = 0;
|
||||
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
SkSurface* surface = SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0,
|
||||
SkSurface* surface = SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0,
|
||||
&props);
|
||||
return surface;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user