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/float_clip_display_item.h" | 5 #include "cc/playback/float_clip_display_item.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
11 #include "cc/proto/display_item.pb.h" | 11 #include "cc/proto/display_item.pb.h" |
12 #include "cc/proto/gfx_conversions.h" | 12 #include "cc/proto/gfx_conversions.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 class ImageSerializationProcessor; | |
18 | 17 |
19 FloatClipDisplayItem::FloatClipDisplayItem(const gfx::RectF& clip_rect) { | 18 FloatClipDisplayItem::FloatClipDisplayItem(const gfx::RectF& clip_rect) { |
20 SetNew(clip_rect); | 19 SetNew(clip_rect); |
21 } | 20 } |
22 | 21 |
23 FloatClipDisplayItem::FloatClipDisplayItem(const proto::DisplayItem& proto) { | 22 FloatClipDisplayItem::FloatClipDisplayItem(const proto::DisplayItem& proto) { |
24 DCHECK_EQ(proto::DisplayItem::Type_FloatClip, proto.type()); | 23 DCHECK_EQ(proto::DisplayItem::Type_FloatClip, proto.type()); |
25 | 24 |
26 const proto::FloatClipDisplayItem& details = proto.float_clip_item(); | 25 const proto::FloatClipDisplayItem& details = proto.float_clip_item(); |
27 gfx::RectF clip_rect = ProtoToRectF(details.clip_rect()); | 26 gfx::RectF clip_rect = ProtoToRectF(details.clip_rect()); |
28 | 27 |
29 SetNew(clip_rect); | 28 SetNew(clip_rect); |
30 } | 29 } |
31 | 30 |
32 FloatClipDisplayItem::~FloatClipDisplayItem() { | 31 FloatClipDisplayItem::~FloatClipDisplayItem() { |
33 } | 32 } |
34 | 33 |
35 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { | 34 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { |
36 clip_rect_ = clip_rect; | 35 clip_rect_ = clip_rect; |
37 } | 36 } |
38 | 37 |
39 void FloatClipDisplayItem::ToProtobuf( | 38 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
40 proto::DisplayItem* proto, | |
41 ImageSerializationProcessor* image_serialization_processor) const { | |
42 proto->set_type(proto::DisplayItem::Type_FloatClip); | 39 proto->set_type(proto::DisplayItem::Type_FloatClip); |
43 | 40 |
44 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item(); | 41 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item(); |
45 RectFToProto(clip_rect_, details->mutable_clip_rect()); | 42 RectFToProto(clip_rect_, details->mutable_clip_rect()); |
46 } | 43 } |
47 | 44 |
48 void FloatClipDisplayItem::Raster(SkCanvas* canvas, | 45 void FloatClipDisplayItem::Raster(SkCanvas* canvas, |
49 const gfx::Rect& canvas_target_playback_rect, | 46 const gfx::Rect& canvas_target_playback_rect, |
50 SkPicture::AbortCallback* callback) const { | 47 SkPicture::AbortCallback* callback) const { |
51 canvas->save(); | 48 canvas->save(); |
(...skipping 15 matching lines...) Expand all Loading... |
67 EndFloatClipDisplayItem::EndFloatClipDisplayItem() {} | 64 EndFloatClipDisplayItem::EndFloatClipDisplayItem() {} |
68 | 65 |
69 EndFloatClipDisplayItem::EndFloatClipDisplayItem( | 66 EndFloatClipDisplayItem::EndFloatClipDisplayItem( |
70 const proto::DisplayItem& proto) { | 67 const proto::DisplayItem& proto) { |
71 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type()); | 68 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type()); |
72 } | 69 } |
73 | 70 |
74 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { | 71 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { |
75 } | 72 } |
76 | 73 |
77 void EndFloatClipDisplayItem::ToProtobuf( | 74 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
78 proto::DisplayItem* proto, | |
79 ImageSerializationProcessor* image_serialization_processor) const { | |
80 proto->set_type(proto::DisplayItem::Type_EndFloatClip); | 75 proto->set_type(proto::DisplayItem::Type_EndFloatClip); |
81 } | 76 } |
82 | 77 |
83 void EndFloatClipDisplayItem::Raster( | 78 void EndFloatClipDisplayItem::Raster( |
84 SkCanvas* canvas, | 79 SkCanvas* canvas, |
85 const gfx::Rect& canvas_target_playback_rect, | 80 const gfx::Rect& canvas_target_playback_rect, |
86 SkPicture::AbortCallback* callback) const { | 81 SkPicture::AbortCallback* callback) const { |
87 canvas->restore(); | 82 canvas->restore(); |
88 } | 83 } |
89 | 84 |
90 void EndFloatClipDisplayItem::AsValueInto( | 85 void EndFloatClipDisplayItem::AsValueInto( |
91 const gfx::Rect& visual_rect, | 86 const gfx::Rect& visual_rect, |
92 base::trace_event::TracedValue* array) const { | 87 base::trace_event::TracedValue* array) const { |
93 array->AppendString( | 88 array->AppendString( |
94 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]", | 89 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]", |
95 visual_rect.ToString().c_str())); | 90 visual_rect.ToString().c_str())); |
96 } | 91 } |
97 | 92 |
98 size_t EndFloatClipDisplayItem::ExternalMemoryUsage() const { | 93 size_t EndFloatClipDisplayItem::ExternalMemoryUsage() const { |
99 return 0; | 94 return 0; |
100 } | 95 } |
101 | 96 |
102 } // namespace cc | 97 } // namespace cc |
OLD | NEW |