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

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

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 months 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/clip_path_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 <string>
8
9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event_argument.h"
11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "ui/gfx/skia_util.h"
13
14 namespace cc {
15
16 ClipDisplayItem::ClipDisplayItem(gfx::Rect clip_rect,
17 const std::vector<SkRRect>& rounded_clip_rects)
18 : clip_rect_(clip_rect), rounded_clip_rects_(rounded_clip_rects) {
19 }
20
21 ClipDisplayItem::~ClipDisplayItem() {
22 }
23
24 void ClipDisplayItem::Raster(SkCanvas* canvas,
25 SkDrawPictureCallback* callback) const {
26 canvas->save();
27 canvas->clipRect(SkRect::MakeXYWH(clip_rect_.x(), clip_rect_.y(),
28 clip_rect_.width(), clip_rect_.height()));
29 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) {
30 if (rounded_clip_rects_[i].isRect()) {
31 canvas->clipRect(rounded_clip_rects_[i].rect());
32 } else {
33 bool antialiased = true;
34 canvas->clipRRect(rounded_clip_rects_[i], SkRegion::kIntersect_Op,
35 antialiased);
36 }
37 }
38 }
39
40 bool ClipDisplayItem::IsSuitableForGpuRasterization() const {
41 return true;
42 }
43
44 int ClipDisplayItem::ApproximateOpCount() const {
45 return 1;
46 }
47
48 size_t ClipDisplayItem::PictureMemoryUsage() const {
49 size_t total_size = sizeof(gfx::Rect);
50 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) {
51 total_size += sizeof(rounded_clip_rects_[i]);
52 }
53 return total_size;
54 }
55
56 void ClipDisplayItem::AsValueInto(base::trace_event::TracedValue* array) const {
57 std::string value = base::StringPrintf("ClipDisplayItem rect: [%s]",
58 clip_rect_.ToString().c_str());
59 for (const SkRRect& rounded_rect : rounded_clip_rects_) {
60 base::StringAppendF(
61 &value, " rounded_rect: [rect: [%s]",
62 gfx::SkRectToRectF(rounded_rect.rect()).ToString().c_str());
63 base::StringAppendF(&value, " radii: [");
64 SkVector upper_left_radius = rounded_rect.radii(SkRRect::kUpperLeft_Corner);
65 base::StringAppendF(&value, "[%f,%f],", upper_left_radius.x(),
66 upper_left_radius.y());
67 SkVector upper_right_radius =
68 rounded_rect.radii(SkRRect::kUpperRight_Corner);
69 base::StringAppendF(&value, " [%f,%f],", upper_right_radius.x(),
70 upper_right_radius.y());
71 SkVector lower_right_radius =
72 rounded_rect.radii(SkRRect::kLowerRight_Corner);
73 base::StringAppendF(&value, " [%f,%f],", lower_right_radius.x(),
74 lower_right_radius.y());
75 SkVector lower_left_radius = rounded_rect.radii(SkRRect::kLowerLeft_Corner);
76 base::StringAppendF(&value, " [%f,%f]]", lower_left_radius.x(),
77 lower_left_radius.y());
78 }
79 array->AppendString(value);
80 }
81
82 EndClipDisplayItem::EndClipDisplayItem() {
83 }
84
85 EndClipDisplayItem::~EndClipDisplayItem() {
86 }
87
88 void EndClipDisplayItem::Raster(SkCanvas* canvas,
89 SkDrawPictureCallback* callback) const {
90 canvas->restore();
91 }
92
93 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const {
94 return true;
95 }
96
97 int EndClipDisplayItem::ApproximateOpCount() const {
98 return 0;
99 }
100
101 size_t EndClipDisplayItem::PictureMemoryUsage() const {
102 return 0;
103 }
104
105 void EndClipDisplayItem::AsValueInto(
106 base::trace_event::TracedValue* array) const {
107 array->AppendString("EndClipDisplayItem");
108 }
109
110 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/clip_display_item.h ('k') | cc/resources/clip_path_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698