Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: tests/CanvasStateTest.cpp

Issue 168653002: Change device factories to take SkImageInfo instead of SkBitmap::Config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix PdfViewer Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils/SkPictureUtils.cpp ('k') | tests/GpuBitmapCopyTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasStateUtils.h" 10 #include "SkCanvasStateUtils.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 //////////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////////
181 181
182 class TestDrawFilter : public SkDrawFilter { 182 class TestDrawFilter : public SkDrawFilter {
183 public: 183 public:
184 virtual bool filter(SkPaint*, Type) SK_OVERRIDE { return true; } 184 virtual bool filter(SkPaint*, Type) SK_OVERRIDE { return true; }
185 }; 185 };
186 186
187 static void test_draw_filters(skiatest::Reporter* reporter) { 187 static void test_draw_filters(skiatest::Reporter* reporter) {
188 TestDrawFilter drawFilter; 188 TestDrawFilter drawFilter;
189 SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 10, 10); 189 SkBitmap bitmap;
190 SkCanvas canvas(&device); 190 bitmap.allocN32Pixels(10, 10);
191 SkCanvas canvas(bitmap);
191 192
192 canvas.setDrawFilter(&drawFilter); 193 canvas.setDrawFilter(&drawFilter);
193 194
194 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas); 195 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
195 REPORTER_ASSERT(reporter, state); 196 REPORTER_ASSERT(reporter, state);
196 SkCanvas* tmpCanvas = SkCanvasStateUtils::CreateFromCanvasState(state); 197 SkCanvas* tmpCanvas = SkCanvasStateUtils::CreateFromCanvasState(state);
197 REPORTER_ASSERT(reporter, tmpCanvas); 198 REPORTER_ASSERT(reporter, tmpCanvas);
198 199
199 REPORTER_ASSERT(reporter, NULL != canvas.getDrawFilter()); 200 REPORTER_ASSERT(reporter, NULL != canvas.getDrawFilter());
200 REPORTER_ASSERT(reporter, NULL == tmpCanvas->getDrawFilter()); 201 REPORTER_ASSERT(reporter, NULL == tmpCanvas->getDrawFilter());
201 202
202 tmpCanvas->unref(); 203 tmpCanvas->unref();
203 SkCanvasStateUtils::ReleaseCanvasState(state); 204 SkCanvasStateUtils::ReleaseCanvasState(state);
204 } 205 }
205 206
206 //////////////////////////////////////////////////////////////////////////////// 207 ////////////////////////////////////////////////////////////////////////////////
207 208
208 // we need this function to prevent SkError from printing to stdout 209 // we need this function to prevent SkError from printing to stdout
209 static void error_callback(SkError code, void* ctx) {} 210 static void error_callback(SkError code, void* ctx) {}
210 211
211 static void test_soft_clips(skiatest::Reporter* reporter) { 212 static void test_soft_clips(skiatest::Reporter* reporter) {
212 SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 10, 10); 213 SkBitmap bitmap;
213 SkCanvas canvas(&device); 214 bitmap.allocN32Pixels(10, 10);
215 SkCanvas canvas(bitmap);
214 216
215 SkRRect roundRect; 217 SkRRect roundRect;
216 roundRect.setOval(SkRect::MakeWH(5, 5)); 218 roundRect.setOval(SkRect::MakeWH(5, 5));
217 219
218 canvas.clipRRect(roundRect, SkRegion::kIntersect_Op, true); 220 canvas.clipRRect(roundRect, SkRegion::kIntersect_Op, true);
219 221
220 SkSetErrorCallback(error_callback, NULL); 222 SkSetErrorCallback(error_callback, NULL);
221 223
222 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas); 224 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
223 REPORTER_ASSERT(reporter, !state); 225 REPORTER_ASSERT(reporter, !state);
224 226
225 REPORTER_ASSERT(reporter, kInvalidOperation_SkError == SkGetLastError()); 227 REPORTER_ASSERT(reporter, kInvalidOperation_SkError == SkGetLastError());
226 SkClearLastError(); 228 SkClearLastError();
227 } 229 }
228 230
229 DEF_TEST(CanvasState, reporter) { 231 DEF_TEST(CanvasState, reporter) {
230 test_complex_layers(reporter); 232 test_complex_layers(reporter);
231 test_complex_clips(reporter); 233 test_complex_clips(reporter);
232 test_draw_filters(reporter); 234 test_draw_filters(reporter);
233 test_soft_clips(reporter); 235 test_soft_clips(reporter);
234 } 236 }
OLDNEW
« no previous file with comments | « src/utils/SkPictureUtils.cpp ('k') | tests/GpuBitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698