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

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

Issue 2646623002: cc: Remove all blimp code from cc. (Closed)
Patch Set: test build Created 3 years, 11 months 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/clip_path_display_item.h ('k') | cc/playback/compositing_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/clip_path_display_item.h" 5 #include "cc/playback/clip_path_display_item.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/trace_event/trace_event_argument.h" 11 #include "base/trace_event/trace_event_argument.h"
12 #include "cc/proto/display_item.pb.h"
13 #include "cc/proto/skia_conversions.h"
14 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
15 13
16 namespace cc { 14 namespace cc {
17 15
18 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path, 16 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path,
19 bool antialias) 17 bool antialias)
20 : DisplayItem(CLIP_PATH) { 18 : DisplayItem(CLIP_PATH) {
21 SetNew(clip_path, antialias); 19 SetNew(clip_path, antialias);
22 } 20 }
23 21
24 ClipPathDisplayItem::ClipPathDisplayItem(const proto::DisplayItem& proto)
25 : DisplayItem(CLIP_PATH) {
26 DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type());
27
28 const proto::ClipPathDisplayItem& details = proto.clip_path_item();
29 bool antialias = details.antialias();
30
31 SkPath clip_path;
32 if (details.has_clip_path()) {
33 size_t bytes_read = clip_path.readFromMemory(details.clip_path().data(),
34 details.clip_path().size());
35 DCHECK_EQ(details.clip_path().size(), bytes_read);
36 }
37
38 SetNew(clip_path, antialias);
39 }
40
41 ClipPathDisplayItem::~ClipPathDisplayItem() { 22 ClipPathDisplayItem::~ClipPathDisplayItem() {
42 } 23 }
43 24
44 void ClipPathDisplayItem::SetNew(const SkPath& clip_path, 25 void ClipPathDisplayItem::SetNew(const SkPath& clip_path,
45 bool antialias) { 26 bool antialias) {
46 clip_path_ = clip_path; 27 clip_path_ = clip_path;
47 antialias_ = antialias; 28 antialias_ = antialias;
48 } 29 }
49 30
50 void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
51 proto->set_type(proto::DisplayItem::Type_ClipPath);
52
53 proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item();
54 details->set_antialias(antialias_);
55
56 // Just use skia's serialization method for the SkPath for now.
57 size_t path_size = clip_path_.writeToMemory(nullptr);
58 if (path_size > 0) {
59 std::unique_ptr<uint8_t[]> buffer(new uint8_t[path_size]);
60 clip_path_.writeToMemory(buffer.get());
61 details->set_clip_path(buffer.get(), path_size);
62 }
63 }
64
65 void ClipPathDisplayItem::Raster(SkCanvas* canvas, 31 void ClipPathDisplayItem::Raster(SkCanvas* canvas,
66 SkPicture::AbortCallback* callback) const { 32 SkPicture::AbortCallback* callback) const {
67 canvas->save(); 33 canvas->save();
68 canvas->clipPath(clip_path_, antialias_); 34 canvas->clipPath(clip_path_, antialias_);
69 } 35 }
70 36
71 void ClipPathDisplayItem::AsValueInto( 37 void ClipPathDisplayItem::AsValueInto(
72 const gfx::Rect& visual_rect, 38 const gfx::Rect& visual_rect,
73 base::trace_event::TracedValue* array) const { 39 base::trace_event::TracedValue* array) const {
74 array->AppendString(base::StringPrintf( 40 array->AppendString(base::StringPrintf(
75 "ClipPathDisplayItem length: %d visualRect: [%s]", 41 "ClipPathDisplayItem length: %d visualRect: [%s]",
76 clip_path_.countPoints(), visual_rect.ToString().c_str())); 42 clip_path_.countPoints(), visual_rect.ToString().c_str()));
77 } 43 }
78 44
79 EndClipPathDisplayItem::EndClipPathDisplayItem() : DisplayItem(END_CLIP_PATH) {} 45 EndClipPathDisplayItem::EndClipPathDisplayItem() : DisplayItem(END_CLIP_PATH) {}
80 46
81 EndClipPathDisplayItem::EndClipPathDisplayItem(const proto::DisplayItem& proto)
82 : DisplayItem(END_CLIP_PATH) {
83 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type());
84 }
85
86 EndClipPathDisplayItem::~EndClipPathDisplayItem() { 47 EndClipPathDisplayItem::~EndClipPathDisplayItem() {
87 } 48 }
88 49
89 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
90 proto->set_type(proto::DisplayItem::Type_EndClipPath);
91 }
92
93 void EndClipPathDisplayItem::Raster( 50 void EndClipPathDisplayItem::Raster(
94 SkCanvas* canvas, 51 SkCanvas* canvas,
95 SkPicture::AbortCallback* callback) const { 52 SkPicture::AbortCallback* callback) const {
96 canvas->restore(); 53 canvas->restore();
97 } 54 }
98 55
99 void EndClipPathDisplayItem::AsValueInto( 56 void EndClipPathDisplayItem::AsValueInto(
100 const gfx::Rect& visual_rect, 57 const gfx::Rect& visual_rect,
101 base::trace_event::TracedValue* array) const { 58 base::trace_event::TracedValue* array) const {
102 array->AppendString( 59 array->AppendString(
103 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", 60 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]",
104 visual_rect.ToString().c_str())); 61 visual_rect.ToString().c_str()));
105 } 62 }
106 63
107 } // namespace cc 64 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/clip_path_display_item.h ('k') | cc/playback/compositing_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698