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

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

Issue 1407793002: Add protobuf serialization to DisplayItemList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_display2
Patch Set: Comments are hard Created 5 years, 1 month 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/filter_display_item.h ('k') | cc/playback/float_clip_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/filter_display_item.h" 5 #include "cc/playback/filter_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/output/render_surface_filters.h" 9 #include "cc/output/render_surface_filters.h"
10 #include "cc/proto/display_item.pb.h"
11 #include "cc/proto/gfx_conversions.h"
10 #include "skia/ext/refptr.h" 12 #include "skia/ext/refptr.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "third_party/skia/include/core/SkImageFilter.h" 14 #include "third_party/skia/include/core/SkImageFilter.h"
13 #include "third_party/skia/include/core/SkPaint.h" 15 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkXfermode.h" 16 #include "third_party/skia/include/core/SkXfermode.h"
15 #include "ui/gfx/skia_util.h" 17 #include "ui/gfx/skia_util.h"
16 18
17 namespace cc { 19 namespace cc {
18 20
19 FilterDisplayItem::FilterDisplayItem() { 21 FilterDisplayItem::FilterDisplayItem() {
20 } 22 }
21 23
22 FilterDisplayItem::~FilterDisplayItem() { 24 FilterDisplayItem::~FilterDisplayItem() {
23 } 25 }
24 26
25 void FilterDisplayItem::SetNew(const FilterOperations& filters, 27 void FilterDisplayItem::SetNew(const FilterOperations& filters,
26 const gfx::RectF& bounds) { 28 const gfx::RectF& bounds) {
27 filters_ = filters; 29 filters_ = filters;
28 bounds_ = bounds; 30 bounds_ = bounds;
29 31
30 // FilterOperations doesn't expose its capacity, but size is probably good 32 // FilterOperations doesn't expose its capacity, but size is probably good
31 // enough. 33 // enough.
32 size_t external_memory_usage = filters_.size() * sizeof(filters_.at(0)); 34 size_t external_memory_usage = filters_.size() * sizeof(filters_.at(0));
33 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, 35 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
34 external_memory_usage); 36 external_memory_usage);
35 } 37 }
36 38
39 void FilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
40 proto->set_type(proto::DisplayItem::Type_Filter);
41
42 proto::FilterDisplayItem* details = proto->mutable_filter_item();
43 RectFToProto(bounds_, details->mutable_bounds());
44
45 // TODO(dtrainor): Support serializing FilterOperations (crbug.com/541321).
46 }
47
48 void FilterDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
49 DCHECK_EQ(proto::DisplayItem::Type_Filter, proto.type());
50
51 const proto::FilterDisplayItem& details = proto.filter_item();
52 gfx::RectF bounds = ProtoToRectF(details.bounds());
53
54 // TODO(dtrainor): Support deserializing FilterOperations (crbug.com/541321).
55 FilterOperations filters;
56
57 SetNew(filters, bounds);
58 }
59
37 void FilterDisplayItem::Raster(SkCanvas* canvas, 60 void FilterDisplayItem::Raster(SkCanvas* canvas,
38 const gfx::Rect& canvas_target_playback_rect, 61 const gfx::Rect& canvas_target_playback_rect,
39 SkPicture::AbortCallback* callback) const { 62 SkPicture::AbortCallback* callback) const {
40 canvas->save(); 63 canvas->save();
41 canvas->translate(bounds_.x(), bounds_.y()); 64 canvas->translate(bounds_.x(), bounds_.y());
42 65
43 skia::RefPtr<SkImageFilter> image_filter = 66 skia::RefPtr<SkImageFilter> image_filter =
44 RenderSurfaceFilters::BuildImageFilter( 67 RenderSurfaceFilters::BuildImageFilter(
45 filters_, gfx::SizeF(bounds_.width(), bounds_.height())); 68 filters_, gfx::SizeF(bounds_.width(), bounds_.height()));
46 #ifdef SK_SAVE_LAYER_BOUNDS_ARE_FILTERED 69 #ifdef SK_SAVE_LAYER_BOUNDS_ARE_FILTERED
(...skipping 20 matching lines...) Expand all
67 } 90 }
68 91
69 EndFilterDisplayItem::EndFilterDisplayItem() { 92 EndFilterDisplayItem::EndFilterDisplayItem() {
70 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 93 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
71 0 /* external_memory_usage */); 94 0 /* external_memory_usage */);
72 } 95 }
73 96
74 EndFilterDisplayItem::~EndFilterDisplayItem() { 97 EndFilterDisplayItem::~EndFilterDisplayItem() {
75 } 98 }
76 99
100 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
101 proto->set_type(proto::DisplayItem::Type_EndFilter);
102 }
103
104 void EndFilterDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
105 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type());
106 }
107
77 void EndFilterDisplayItem::Raster(SkCanvas* canvas, 108 void EndFilterDisplayItem::Raster(SkCanvas* canvas,
78 const gfx::Rect& canvas_target_playback_rect, 109 const gfx::Rect& canvas_target_playback_rect,
79 SkPicture::AbortCallback* callback) const { 110 SkPicture::AbortCallback* callback) const {
80 canvas->restore(); 111 canvas->restore();
81 canvas->restore(); 112 canvas->restore();
82 } 113 }
83 114
84 void EndFilterDisplayItem::AsValueInto( 115 void EndFilterDisplayItem::AsValueInto(
85 base::trace_event::TracedValue* array) const { 116 base::trace_event::TracedValue* array) const {
86 array->AppendString("EndFilterDisplayItem"); 117 array->AppendString("EndFilterDisplayItem");
87 } 118 }
88 119
89 } // namespace cc 120 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/filter_display_item.h ('k') | cc/playback/float_clip_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698