OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/playback/clip_display_item.h" | |
6 | |
7 #include <stddef.h> | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/logging.h" | |
12 #include "base/strings/stringprintf.h" | |
13 #include "base/trace_event/trace_event_argument.h" | |
14 #include "third_party/skia/include/core/SkCanvas.h" | |
15 #include "ui/gfx/skia_util.h" | |
16 | |
17 namespace cc { | |
18 class ImageSerializationProcessor; | |
19 | |
20 ClipDisplayItem::ClipDisplayItem(const gfx::Rect& clip_rect, | |
21 const std::vector<SkRRect>& rounded_clip_rects, | |
22 bool antialias) | |
23 : DisplayItem(CLIP) { | |
24 SetNew(clip_rect, rounded_clip_rects, antialias); | |
25 } | |
26 | |
27 void ClipDisplayItem::SetNew(const gfx::Rect& clip_rect, | |
28 const std::vector<SkRRect>& rounded_clip_rects, | |
29 bool antialias) { | |
30 clip_rect_ = clip_rect; | |
31 rounded_clip_rects_ = rounded_clip_rects; | |
32 antialias_ = antialias; | |
33 } | |
34 | |
35 ClipDisplayItem::~ClipDisplayItem() {} | |
36 | |
37 void ClipDisplayItem::Raster(SkCanvas* canvas, | |
38 SkPicture::AbortCallback* callback) const { | |
39 canvas->save(); | |
40 canvas->clipRect(gfx::RectToSkRect(clip_rect_), antialias_); | |
41 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { | |
42 if (rounded_clip_rects_[i].isRect()) { | |
43 canvas->clipRect(rounded_clip_rects_[i].rect(), antialias_); | |
44 } else { | |
45 canvas->clipRRect(rounded_clip_rects_[i], antialias_); | |
46 } | |
47 } | |
48 } | |
49 | |
50 EndClipDisplayItem::EndClipDisplayItem() : DisplayItem(END_CLIP) {} | |
51 | |
52 EndClipDisplayItem::~EndClipDisplayItem() { | |
53 } | |
54 | |
55 void EndClipDisplayItem::Raster(SkCanvas* canvas, | |
56 SkPicture::AbortCallback* callback) const { | |
57 canvas->restore(); | |
58 } | |
59 | |
60 } // namespace cc | |
OLD | NEW |