Add test for clicking bookmark star in presence of ctrl-D keybinding
[chromium-blink-merge.git] / cc / resources / clip_display_item.cc
blob731c6059122df0930ce340ad894ad464a5242175
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"
9 namespace cc {
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 {
21 canvas->save();
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());
27 } else {
28 bool antialiased = true;
29 canvas->clipRRect(rounded_clip_rects_[i], SkRegion::kIntersect_Op,
30 antialiased);
35 bool ClipDisplayItem::IsSuitableForGpuRasterization() const {
36 return true;
39 int ClipDisplayItem::ApproximateOpCount() const {
40 return 1;
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]);
48 return total_size;
51 EndClipDisplayItem::EndClipDisplayItem() {
54 EndClipDisplayItem::~EndClipDisplayItem() {
57 void EndClipDisplayItem::Raster(SkCanvas* canvas,
58 SkDrawPictureCallback* callback) const {
59 canvas->restore();
62 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const {
63 return true;
66 int EndClipDisplayItem::ApproximateOpCount() const {
67 return 0;
70 size_t EndClipDisplayItem::PictureMemoryUsage() const {
71 return 0;
74 } // namespace cc