OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
| 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
9 #include "SamplePipeControllers.h" | 10 #include "SamplePipeControllers.h" |
10 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
11 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
12 #include "SkGPipe.h" | 13 #include "SkGPipe.h" |
13 #include "SkPaint.h" | 14 #include "SkPaint.h" |
14 #include "SkShader.h" | 15 #include "SkShader.h" |
15 #include "Test.h" | |
16 | 16 |
17 // Ensures that the pipe gracefully handles drawing an invalid bitmap. | 17 // Ensures that the pipe gracefully handles drawing an invalid bitmap. |
18 static void testDrawingBadBitmap(SkCanvas* pipeCanvas) { | 18 static void testDrawingBadBitmap(SkCanvas* pipeCanvas) { |
19 SkBitmap badBitmap; | 19 SkBitmap badBitmap; |
20 badBitmap.setConfig(SkBitmap::kNo_Config, 5, 5); | 20 badBitmap.setConfig(SkBitmap::kNo_Config, 5, 5); |
21 pipeCanvas->drawBitmap(badBitmap, 0, 0); | 21 pipeCanvas->drawBitmap(badBitmap, 0, 0); |
22 } | 22 } |
23 | 23 |
24 // Ensure that pipe gracefully handles attempting to draw after endRecording is
called on the | 24 // Ensure that pipe gracefully handles attempting to draw after endRecording is
called on the |
25 // SkGPipeWriter. | 25 // SkGPipeWriter. |
(...skipping 10 matching lines...) Expand all Loading... |
36 | 36 |
37 SkShader* shader = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMod
e, | 37 SkShader* shader = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMod
e, |
38 SkShader::kClamp_TileMode); | 38 SkShader::kClamp_TileMode); |
39 SkPaint paint; | 39 SkPaint paint; |
40 paint.setShader(shader)->unref(); | 40 paint.setShader(shader)->unref(); |
41 pipeCanvas->drawPaint(paint); | 41 pipeCanvas->drawPaint(paint); |
42 | 42 |
43 pipeCanvas->drawBitmap(bm, 0, 0); | 43 pipeCanvas->drawBitmap(bm, 0, 0); |
44 } | 44 } |
45 | 45 |
46 static void test_pipeTests(skiatest::Reporter*) { | 46 DEF_TEST(Pipe, reporter) { |
47 SkBitmap bitmap; | 47 SkBitmap bitmap; |
48 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 64, 64); | 48 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 64, 64); |
49 SkCanvas canvas(bitmap); | 49 SkCanvas canvas(bitmap); |
50 | 50 |
51 PipeController pipeController(&canvas); | 51 PipeController pipeController(&canvas); |
52 SkGPipeWriter writer; | 52 SkGPipeWriter writer; |
53 SkCanvas* pipeCanvas = writer.startRecording(&pipeController); | 53 SkCanvas* pipeCanvas = writer.startRecording(&pipeController); |
54 testDrawingBadBitmap(pipeCanvas); | 54 testDrawingBadBitmap(pipeCanvas); |
55 writer.endRecording(); | 55 writer.endRecording(); |
56 | 56 |
57 testDrawingAfterEndRecording(&canvas); | 57 testDrawingAfterEndRecording(&canvas); |
58 } | 58 } |
59 | |
60 #include "TestClassDef.h" | |
61 DEFINE_TESTCLASS("PipeTest", PipeTestClass, test_pipeTests) | |
OLD | NEW |