diff options
author | 2013-04-15 18:15:23 +0000 | |
---|---|---|
committer | 2013-04-15 18:15:23 +0000 | |
commit | 9becf0090f9c1c14f42d161b9a1fb3af142f9420 (patch) | |
tree | a7c608d6d2068ed9b2766ba67570b121286f99d7 /tests/DeferredCanvasTest.cpp | |
parent | d2ef088ea3c0b32e1e97554d66b9f0b098aea9d8 (diff) |
Fix crash with SkDeferredCanvas+SkSurface integration with in order draw buffer.
The fImmediateDevice member of DeferredDevice (SkDeferredCanvas.cpp) was becoming invalid after a fork of the backingstore in SkSurface_Gpu cause the device to be substituted.
New unit test code was to exercise SkSurface copy on write with draws that are deferred in GrInOrderDrawBuffer. The bad pointer was causing the test to crash.
TEST=skia unit test DeferredCanvas, subtest TestDeferredCanvasSurface
Review URL: https://codereview.chromium.org/14263015
git-svn-id: http://skia.googlecode.com/svn/trunk@8686 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/DeferredCanvasTest.cpp')
-rw-r--r-- | tests/DeferredCanvasTest.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp index 2926ea9c92..3e73393d14 100644 --- a/tests/DeferredCanvasTest.cpp +++ b/tests/DeferredCanvasTest.cpp @@ -527,16 +527,25 @@ static void TestDeferredCanvasSurface(skiatest::Reporter* reporter, GrContextFac // write PixelPtr pixels2 = getSurfacePixelPtr(surface, useGpu); REPORTER_ASSERT(reporter, pixels1 != pixels2); - canvas.clear(SK_ColorWHITE); - canvas.flush(); + // Verify copy-on write with a draw operation that gets deferred by + // the in order draw buffer. + SkPaint paint; + canvas.drawPaint(paint); + SkImage* image4 = canvas.newImageSnapshot(); // implicit flush + SkAutoTUnref<SkImage> aur_i4(image4); + REPORTER_ASSERT(reporter, image4->uniqueID() != image3->uniqueID()); PixelPtr pixels3 = getSurfacePixelPtr(surface, useGpu); + REPORTER_ASSERT(reporter, pixels2 != pixels3); // Verify that a direct canvas flush with a pending draw does not trigger // a copy on write when the surface is not sharing its buffer with an // SkImage. - canvas.clear(SK_ColorBLACK); + canvas.clear(SK_ColorWHITE); canvas.flush(); PixelPtr pixels4 = getSurfacePixelPtr(surface, useGpu); - REPORTER_ASSERT(reporter, pixels3 == pixels4); + canvas.drawPaint(paint); + canvas.flush(); + PixelPtr pixels5 = getSurfacePixelPtr(surface, useGpu); + REPORTER_ASSERT(reporter, pixels4 == pixels5); } static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* factory) { |