robertphillips@google.com | 56bf6e4 | 2014-01-13 13:33:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkGatherPixelRefsAndRects.h" |
| 9 | #include "SkNoSaveLayerCanvas.h" |
| 10 | #include "SkPictureUtils.h" |
| 11 | |
| 12 | void SkPictureUtils::GatherPixelRefsAndRects(SkPicture* pict, |
| 13 | SkPictureUtils::SkPixelRefContainer* prCont) { |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 14 | if (pict->cullRect().isEmpty()) { |
robertphillips@google.com | 56bf6e4 | 2014-01-13 13:33:26 +0000 | [diff] [blame] | 15 | return ; |
| 16 | } |
| 17 | |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 18 | SkGatherPixelRefsAndRectsDevice device(SkScalarCeilToInt(pict->cullRect().width()), |
| 19 | SkScalarCeilToInt(pict->cullRect().height()), |
| 20 | prCont); |
robertphillips@google.com | 56bf6e4 | 2014-01-13 13:33:26 +0000 | [diff] [blame] | 21 | SkNoSaveLayerCanvas canvas(&device); |
| 22 | |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 23 | canvas.clipRect(pict->cullRect(), SkRegion::kIntersect_Op, false); |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 24 | canvas.drawPicture(pict); |
robertphillips@google.com | 56bf6e4 | 2014-01-13 13:33:26 +0000 | [diff] [blame] | 25 | } |