Commit bb854e34 authored by rosca@adobe.com's avatar rosca@adobe.com

Use the factory to create SkGpuDevice objects.

SkGpuDevice constructors are deprecated and the factory should
be used instead when filters and blending require offscreen targets.

Extra NULL check added: for many reasons, something can go wrong
within GrGpuGL::onCreateTexture() and fail to create the backing
store's texture. Instead of crashing, we can handle this gracefully
and simply render the page without the blending applied.



BUG=359947

Review URL: https://codereview.chromium.org/315913002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275553 0039d316-1c4b-4281-b951-d872f2087c98
parent 65768440
......@@ -665,12 +665,18 @@ static SkBitmap ApplyImageFilter(
use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch);
skia::RefPtr<GrTexture> backing_store =
skia::AdoptRef(scratch_texture.detach());
if (backing_store.get() == NULL)
if (backing_store.get() == NULL) {
TRACE_EVENT_INSTANT0("cc",
"ApplyImageFilter scratch texture allocation failed",
TRACE_EVENT_SCOPE_THREAD);
return SkBitmap();
}
// Create a device and canvas using that backing store.
SkGpuDevice device(use_gr_context->context(), backing_store.get());
SkCanvas canvas(&device);
skia::RefPtr<SkGpuDevice> device =
skia::AdoptRef(SkGpuDevice::Create(backing_store->asRenderTarget()));
DCHECK(device.get());
SkCanvas canvas(device.get());
// Draw the source bitmap through the filter to the canvas.
SkPaint paint;
......@@ -688,7 +694,7 @@ static SkBitmap ApplyImageFilter(
// GL context again.
use_gr_context->context()->flush();
return device.accessBitmap(false);
return device->accessBitmap(false);
}
static SkBitmap ApplyBlendModeWithBackdrop(
......@@ -785,10 +791,19 @@ static SkBitmap ApplyBlendModeWithBackdrop(
use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch);
skia::RefPtr<GrTexture> backing_store =
skia::AdoptRef(scratch_texture.detach());
if (backing_store.get() == NULL) {
TRACE_EVENT_INSTANT0(
"cc",
"ApplyBlendModeWithBackdrop scratch texture allocation failed",
TRACE_EVENT_SCOPE_THREAD);
return source_bitmap_with_filters;
}
// Create a device and canvas using that backing store.
SkGpuDevice device(use_gr_context->context(), backing_store.get());
SkCanvas canvas(&device);
skia::RefPtr<SkGpuDevice> device =
skia::AdoptRef(SkGpuDevice::Create(backing_store->asRenderTarget()));
DCHECK(device.get());
SkCanvas canvas(device.get());
// Draw the source bitmap through the filter to the canvas.
canvas.clear(SK_ColorTRANSPARENT);
......@@ -802,7 +817,7 @@ static SkBitmap ApplyBlendModeWithBackdrop(
// GL context again.
use_gr_context->context()->flush();
return device.accessBitmap(false);
return device->accessBitmap(false);
}
scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters(
......
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