diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-14 20:38:28 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-14 20:38:28 +0000 |
commit | d5d158b325f05902ac845f2f7c8c65ffe6074257 (patch) | |
tree | dacc677f3e66af15527c3ed7a9a57a1315d6a807 /tests | |
parent | bda03db28935eef7f9a3aae05fdedca57cd984ad (diff) |
Ensure that Pipe does not crash when attempting to draw after endRecording.
Add a test for drawing a bitmap and a bitmapshader after endRecording.
BUG=https://code.google.com/p/skia/issues/detail?id=774&can=3
Test=PipeTest
Review URL: https://codereview.appspot.com/6459088
git-svn-id: http://skia.googlecode.com/svn/trunk@5099 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PipeTest.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/PipeTest.cpp b/tests/PipeTest.cpp index 37242232d4..7790c1695d 100644 --- a/tests/PipeTest.cpp +++ b/tests/PipeTest.cpp @@ -10,16 +10,40 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkGPipe.h" +#include "SkPaint.h" +#include "SkShader.h" #include "Test.h" // Ensures that the pipe gracefully handles drawing an invalid bitmap. -static void testDrawingBadBitmap(skiatest::Reporter* reporter, SkCanvas* pipeCanvas) { +static void testDrawingBadBitmap(SkCanvas* pipeCanvas) { SkBitmap badBitmap; badBitmap.setConfig(SkBitmap::kNo_Config, 5, 5); pipeCanvas->drawBitmap(badBitmap, 0, 0); } -static void test_pipeTests(skiatest::Reporter* reporter) { +// Ensure that pipe gracefully handles attempting to draw after endRecording is called on the +// SkGPipeWriter. +static void testDrawingAfterEndRecording(SkCanvas* canvas) { + PipeController pc(canvas); + SkGPipeWriter writer; + SkCanvas* pipeCanvas = writer.startRecording(&pc, SkGPipeWriter::kCrossProcess_Flag); + writer.endRecording(); + + SkBitmap bm; + bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); + bm.allocPixels(); + bm.eraseColor(0); + + SkShader* shader = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode, + SkShader::kClamp_TileMode); + SkPaint paint; + paint.setShader(shader)->unref(); + pipeCanvas->drawPaint(paint); + + pipeCanvas->drawBitmap(bm, 0, 0); +} + +static void test_pipeTests(skiatest::Reporter*) { SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, 64, 64); SkCanvas canvas(bitmap); @@ -27,8 +51,10 @@ static void test_pipeTests(skiatest::Reporter* reporter) { PipeController pipeController(&canvas); SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording(&pipeController); - testDrawingBadBitmap(reporter, pipeCanvas); + testDrawingBadBitmap(pipeCanvas); writer.endRecording(); + + testDrawingAfterEndRecording(&canvas); } #include "TestClassDef.h" |