Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: cc/resources/clip_display_item.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/clip_display_item.h ('k') | cc/resources/display_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/resources/clip_display_item.h"
6
7 #include "third_party/skia/include/core/SkCanvas.h"
8
9 namespace cc {
10
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) {
14 }
15
16 ClipDisplayItem::~ClipDisplayItem() {
17 }
18
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);
31 }
32 }
33 }
34
35 bool ClipDisplayItem::IsSuitableForGpuRasterization() const {
36 return true;
37 }
38
39 int ClipDisplayItem::ApproximateOpCount() const {
40 return 1;
41 }
42
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]);
47 }
48 return total_size;
49 }
50
51 EndClipDisplayItem::EndClipDisplayItem() {
52 }
53
54 EndClipDisplayItem::~EndClipDisplayItem() {
55 }
56
57 void EndClipDisplayItem::Raster(SkCanvas* canvas,
58 SkDrawPictureCallback* callback) const {
59 canvas->restore();
60 }
61
62 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const {
63 return true;
64 }
65
66 int EndClipDisplayItem::ApproximateOpCount() const {
67 return 0;
68 }
69
70 size_t EndClipDisplayItem::PictureMemoryUsage() const {
71 return 0;
72 }
73
74 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/clip_display_item.h ('k') | cc/resources/display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698