Require budget decision when creating a RenderTarget SkSurface.
Restructure SkGpuDevice creation:
*SkSurfaceProps are optional.
*Use SkSurfaceProps to communicate DF text rather than a flag.
*Tell SkGpuDevice::Create whether RT comes from cache or not.
Review URL: https://codereview.chromium.org/848903004
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 4ec67ae..3089dc0 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -698,7 +698,8 @@
return;
}
- surface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL);
+ surface =
+ SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, imageSpec, 0, NULL);
} else
#endif
{
@@ -780,8 +781,10 @@
if (NULL == context) {
continue;
}
- surface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL);
- alternateSurface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL);
+ surface =
+ SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, imageSpec, 0, NULL);
+ alternateSurface =
+ SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, imageSpec, 0, NULL);
} else
#endif
{
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index 3e47a05..b86689f 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -56,8 +56,9 @@
for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(grContext, info,
- sampleCounts[i], NULL));
+ SkAutoTUnref<SkSurface> surface(
+ SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, info,
+ sampleCounts[i], NULL));
test_drawPathEmpty(reporter, surface->getCanvas());
}
}
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 4ffcc11..55499d7 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -1074,36 +1074,40 @@
DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
+ SkSurface::kNo_Budgeted,
SkImageInfo::MakeN32Premul(100, 100),
- gProps,
- 0));
+ 0,
+ &gProps));
test_crop_rects(device, reporter);
}
DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) {
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
+ SkSurface::kNo_Budgeted,
SkImageInfo::MakeN32Premul(100, 100),
- gProps,
- 0));
+ 0,
+ &gProps));
test_huge_blur(device, reporter);
}
DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) {
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
+ SkSurface::kNo_Budgeted,
SkImageInfo::MakeN32Premul(1, 1),
- gProps,
- 0));
+ 0,
+ &gProps));
test_xfermode_cropped_input(device, reporter);
}
DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) {
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
+ SkSurface::kNo_Budgeted,
SkImageInfo::MakeN32Premul(1, 1),
- gProps,
- 0));
+ 0,
+ &gProps));
test_negative_blur_sigma(device, reporter);
}
#endif
diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp
index 6d886d4..522bd94 100644
--- a/tests/ImageIsOpaqueTest.cpp
+++ b/tests/ImageIsOpaqueTest.cpp
@@ -80,11 +80,13 @@
}
SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRenderTarget(context, infoTransparent));
+ SkAutoTUnref<SkSurface> surfaceTransparent(
+ SkSurface::NewRenderTarget(context,SkSurface::kNo_Budgeted, infoTransparent));
check_isopaque(reporter, surfaceTransparent, false);
SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRenderTarget(context, infoOpaque));
+ SkAutoTUnref<SkSurface> surfaceOpaque(
+ SkSurface::NewRenderTarget(context,SkSurface::kNo_Budgeted, infoOpaque));
#if 0
// this is failing right now : TODO fix me
check_isopaque(reporter, surfaceOpaque, true);
diff --git a/tests/ImageNewShaderTest.cpp b/tests/ImageNewShaderTest.cpp
index 1bc77fb..c78b715 100644
--- a/tests/ImageNewShaderTest.cpp
+++ b/tests/ImageNewShaderTest.cpp
@@ -115,8 +115,10 @@
void gpuToGpu(skiatest::Reporter* reporter, GrContext* context) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRenderTarget(context, info));
- SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(context, info));
+ SkAutoTUnref<SkSurface> sourceSurface(
+ SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info));
+ SkAutoTUnref<SkSurface> destinationSurface(
+ SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info));
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
@@ -124,7 +126,8 @@
void gpuToRaster(skiatest::Reporter* reporter, GrContext* context) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRenderTarget(context, info));
+ SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRenderTarget(context,
+ SkSurface::kNo_Budgeted, info));
SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRaster(info));
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
@@ -134,7 +137,8 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRaster(info));
- SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(context, info));
+ SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(context,
+ SkSurface::kNo_Budgeted, info));
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index ce45f16..9f5d6ff 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -85,13 +85,12 @@
if (!GrContextFactory::IsRenderingGLContext(type)) {
continue;
}
- GrContext* context = factory->get(type);
- if (NULL == context) {
+ GrContext* ctx = factory->get(type);
+ if (NULL == ctx) {
continue;
}
-
- device.reset(SkGpuDevice::Create(context, info,
- SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType), 0));
+ SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ device.reset(SkGpuDevice::Create(ctx, SkSurface::kNo_Budgeted, info, 0, &props));
#else
continue;
#endif
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 6bcc51f..966bc7f 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -82,8 +82,8 @@
REPORTER_ASSERT(reporter, match);
// Now try writing on the single channel texture
- SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderTarget(),
- SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)));
+ SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderTarget(), &props));
SkCanvas canvas(device);
SkPaint paint;
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 8639626..e51b3e0 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -797,7 +797,8 @@
desc.fWidth = gWidth;
desc.fHeight = gHeight;
SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, info));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context,
+ SkSurface::kNo_Budgeted, info));
test_cache(reporter, context, surface->getCanvas());
}
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index c09d97c..4816ffc 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -50,15 +50,9 @@
release_storage, storage);
}
case kGpu_SurfaceType:
-#if SK_SUPPORT_GPU
- return context ? SkSurface::NewRenderTarget(context, info, 0, NULL) : NULL;
-#endif
- break;
+ return SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0, NULL);
case kGpuScratch_SurfaceType:
-#if SK_SUPPORT_GPU
- return context ? SkSurface::NewScratchRenderTarget(context, info) : NULL;
-#endif
- break;
+ return SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted, info, 0, NULL);
}
return NULL;
}
@@ -94,8 +88,8 @@
REPORTER_ASSERT(reporter, NULL == SkSurface::NewRaster(info));
REPORTER_ASSERT(reporter, NULL == SkSurface::NewRasterDirect(info, NULL, 0));
if (ctx) {
- REPORTER_ASSERT(reporter, NULL == SkSurface::NewRenderTarget(ctx, info, 0, NULL));
- REPORTER_ASSERT(reporter, NULL == SkSurface::NewScratchRenderTarget(ctx, info, 0, NULL));
+ REPORTER_ASSERT(reporter, NULL ==
+ SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info, 0, NULL));
}
}
@@ -129,7 +123,8 @@
case kRasterData_ImageType:
return SkImage::NewRasterData(info, data, rowBytes);
case kGpu_ImageType: {
- SkAutoTUnref<SkSurface> surf(SkSurface::NewRenderTarget(context, info, 0));
+ SkAutoTUnref<SkSurface> surf(
+ SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0));
surf->getCanvas()->clear(color);
return surf->newImageSnapshot();
}