OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/clip_display_item.h" | 5 #include "cc/resources/clip_display_item.h" |
6 | 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/trace_event_argument.h" |
7 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 #include "ui/gfx/skia_util.h" |
8 | 13 |
9 namespace cc { | 14 namespace cc { |
10 | 15 |
11 ClipDisplayItem::ClipDisplayItem(gfx::Rect clip_rect, | 16 ClipDisplayItem::ClipDisplayItem(gfx::Rect clip_rect, |
12 const std::vector<SkRRect>& rounded_clip_rects) | 17 const std::vector<SkRRect>& rounded_clip_rects) |
13 : clip_rect_(clip_rect), rounded_clip_rects_(rounded_clip_rects) { | 18 : clip_rect_(clip_rect), rounded_clip_rects_(rounded_clip_rects) { |
14 } | 19 } |
15 | 20 |
16 ClipDisplayItem::~ClipDisplayItem() { | 21 ClipDisplayItem::~ClipDisplayItem() { |
17 } | 22 } |
(...skipping 23 matching lines...) Expand all Loading... |
41 } | 46 } |
42 | 47 |
43 size_t ClipDisplayItem::PictureMemoryUsage() const { | 48 size_t ClipDisplayItem::PictureMemoryUsage() const { |
44 size_t total_size = sizeof(gfx::Rect); | 49 size_t total_size = sizeof(gfx::Rect); |
45 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { | 50 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { |
46 total_size += sizeof(rounded_clip_rects_[i]); | 51 total_size += sizeof(rounded_clip_rects_[i]); |
47 } | 52 } |
48 return total_size; | 53 return total_size; |
49 } | 54 } |
50 | 55 |
| 56 void ClipDisplayItem::AsValueInto(base::debug::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 |
51 EndClipDisplayItem::EndClipDisplayItem() { | 82 EndClipDisplayItem::EndClipDisplayItem() { |
52 } | 83 } |
53 | 84 |
54 EndClipDisplayItem::~EndClipDisplayItem() { | 85 EndClipDisplayItem::~EndClipDisplayItem() { |
55 } | 86 } |
56 | 87 |
57 void EndClipDisplayItem::Raster(SkCanvas* canvas, | 88 void EndClipDisplayItem::Raster(SkCanvas* canvas, |
58 SkDrawPictureCallback* callback) const { | 89 SkDrawPictureCallback* callback) const { |
59 canvas->restore(); | 90 canvas->restore(); |
60 } | 91 } |
61 | 92 |
62 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const { | 93 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const { |
63 return true; | 94 return true; |
64 } | 95 } |
65 | 96 |
66 int EndClipDisplayItem::ApproximateOpCount() const { | 97 int EndClipDisplayItem::ApproximateOpCount() const { |
67 return 0; | 98 return 0; |
68 } | 99 } |
69 | 100 |
70 size_t EndClipDisplayItem::PictureMemoryUsage() const { | 101 size_t EndClipDisplayItem::PictureMemoryUsage() const { |
71 return 0; | 102 return 0; |
72 } | 103 } |
73 | 104 |
| 105 void EndClipDisplayItem::AsValueInto(base::debug::TracedValue* array) const { |
| 106 array->AppendString("EndClipDisplayItem"); |
| 107 } |
| 108 |
74 } // namespace cc | 109 } // namespace cc |
OLD | NEW |