| 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 "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/trace_event/trace_event_argument.h" | 8 #include "base/trace_event/trace_event_argument.h" |
| 9 #include "cc/proto/display_item.pb.h" | 9 #include "cc/proto/display_item.pb.h" |
| 10 #include "cc/proto/skia_conversions.h" | 10 #include "cc/proto/skia_conversions.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 34 void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 35 proto->set_type(proto::DisplayItem::Type_ClipPath); | 35 proto->set_type(proto::DisplayItem::Type_ClipPath); |
| 36 | 36 |
| 37 proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item(); | 37 proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item(); |
| 38 details->set_clip_op(SkRegionOpToProto(clip_op_)); | 38 details->set_clip_op(SkRegionOpToProto(clip_op_)); |
| 39 details->set_antialias(antialias_); | 39 details->set_antialias(antialias_); |
| 40 | 40 |
| 41 // Just use skia's serialization method for the SkPath for now. | 41 // Just use skia's serialization method for the SkPath for now. |
| 42 size_t path_size = clip_path_.writeToMemory(nullptr); | 42 size_t path_size = clip_path_.writeToMemory(nullptr); |
| 43 if (path_size > 0) { | 43 if (path_size > 0) { |
| 44 scoped_ptr<char[]> buffer(new char[path_size]); | 44 scoped_ptr<uint8_t[]> buffer(new uint8_t[path_size]); |
| 45 clip_path_.writeToMemory(buffer.get()); | 45 clip_path_.writeToMemory(buffer.get()); |
| 46 details->set_clip_path(std::string(buffer.get(), path_size)); | 46 details->set_clip_path(buffer.get(), path_size); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void ClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { | 50 void ClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
| 51 DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type()); | 51 DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type()); |
| 52 | 52 |
| 53 const proto::ClipPathDisplayItem& details = proto.clip_path_item(); | 53 const proto::ClipPathDisplayItem& details = proto.clip_path_item(); |
| 54 SkRegion::Op clip_op = SkRegionOpFromProto(details.clip_op()); | 54 SkRegion::Op clip_op = SkRegionOpFromProto(details.clip_op()); |
| 55 bool antialias = details.antialias(); | 55 bool antialias = details.antialias(); |
| 56 | 56 |
| 57 SkPath clip_path; | 57 SkPath clip_path; |
| 58 if (details.has_clip_path()) { | 58 if (details.has_clip_path()) { |
| 59 size_t bytes_read = clip_path.readFromMemory(details.clip_path().c_str(), | 59 size_t bytes_read = clip_path.readFromMemory(details.clip_path().data(), |
| 60 details.clip_path().size()); | 60 details.clip_path().size()); |
| 61 DCHECK_EQ(details.clip_path().size(), bytes_read); | 61 DCHECK_EQ(details.clip_path().size(), bytes_read); |
| 62 } | 62 } |
| 63 | 63 |
| 64 SetNew(clip_path, clip_op, antialias); | 64 SetNew(clip_path, clip_op, antialias); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ClipPathDisplayItem::Raster(SkCanvas* canvas, | 67 void ClipPathDisplayItem::Raster(SkCanvas* canvas, |
| 68 const gfx::Rect& canvas_target_playback_rect, | 68 const gfx::Rect& canvas_target_playback_rect, |
| 69 SkPicture::AbortCallback* callback) const { | 69 SkPicture::AbortCallback* callback) const { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 99 SkPicture::AbortCallback* callback) const { | 99 SkPicture::AbortCallback* callback) const { |
| 100 canvas->restore(); | 100 canvas->restore(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void EndClipPathDisplayItem::AsValueInto( | 103 void EndClipPathDisplayItem::AsValueInto( |
| 104 base::trace_event::TracedValue* array) const { | 104 base::trace_event::TracedValue* array) const { |
| 105 array->AppendString("EndClipPathDisplayItem"); | 105 array->AppendString("EndClipPathDisplayItem"); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace cc | 108 } // namespace cc |
| OLD | NEW |