OLD | NEW |
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 "CanvasStateHelpers.h" | 8 #include "CanvasStateHelpers.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasStateUtils.h" | 10 #include "SkCanvasStateUtils.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // now we memcmp the two bitmaps | 245 // now we memcmp the two bitmaps |
246 REPORTER_ASSERT(reporter, bitmaps[0].getSize() == bitmaps[1].getSize()); | 246 REPORTER_ASSERT(reporter, bitmaps[0].getSize() == bitmaps[1].getSize()); |
247 REPORTER_ASSERT(reporter, !memcmp(bitmaps[0].getPixels(), | 247 REPORTER_ASSERT(reporter, !memcmp(bitmaps[0].getPixels(), |
248 bitmaps[1].getPixels(), | 248 bitmaps[1].getPixels(), |
249 bitmaps[0].getSize())); | 249 bitmaps[0].getSize())); |
250 } | 250 } |
251 #endif | 251 #endif |
252 | 252 |
253 //////////////////////////////////////////////////////////////////////////////// | 253 //////////////////////////////////////////////////////////////////////////////// |
254 | 254 |
| 255 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER |
| 256 |
255 class TestDrawFilter : public SkDrawFilter { | 257 class TestDrawFilter : public SkDrawFilter { |
256 public: | 258 public: |
257 bool filter(SkPaint*, Type) override { return true; } | 259 bool filter(SkPaint*, Type) override { return true; } |
258 }; | 260 }; |
259 | 261 |
260 DEF_TEST(CanvasState_test_draw_filters, reporter) { | 262 DEF_TEST(CanvasState_test_draw_filters, reporter) { |
261 TestDrawFilter drawFilter; | 263 TestDrawFilter drawFilter; |
262 SkBitmap bitmap; | 264 SkBitmap bitmap; |
263 bitmap.allocN32Pixels(10, 10); | 265 bitmap.allocN32Pixels(10, 10); |
264 SkCanvas canvas(bitmap); | 266 SkCanvas canvas(bitmap); |
265 | 267 |
266 canvas.setDrawFilter(&drawFilter); | 268 canvas.setDrawFilter(&drawFilter); |
267 | 269 |
268 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas); | 270 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas); |
269 REPORTER_ASSERT(reporter, state); | 271 REPORTER_ASSERT(reporter, state); |
270 SkCanvas* tmpCanvas = SkCanvasStateUtils::CreateFromCanvasState(state); | 272 SkCanvas* tmpCanvas = SkCanvasStateUtils::CreateFromCanvasState(state); |
271 REPORTER_ASSERT(reporter, tmpCanvas); | 273 REPORTER_ASSERT(reporter, tmpCanvas); |
272 | 274 |
273 REPORTER_ASSERT(reporter, canvas.getDrawFilter()); | 275 REPORTER_ASSERT(reporter, canvas.getDrawFilter()); |
274 REPORTER_ASSERT(reporter, nullptr == tmpCanvas->getDrawFilter()); | 276 REPORTER_ASSERT(reporter, nullptr == tmpCanvas->getDrawFilter()); |
275 | 277 |
276 tmpCanvas->unref(); | 278 tmpCanvas->unref(); |
277 SkCanvasStateUtils::ReleaseCanvasState(state); | 279 SkCanvasStateUtils::ReleaseCanvasState(state); |
278 } | 280 } |
279 | 281 |
| 282 #endif |
| 283 |
280 //////////////////////////////////////////////////////////////////////////////// | 284 //////////////////////////////////////////////////////////////////////////////// |
281 | 285 |
282 // we need this function to prevent SkError from printing to stdout | 286 // we need this function to prevent SkError from printing to stdout |
283 static void error_callback(SkError code, void* ctx) {} | 287 static void error_callback(SkError code, void* ctx) {} |
284 | 288 |
285 DEF_TEST(CanvasState_test_soft_clips, reporter) { | 289 DEF_TEST(CanvasState_test_soft_clips, reporter) { |
286 SkBitmap bitmap; | 290 SkBitmap bitmap; |
287 bitmap.allocN32Pixels(10, 10); | 291 bitmap.allocN32Pixels(10, 10); |
288 SkCanvas canvas(bitmap); | 292 SkCanvas canvas(bitmap); |
289 | 293 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // Check that saveLayer with the kClipToLayer_SaveFlag sets the clip | 339 // Check that saveLayer with the kClipToLayer_SaveFlag sets the clip |
336 // stack to the layer bounds. | 340 // stack to the layer bounds. |
337 canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_ClipLayer_SaveFlag); | 341 canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_ClipLayer_SaveFlag); |
338 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); | 342 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); |
339 REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH); | 343 REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH); |
340 REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT); | 344 REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT); |
341 | 345 |
342 canvas.restore(); | 346 canvas.restore(); |
343 } | 347 } |
344 #endif | 348 #endif |
OLD | NEW |