Chromium Code Reviews| 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 (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { | |
|
pdr.
2015/02/02 22:22:16
You can use a fancy c++11 iterator here to clean u
ajuma
2015/02/02 23:02:21
Done.
| |
| 60 base::StringAppendF( | |
| 61 &value, " rounded_rect: [rect: [%s]", | |
| 62 gfx::SkRectToRectF(rounded_clip_rects_[i].rect()).ToString().c_str()); | |
| 63 base::StringAppendF(&value, " radii: ["); | |
| 64 SkVector upper_left_radius = | |
| 65 rounded_clip_rects_[i].radii(SkRRect::kUpperLeft_Corner); | |
| 66 base::StringAppendF(&value, "[%f %f]", upper_left_radius.x(), | |
|
pdr.
2015/02/02 22:22:16
Can you double-check that the output of these is v
ajuma
2015/02/02 23:02:21
Added commas.
The overall output for the list is
| |
| 67 upper_left_radius.y()); | |
| 68 SkVector upper_right_radius = | |
| 69 rounded_clip_rects_[i].radii(SkRRect::kUpperRight_Corner); | |
| 70 base::StringAppendF(&value, " [%f %f]", upper_right_radius.x(), | |
| 71 upper_right_radius.y()); | |
| 72 SkVector lower_right_radius = | |
| 73 rounded_clip_rects_[i].radii(SkRRect::kLowerRight_Corner); | |
| 74 base::StringAppendF(&value, " [%f %f]", lower_right_radius.x(), | |
| 75 lower_right_radius.y()); | |
| 76 SkVector lower_left_radius = | |
| 77 rounded_clip_rects_[i].radii(SkRRect::kLowerLeft_Corner); | |
| 78 base::StringAppendF(&value, " [%f %f]]", lower_left_radius.x(), | |
| 79 lower_left_radius.y()); | |
| 80 } | |
| 81 array->AppendString(value); | |
| 82 } | |
| 83 | |
| 51 EndClipDisplayItem::EndClipDisplayItem() { | 84 EndClipDisplayItem::EndClipDisplayItem() { |
| 52 } | 85 } |
| 53 | 86 |
| 54 EndClipDisplayItem::~EndClipDisplayItem() { | 87 EndClipDisplayItem::~EndClipDisplayItem() { |
| 55 } | 88 } |
| 56 | 89 |
| 57 void EndClipDisplayItem::Raster(SkCanvas* canvas, | 90 void EndClipDisplayItem::Raster(SkCanvas* canvas, |
| 58 SkDrawPictureCallback* callback) const { | 91 SkDrawPictureCallback* callback) const { |
| 59 canvas->restore(); | 92 canvas->restore(); |
| 60 } | 93 } |
| 61 | 94 |
| 62 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const { | 95 bool EndClipDisplayItem::IsSuitableForGpuRasterization() const { |
| 63 return true; | 96 return true; |
| 64 } | 97 } |
| 65 | 98 |
| 66 int EndClipDisplayItem::ApproximateOpCount() const { | 99 int EndClipDisplayItem::ApproximateOpCount() const { |
| 67 return 0; | 100 return 0; |
| 68 } | 101 } |
| 69 | 102 |
| 70 size_t EndClipDisplayItem::PictureMemoryUsage() const { | 103 size_t EndClipDisplayItem::PictureMemoryUsage() const { |
| 71 return 0; | 104 return 0; |
| 72 } | 105 } |
| 73 | 106 |
| 107 void EndClipDisplayItem::AsValueInto(base::debug::TracedValue* array) const { | |
| 108 array->AppendString("EndClipDisplayItem"); | |
| 109 } | |
| 110 | |
| 74 } // namespace cc | 111 } // namespace cc |
| OLD | NEW |