Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: cc/playback/float_clip_display_item.cc

Issue 1521373005: Revert of cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/playback/float_clip_display_item.h ('k') | cc/playback/transform_display_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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/gfx_conversions.h" 10 #include "cc/proto/gfx_conversions.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "ui/gfx/skia_util.h" 12 #include "ui/gfx/skia_util.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 FloatClipDisplayItem::FloatClipDisplayItem(const gfx::RectF& clip_rect) { 16 FloatClipDisplayItem::FloatClipDisplayItem() {
17 SetNew(clip_rect);
18 }
19
20 FloatClipDisplayItem::FloatClipDisplayItem(const proto::DisplayItem& proto) {
21 DCHECK_EQ(proto::DisplayItem::Type_FloatClip, proto.type());
22
23 const proto::FloatClipDisplayItem& details = proto.float_clip_item();
24 gfx::RectF clip_rect = ProtoToRectF(details.clip_rect());
25
26 SetNew(clip_rect);
27 } 17 }
28 18
29 FloatClipDisplayItem::~FloatClipDisplayItem() { 19 FloatClipDisplayItem::~FloatClipDisplayItem() {
30 } 20 }
31 21
32 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { 22 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) {
33 clip_rect_ = clip_rect; 23 clip_rect_ = clip_rect;
24
25 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
26 0 /* external_memory_usage */);
34 } 27 }
35 28
36 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 29 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
37 proto->set_type(proto::DisplayItem::Type_FloatClip); 30 proto->set_type(proto::DisplayItem::Type_FloatClip);
38 31
39 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item(); 32 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item();
40 RectFToProto(clip_rect_, details->mutable_clip_rect()); 33 RectFToProto(clip_rect_, details->mutable_clip_rect());
41 } 34 }
42 35
36 void FloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
37 DCHECK_EQ(proto::DisplayItem::Type_FloatClip, proto.type());
38
39 const proto::FloatClipDisplayItem& details = proto.float_clip_item();
40 gfx::RectF clip_rect = ProtoToRectF(details.clip_rect());
41
42 SetNew(clip_rect);
43 }
44
43 void FloatClipDisplayItem::Raster(SkCanvas* canvas, 45 void FloatClipDisplayItem::Raster(SkCanvas* canvas,
44 const gfx::Rect& canvas_target_playback_rect, 46 const gfx::Rect& canvas_target_playback_rect,
45 SkPicture::AbortCallback* callback) const { 47 SkPicture::AbortCallback* callback) const {
46 canvas->save(); 48 canvas->save();
47 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); 49 canvas->clipRect(gfx::RectFToSkRect(clip_rect_));
48 } 50 }
49 51
50 void FloatClipDisplayItem::AsValueInto( 52 void FloatClipDisplayItem::AsValueInto(
51 const gfx::Rect& visual_rect, 53 const gfx::Rect& visual_rect,
52 base::trace_event::TracedValue* array) const { 54 base::trace_event::TracedValue* array) const {
53 array->AppendString(base::StringPrintf( 55 array->AppendString(base::StringPrintf(
54 "FloatClipDisplayItem rect: [%s] visualRect: [%s]", 56 "FloatClipDisplayItem rect: [%s] visualRect: [%s]",
55 clip_rect_.ToString().c_str(), visual_rect.ToString().c_str())); 57 clip_rect_.ToString().c_str(), visual_rect.ToString().c_str()));
56 } 58 }
57 59
58 size_t FloatClipDisplayItem::ExternalMemoryUsage() const { 60 EndFloatClipDisplayItem::EndFloatClipDisplayItem() {
59 return 0; 61 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
60 } 62 0 /* external_memory_usage */);
61
62 EndFloatClipDisplayItem::EndFloatClipDisplayItem() {}
63
64 EndFloatClipDisplayItem::EndFloatClipDisplayItem(
65 const proto::DisplayItem& proto) {
66 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type());
67 } 63 }
68 64
69 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { 65 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() {
70 } 66 }
71 67
72 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 68 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
73 proto->set_type(proto::DisplayItem::Type_EndFloatClip); 69 proto->set_type(proto::DisplayItem::Type_EndFloatClip);
74 } 70 }
75 71
72 void EndFloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
73 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type());
74 }
75
76 void EndFloatClipDisplayItem::Raster( 76 void EndFloatClipDisplayItem::Raster(
77 SkCanvas* canvas, 77 SkCanvas* canvas,
78 const gfx::Rect& canvas_target_playback_rect, 78 const gfx::Rect& canvas_target_playback_rect,
79 SkPicture::AbortCallback* callback) const { 79 SkPicture::AbortCallback* callback) const {
80 canvas->restore(); 80 canvas->restore();
81 } 81 }
82 82
83 void EndFloatClipDisplayItem::AsValueInto( 83 void EndFloatClipDisplayItem::AsValueInto(
84 const gfx::Rect& visual_rect, 84 const gfx::Rect& visual_rect,
85 base::trace_event::TracedValue* array) const { 85 base::trace_event::TracedValue* array) const {
86 array->AppendString( 86 array->AppendString(
87 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]", 87 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]",
88 visual_rect.ToString().c_str())); 88 visual_rect.ToString().c_str()));
89 } 89 }
90 90
91 size_t EndFloatClipDisplayItem::ExternalMemoryUsage() const {
92 return 0;
93 }
94
95 } // namespace cc 91 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/float_clip_display_item.h ('k') | cc/playback/transform_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698