Commit bd500f09 authored by bsalomon's avatar bsalomon Committed by Commit bot
Browse files

Revert of Move Budgeted enum out of SkSurface, use in GrTextureProvider...

Revert of Move Budgeted enum out of SkSurface, use in GrTextureProvider (patchset #6 id:100001 of https://codereview.chromium.org/1728093005/ )

Reason for revert:
Need workaround for chrome to build

Original issue's description:
> 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

TBR=reed@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1734043002
parent 2d07b764
......@@ -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),
SkBudgeted::kNo, info,
SkSurface::kNo_Budgeted, 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(),
SkBudgeted::kNo,
SkSurface::kNo_Budgeted,
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), SkBudgeted::kNo,
return SkSurface::NewRenderTarget(grFactory->get(type, options), SkSurface::kNo_Budgeted,
info, samples, &props);
}
......
......@@ -112,7 +112,7 @@ int main() {
SkAutoTUnref<SkSurface> surface(
SkSurface::NewRenderTarget(
grContext,
SkBudgeted::kNo,
SkSurface::kNo_Budgeted,
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, SkBudgeted::kYes, pixels.get(), rowBytes));
SkAutoTUnref<GrTexture> texture(ctx->textureProvider()->createTexture(desc, true, 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, SkBudgeted::kNo,
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted,
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, SkBudgeted::kNo, info);
SkSurface* surface = SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info);
if (nullptr == surface) {
return;
......
......@@ -177,7 +177,7 @@ protected:
#if SK_SUPPORT_GPU
surf2.reset(SkSurface::NewRenderTarget(canvas->getGrContext(),
SkBudgeted::kNo, info));
SkSurface::kNo_Budgeted, 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, SkBudgeted::kNo, info));
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, 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, SkBudgeted::kYes,
SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted,
SkImageInfo::MakeN32Premul(kSize, kSize)));
if (!surface) {
return nullptr;
......
......@@ -211,7 +211,7 @@ public:
: SkImageGenerator(info)
, fCtx(SkRef(ctx))
{
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo,
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted,
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, SkBudgeted::kNo);
GrTexture* dst = fCtx->textureProvider()->createTexture(desc, false);
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,
SkBudgeted::kNo));
SkSurface::kNo_Budgeted));
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, SkBudgeted::kNo,
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted,
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, SkBudgeted::kYes, info, 0));
surface.reset(SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted, 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, SkBudgeted::kNo, info, 0, &props);
return SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, 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, SkBudgeted::kNo, gTextureData.get(), 0);
desc, false, 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, SkBudgeted::kNo, info, 0,
surface.reset(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, 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, SkBudgeted::kNo, info, 0, nullptr);
return SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0, nullptr);
#else
return nullptr;
#endif
......
......@@ -30,6 +30,18 @@ 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
};
/**
* Create a new surface, using the specified pixels/rowbytes as its
* backend.
......@@ -123,10 +135,10 @@ public:
* additional textures.
*/
static SkSurface* NewRenderTarget(
GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount,
const SkSurfaceProps* = NULL, GrTextureStorageAllocator = GrTextureStorageAllocator());
GrContext*, Budgeted, const SkImageInfo&, int sampleCount, const SkSurfaceProps* = NULL,
GrTextureStorageAllocator = GrTextureStorageAllocator());
static SkSurface* NewRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) {
static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageInfo& info) {
return NewRenderTarget(gr, b, info, 0);
}
......@@ -232,7 +244,7 @@ public:
* parameter controls whether it counts against the resource budget
* (currently for the gpu backend only).
*/
SkImage* newImageSnapshot(SkBudgeted = SkBudgeted::kYes);
SkImage* newImageSnapshot(Budgeted = kYes_Budgeted);
/**
* In rare instances a client may want a unique copy of the SkSurface's contents in an image
......@@ -244,7 +256,7 @@ public:
kNo_ForceUnique,
kYes_ForceUnique
};
SkImage* newImageSnapshot(SkBudgeted, ForceUnique);
SkImage* newImageSnapshot(Budgeted, ForceUnique);
/**
* Though the caller could get a snapshot image explicitly, and draw that,
......
......@@ -439,17 +439,6 @@ 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, SkBudgeted budgeted, const void* srcData,
GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, const void* srcData,
size_t rowBytes);
/** Shortcut for creating a texture with no initial data to upload. */
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted) {
GrTexture* createTexture(const GrSurfaceDesc& desc, bool 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, SkBudgeted::kYes);
return this->createTexture(desc, true);
}
}
......
......@@ -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, SkBudgeted::kNo, info));
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info));
if (!gpuSurface) {
SkDebugf("SkSurface::NewRenderTarget returned null\n");
return;
......
......@@ -1146,8 +1146,7 @@ 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(),
SkBudgeted::kYes));
SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture(srcRT->desc(), true));
context->copySurface(tex, srcRT);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment