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.
5 #include "cc/resources/clip_display_item.h"
7 #include "third_party/skia/include/core/SkCanvas.h"
11 ClipDisplayItem::ClipDisplayItem(gfx::Rect clip_rect
,
12 const std::vector
<SkRRect
>& rounded_clip_rects
)
13 : clip_rect_(clip_rect
), rounded_clip_rects_(rounded_clip_rects
) {
16 ClipDisplayItem::~ClipDisplayItem() {
19 void ClipDisplayItem::Raster(SkCanvas
* canvas
,
20 SkDrawPictureCallback
* callback
) const {
22 canvas
->clipRect(SkRect::MakeXYWH(clip_rect_
.x(), clip_rect_
.y(),
23 clip_rect_
.width(), clip_rect_
.height()));
24 for (size_t i
= 0; i
< rounded_clip_rects_
.size(); ++i
) {
25 if (rounded_clip_rects_
[i
].isRect()) {
26 canvas
->clipRect(rounded_clip_rects_
[i
].rect());
28 bool antialiased
= true;
29 canvas
->clipRRect(rounded_clip_rects_
[i
], SkRegion::kIntersect_Op
,
35 bool ClipDisplayItem::IsSuitableForGpuRasterization() const {
39 int ClipDisplayItem::ApproximateOpCount() const {
43 size_t ClipDisplayItem::PictureMemoryUsage() const {
44 size_t total_size
= sizeof(gfx::Rect
);
45 for (size_t i
= 0; i
< rounded_clip_rects_
.size(); ++i
) {
46 total_size
+= sizeof(rounded_clip_rects_
[i
]);
51 EndClipDisplayItem::EndClipDisplayItem() {
54 EndClipDisplayItem::~EndClipDisplayItem() {
57 void EndClipDisplayItem::Raster(SkCanvas
* canvas
,
58 SkDrawPictureCallback
* callback
) const {
62 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const {
66 int EndClipDisplayItem::ApproximateOpCount() const {
70 size_t EndClipDisplayItem::PictureMemoryUsage() const {