| 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 #include "skia/ext/cdl_canvas.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 | 18 |
| 18 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path, | 19 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path, |
| 19 SkRegion::Op clip_op, | 20 SkRegion::Op clip_op, |
| 20 bool antialias) { | 21 bool antialias) { |
| 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) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 59 |
| 59 // Just use skia's serialization method for the SkPath for now. | 60 // Just use skia's serialization method for the SkPath for now. |
| 60 size_t path_size = clip_path_.writeToMemory(nullptr); | 61 size_t path_size = clip_path_.writeToMemory(nullptr); |
| 61 if (path_size > 0) { | 62 if (path_size > 0) { |
| 62 std::unique_ptr<uint8_t[]> buffer(new uint8_t[path_size]); | 63 std::unique_ptr<uint8_t[]> buffer(new uint8_t[path_size]); |
| 63 clip_path_.writeToMemory(buffer.get()); | 64 clip_path_.writeToMemory(buffer.get()); |
| 64 details->set_clip_path(buffer.get(), path_size); | 65 details->set_clip_path(buffer.get(), path_size); |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 | 68 |
| 68 void ClipPathDisplayItem::Raster(SkCanvas* canvas, | 69 void ClipPathDisplayItem::Raster(CdlCanvas* canvas, |
| 69 SkPicture::AbortCallback* callback) const { | 70 SkPicture::AbortCallback* callback) const { |
| 70 canvas->save(); | 71 canvas->save(); |
| 71 canvas->clipPath(clip_path_, clip_op_, antialias_); | 72 canvas->clipPath(clip_path_, clip_op_, antialias_); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void ClipPathDisplayItem::AsValueInto( | 75 void ClipPathDisplayItem::AsValueInto( |
| 75 const gfx::Rect& visual_rect, | 76 const gfx::Rect& visual_rect, |
| 76 base::trace_event::TracedValue* array) const { | 77 base::trace_event::TracedValue* array) const { |
| 77 array->AppendString(base::StringPrintf( | 78 array->AppendString(base::StringPrintf( |
| 78 "ClipPathDisplayItem length: %d visualRect: [%s]", | 79 "ClipPathDisplayItem length: %d visualRect: [%s]", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 92 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); | 93 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 EndClipPathDisplayItem::~EndClipPathDisplayItem() { | 96 EndClipPathDisplayItem::~EndClipPathDisplayItem() { |
| 96 } | 97 } |
| 97 | 98 |
| 98 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 99 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 99 proto->set_type(proto::DisplayItem::Type_EndClipPath); | 100 proto->set_type(proto::DisplayItem::Type_EndClipPath); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void EndClipPathDisplayItem::Raster( | 103 void EndClipPathDisplayItem::Raster(CdlCanvas* canvas, |
| 103 SkCanvas* canvas, | 104 SkPicture::AbortCallback* callback) const { |
| 104 SkPicture::AbortCallback* callback) const { | |
| 105 canvas->restore(); | 105 canvas->restore(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void EndClipPathDisplayItem::AsValueInto( | 108 void EndClipPathDisplayItem::AsValueInto( |
| 109 const gfx::Rect& visual_rect, | 109 const gfx::Rect& visual_rect, |
| 110 base::trace_event::TracedValue* array) const { | 110 base::trace_event::TracedValue* array) const { |
| 111 array->AppendString( | 111 array->AppendString( |
| 112 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", | 112 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", |
| 113 visual_rect.ToString().c_str())); | 113 visual_rect.ToString().c_str())); |
| 114 } | 114 } |
| 115 | 115 |
| 116 size_t EndClipPathDisplayItem::ExternalMemoryUsage() const { | 116 size_t EndClipPathDisplayItem::ExternalMemoryUsage() const { |
| 117 return 0; | 117 return 0; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace cc | 120 } // namespace cc |
| OLD | NEW |