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" | |
14 #include "ui/gfx/skia_util.h" | 13 #include "ui/gfx/skia_util.h" |
15 | 14 |
16 namespace cc { | 15 namespace cc { |
17 | 16 |
18 FloatClipDisplayItem::FloatClipDisplayItem(const gfx::RectF& clip_rect) | 17 FloatClipDisplayItem::FloatClipDisplayItem(const gfx::RectF& clip_rect) |
19 : DisplayItem(FLOAT_CLIP) { | 18 : DisplayItem(FLOAT_CLIP) { |
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) |
(...skipping 13 matching lines...) Expand all Loading... |
37 clip_rect_ = clip_rect; | 36 clip_rect_ = clip_rect; |
38 } | 37 } |
39 | 38 |
40 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 39 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
41 proto->set_type(proto::DisplayItem::Type_FloatClip); | 40 proto->set_type(proto::DisplayItem::Type_FloatClip); |
42 | 41 |
43 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item(); | 42 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item(); |
44 RectFToProto(clip_rect_, details->mutable_clip_rect()); | 43 RectFToProto(clip_rect_, details->mutable_clip_rect()); |
45 } | 44 } |
46 | 45 |
47 void FloatClipDisplayItem::Raster(SkCanvas* canvas, | 46 void FloatClipDisplayItem::Raster(PaintCanvas* canvas, |
48 SkPicture::AbortCallback* callback) const { | 47 PaintRecord::AbortCallback* callback) const { |
49 canvas->save(); | 48 canvas->save(); |
50 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); | 49 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); |
51 } | 50 } |
52 | 51 |
53 void FloatClipDisplayItem::AsValueInto( | 52 void FloatClipDisplayItem::AsValueInto( |
54 const gfx::Rect& visual_rect, | 53 const gfx::Rect& visual_rect, |
55 base::trace_event::TracedValue* array) const { | 54 base::trace_event::TracedValue* array) const { |
56 array->AppendString(base::StringPrintf( | 55 array->AppendString(base::StringPrintf( |
57 "FloatClipDisplayItem rect: [%s] visualRect: [%s]", | 56 "FloatClipDisplayItem rect: [%s] visualRect: [%s]", |
58 clip_rect_.ToString().c_str(), visual_rect.ToString().c_str())); | 57 clip_rect_.ToString().c_str(), visual_rect.ToString().c_str())); |
59 } | 58 } |
60 | 59 |
61 EndFloatClipDisplayItem::EndFloatClipDisplayItem() | 60 EndFloatClipDisplayItem::EndFloatClipDisplayItem() |
62 : DisplayItem(END_FLOAT_CLIP) {} | 61 : DisplayItem(END_FLOAT_CLIP) {} |
63 | 62 |
64 EndFloatClipDisplayItem::EndFloatClipDisplayItem( | 63 EndFloatClipDisplayItem::EndFloatClipDisplayItem( |
65 const proto::DisplayItem& proto) | 64 const proto::DisplayItem& proto) |
66 : DisplayItem(END_FLOAT_CLIP) { | 65 : DisplayItem(END_FLOAT_CLIP) { |
67 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type()); | 66 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type()); |
68 } | 67 } |
69 | 68 |
70 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { | 69 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { |
71 } | 70 } |
72 | 71 |
73 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 72 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
74 proto->set_type(proto::DisplayItem::Type_EndFloatClip); | 73 proto->set_type(proto::DisplayItem::Type_EndFloatClip); |
75 } | 74 } |
76 | 75 |
77 void EndFloatClipDisplayItem::Raster( | 76 void EndFloatClipDisplayItem::Raster( |
78 SkCanvas* canvas, | 77 PaintCanvas* canvas, |
79 SkPicture::AbortCallback* callback) const { | 78 PaintRecord::AbortCallback* callback) const { |
80 canvas->restore(); | 79 canvas->restore(); |
81 } | 80 } |
82 | 81 |
83 void EndFloatClipDisplayItem::AsValueInto( | 82 void EndFloatClipDisplayItem::AsValueInto( |
84 const gfx::Rect& visual_rect, | 83 const gfx::Rect& visual_rect, |
85 base::trace_event::TracedValue* array) const { | 84 base::trace_event::TracedValue* array) const { |
86 array->AppendString( | 85 array->AppendString( |
87 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]", | 86 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]", |
88 visual_rect.ToString().c_str())); | 87 visual_rect.ToString().c_str())); |
89 } | 88 } |
90 | 89 |
91 } // namespace cc | 90 } // namespace cc |
OLD | NEW |