| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_path_display_item.h" | 5 #include "cc/playback/clip_path_display_item.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
| 12 #include "cc/proto/display_item.pb.h" | 12 #include "cc/proto/display_item.pb.h" |
| 13 #include "cc/proto/skia_conversions.h" | 13 #include "cc/proto/skia_conversions.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path, | 18 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path, |
| 19 SkClipOp clip_op, | 19 SkClipOp clip_op, |
| 20 bool antialias) { | 20 bool antialias) |
| 21 : DisplayItem(CLIP_PATH) { |
| 21 SetNew(clip_path, clip_op, antialias); | 22 SetNew(clip_path, clip_op, antialias); |
| 22 } | 23 } |
| 23 | 24 |
| 24 ClipPathDisplayItem::ClipPathDisplayItem(const proto::DisplayItem& proto) { | 25 ClipPathDisplayItem::ClipPathDisplayItem(const proto::DisplayItem& proto) |
| 26 : DisplayItem(CLIP_PATH) { |
| 25 DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type()); | 27 DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type()); |
| 26 | 28 |
| 27 const proto::ClipPathDisplayItem& details = proto.clip_path_item(); | 29 const proto::ClipPathDisplayItem& details = proto.clip_path_item(); |
| 28 SkClipOp clip_op = SkClipOpFromProto(details.clip_op()); | 30 SkClipOp clip_op = SkClipOpFromProto(details.clip_op()); |
| 29 bool antialias = details.antialias(); | 31 bool antialias = details.antialias(); |
| 30 | 32 |
| 31 SkPath clip_path; | 33 SkPath clip_path; |
| 32 if (details.has_clip_path()) { | 34 if (details.has_clip_path()) { |
| 33 size_t bytes_read = clip_path.readFromMemory(details.clip_path().data(), | 35 size_t bytes_read = clip_path.readFromMemory(details.clip_path().data(), |
| 34 details.clip_path().size()); | 36 details.clip_path().size()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 74 } |
| 73 | 75 |
| 74 void ClipPathDisplayItem::AsValueInto( | 76 void ClipPathDisplayItem::AsValueInto( |
| 75 const gfx::Rect& visual_rect, | 77 const gfx::Rect& visual_rect, |
| 76 base::trace_event::TracedValue* array) const { | 78 base::trace_event::TracedValue* array) const { |
| 77 array->AppendString(base::StringPrintf( | 79 array->AppendString(base::StringPrintf( |
| 78 "ClipPathDisplayItem length: %d visualRect: [%s]", | 80 "ClipPathDisplayItem length: %d visualRect: [%s]", |
| 79 clip_path_.countPoints(), visual_rect.ToString().c_str())); | 81 clip_path_.countPoints(), visual_rect.ToString().c_str())); |
| 80 } | 82 } |
| 81 | 83 |
| 82 size_t ClipPathDisplayItem::ExternalMemoryUsage() const { | 84 EndClipPathDisplayItem::EndClipPathDisplayItem() : DisplayItem(END_CLIP_PATH) {} |
| 83 // The size of SkPath's external storage is not currently accounted for (and | |
| 84 // may well be shared anyway). | |
| 85 return 0; | |
| 86 } | |
| 87 | 85 |
| 88 EndClipPathDisplayItem::EndClipPathDisplayItem() {} | 86 EndClipPathDisplayItem::EndClipPathDisplayItem(const proto::DisplayItem& proto) |
| 89 | 87 : DisplayItem(END_CLIP_PATH) { |
| 90 EndClipPathDisplayItem::EndClipPathDisplayItem( | |
| 91 const proto::DisplayItem& proto) { | |
| 92 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); | 88 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); |
| 93 } | 89 } |
| 94 | 90 |
| 95 EndClipPathDisplayItem::~EndClipPathDisplayItem() { | 91 EndClipPathDisplayItem::~EndClipPathDisplayItem() { |
| 96 } | 92 } |
| 97 | 93 |
| 98 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 94 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 99 proto->set_type(proto::DisplayItem::Type_EndClipPath); | 95 proto->set_type(proto::DisplayItem::Type_EndClipPath); |
| 100 } | 96 } |
| 101 | 97 |
| 102 void EndClipPathDisplayItem::Raster( | 98 void EndClipPathDisplayItem::Raster( |
| 103 SkCanvas* canvas, | 99 SkCanvas* canvas, |
| 104 SkPicture::AbortCallback* callback) const { | 100 SkPicture::AbortCallback* callback) const { |
| 105 canvas->restore(); | 101 canvas->restore(); |
| 106 } | 102 } |
| 107 | 103 |
| 108 void EndClipPathDisplayItem::AsValueInto( | 104 void EndClipPathDisplayItem::AsValueInto( |
| 109 const gfx::Rect& visual_rect, | 105 const gfx::Rect& visual_rect, |
| 110 base::trace_event::TracedValue* array) const { | 106 base::trace_event::TracedValue* array) const { |
| 111 array->AppendString( | 107 array->AppendString( |
| 112 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", | 108 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", |
| 113 visual_rect.ToString().c_str())); | 109 visual_rect.ToString().c_str())); |
| 114 } | 110 } |
| 115 | 111 |
| 116 size_t EndClipPathDisplayItem::ExternalMemoryUsage() const { | |
| 117 return 0; | |
| 118 } | |
| 119 | |
| 120 } // namespace cc | 112 } // namespace cc |
| OLD | NEW |