| 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/playback/clip_display_item.h" | 5 #include "cc/playback/clip_display_item.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
| 14 #include "cc/proto/display_item.pb.h" | 14 #include "cc/proto/display_item.pb.h" |
| 15 #include "cc/proto/gfx_conversions.h" | 15 #include "cc/proto/gfx_conversions.h" |
| 16 #include "cc/proto/skia_conversions.h" | 16 #include "cc/proto/skia_conversions.h" |
| 17 #include "third_party/skia/include/core/SkCanvas.h" | 17 #include "third_party/skia/include/core/SkCanvas.h" |
| 18 #include "ui/gfx/skia_util.h" | 18 #include "ui/gfx/skia_util.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 class ImageSerializationProcessor; | 21 class ImageSerializationProcessor; |
| 22 | 22 |
| 23 ClipDisplayItem::ClipDisplayItem(const gfx::Rect& clip_rect, | 23 ClipDisplayItem::ClipDisplayItem(const gfx::Rect& clip_rect, |
| 24 const std::vector<SkRRect>& rounded_clip_rects, | 24 const std::vector<SkRRect>& rounded_clip_rects, |
| 25 bool antialias) { | 25 bool antialias) |
| 26 : DisplayItem(CLIP) { |
| 26 SetNew(clip_rect, rounded_clip_rects, antialias); | 27 SetNew(clip_rect, rounded_clip_rects, antialias); |
| 27 } | 28 } |
| 28 | 29 |
| 29 ClipDisplayItem::ClipDisplayItem(const proto::DisplayItem& proto) { | 30 ClipDisplayItem::ClipDisplayItem(const proto::DisplayItem& proto) |
| 31 : DisplayItem(CLIP) { |
| 30 DCHECK_EQ(proto::DisplayItem::Type_Clip, proto.type()); | 32 DCHECK_EQ(proto::DisplayItem::Type_Clip, proto.type()); |
| 31 | 33 |
| 32 const proto::ClipDisplayItem& details = proto.clip_item(); | 34 const proto::ClipDisplayItem& details = proto.clip_item(); |
| 33 gfx::Rect clip_rect = ProtoToRect(details.clip_rect()); | 35 gfx::Rect clip_rect = ProtoToRect(details.clip_rect()); |
| 34 std::vector<SkRRect> rounded_clip_rects; | 36 std::vector<SkRRect> rounded_clip_rects; |
| 35 rounded_clip_rects.reserve(details.rounded_rects_size()); | 37 rounded_clip_rects.reserve(details.rounded_rects_size()); |
| 36 for (int i = 0; i < details.rounded_rects_size(); i++) { | 38 for (int i = 0; i < details.rounded_rects_size(); i++) { |
| 37 rounded_clip_rects.push_back(ProtoToSkRRect(details.rounded_rects(i))); | 39 rounded_clip_rects.push_back(ProtoToSkRRect(details.rounded_rects(i))); |
| 38 } | 40 } |
| 39 bool antialias = details.antialias(); | 41 bool antialias = details.antialias(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 rounded_rect.radii(SkRRect::kLowerRight_Corner); | 98 rounded_rect.radii(SkRRect::kLowerRight_Corner); |
| 97 base::StringAppendF(&value, " [%f,%f],", lower_right_radius.x(), | 99 base::StringAppendF(&value, " [%f,%f],", lower_right_radius.x(), |
| 98 lower_right_radius.y()); | 100 lower_right_radius.y()); |
| 99 SkVector lower_left_radius = rounded_rect.radii(SkRRect::kLowerLeft_Corner); | 101 SkVector lower_left_radius = rounded_rect.radii(SkRRect::kLowerLeft_Corner); |
| 100 base::StringAppendF(&value, " [%f,%f]]", lower_left_radius.x(), | 102 base::StringAppendF(&value, " [%f,%f]]", lower_left_radius.x(), |
| 101 lower_left_radius.y()); | 103 lower_left_radius.y()); |
| 102 } | 104 } |
| 103 array->AppendString(value); | 105 array->AppendString(value); |
| 104 } | 106 } |
| 105 | 107 |
| 106 size_t ClipDisplayItem::ExternalMemoryUsage() const { | 108 EndClipDisplayItem::EndClipDisplayItem() : DisplayItem(END_CLIP) {} |
| 107 return rounded_clip_rects_.capacity() * sizeof(rounded_clip_rects_[0]); | |
| 108 } | |
| 109 | 109 |
| 110 EndClipDisplayItem::EndClipDisplayItem() {} | 110 EndClipDisplayItem::EndClipDisplayItem(const proto::DisplayItem& proto) |
| 111 | 111 : DisplayItem(END_CLIP) { |
| 112 EndClipDisplayItem::EndClipDisplayItem(const proto::DisplayItem& proto) { | |
| 113 DCHECK_EQ(proto::DisplayItem::Type_EndClip, proto.type()); | 112 DCHECK_EQ(proto::DisplayItem::Type_EndClip, proto.type()); |
| 114 } | 113 } |
| 115 | 114 |
| 116 EndClipDisplayItem::~EndClipDisplayItem() { | 115 EndClipDisplayItem::~EndClipDisplayItem() { |
| 117 } | 116 } |
| 118 | 117 |
| 119 void EndClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 118 void EndClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 120 proto->set_type(proto::DisplayItem::Type_EndClip); | 119 proto->set_type(proto::DisplayItem::Type_EndClip); |
| 121 } | 120 } |
| 122 | 121 |
| 123 void EndClipDisplayItem::Raster(SkCanvas* canvas, | 122 void EndClipDisplayItem::Raster(SkCanvas* canvas, |
| 124 SkPicture::AbortCallback* callback) const { | 123 SkPicture::AbortCallback* callback) const { |
| 125 canvas->restore(); | 124 canvas->restore(); |
| 126 } | 125 } |
| 127 | 126 |
| 128 void EndClipDisplayItem::AsValueInto( | 127 void EndClipDisplayItem::AsValueInto( |
| 129 const gfx::Rect& visual_rect, | 128 const gfx::Rect& visual_rect, |
| 130 base::trace_event::TracedValue* array) const { | 129 base::trace_event::TracedValue* array) const { |
| 131 array->AppendString(base::StringPrintf("EndClipDisplayItem visualRect: [%s]", | 130 array->AppendString(base::StringPrintf("EndClipDisplayItem visualRect: [%s]", |
| 132 visual_rect.ToString().c_str())); | 131 visual_rect.ToString().c_str())); |
| 133 } | 132 } |
| 134 | 133 |
| 135 size_t EndClipDisplayItem::ExternalMemoryUsage() const { | |
| 136 return 0; | |
| 137 } | |
| 138 | |
| 139 } // namespace cc | 134 } // namespace cc |
| OLD | NEW |