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

Side by Side Diff: cc/resources/picture.h

Issue 362073002: cc: Remove all traces of SkPicture cloning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/output/software_renderer_unittest.cc ('k') | cc/resources/picture.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CC_RESOURCES_PICTURE_H_ 5 #ifndef CC_RESOURCES_PICTURE_H_
6 #define CC_RESOURCES_PICTURE_H_ 6 #define CC_RESOURCES_PICTURE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/threading/thread_checker.h"
20 #include "cc/base/cc_export.h" 19 #include "cc/base/cc_export.h"
21 #include "cc/base/region.h" 20 #include "cc/base/region.h"
22 #include "skia/ext/refptr.h" 21 #include "skia/ext/refptr.h"
23 #include "third_party/skia/include/core/SkBBHFactory.h" 22 #include "third_party/skia/include/core/SkBBHFactory.h"
24 #include "third_party/skia/include/core/SkPicture.h" 23 #include "third_party/skia/include/core/SkPicture.h"
25 #include "third_party/skia/include/record/SkRecording.h" 24 #include "third_party/skia/include/record/SkRecording.h"
26 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
27 26
28 class SkPixelRef; 27 class SkPixelRef;
29 28
(...skipping 22 matching lines...) Expand all
52 RECORD_WITH_PAINTING_DISABLED, 51 RECORD_WITH_PAINTING_DISABLED,
53 RECORD_WITH_SKRECORD, 52 RECORD_WITH_SKRECORD,
54 RECORDING_MODE_COUNT, // Must be the last entry. 53 RECORDING_MODE_COUNT, // Must be the last entry.
55 }; 54 };
56 55
57 static scoped_refptr<Picture> Create( 56 static scoped_refptr<Picture> Create(
58 const gfx::Rect& layer_rect, 57 const gfx::Rect& layer_rect,
59 ContentLayerClient* client, 58 ContentLayerClient* client,
60 const SkTileGridFactory::TileGridInfo& tile_grid_info, 59 const SkTileGridFactory::TileGridInfo& tile_grid_info,
61 bool gather_pixels_refs, 60 bool gather_pixels_refs,
62 int num_raster_threads,
63 RecordingMode recording_mode); 61 RecordingMode recording_mode);
64 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); 62 static scoped_refptr<Picture> CreateFromValue(const base::Value* value);
65 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); 63 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value);
66 64
67 gfx::Rect LayerRect() const { return layer_rect_; } 65 gfx::Rect LayerRect() const { return layer_rect_; }
68 gfx::Rect OpaqueRect() const { return opaque_rect_; } 66 gfx::Rect OpaqueRect() const { return opaque_rect_; }
69 67
70 // Get thread-safe clone for rasterizing with on a specific thread.
71 Picture* GetCloneForDrawingOnThread(unsigned thread_index);
72
73 // Has Record() been called yet? 68 // Has Record() been called yet?
74 bool HasRecording() const { return picture_.get() != NULL; } 69 bool HasRecording() const { return picture_.get() != NULL; }
75 70
76 bool IsSuitableForGpuRasterization() const; 71 bool IsSuitableForGpuRasterization() const;
77 72
78 bool HasText() const; 73 bool HasText() const;
79 74
80 // Apply this scale and raster the negated region into the canvas. 75 // Apply this scale and raster the negated region into the canvas.
81 // |negated_content_region| specifies the region to be clipped out of the 76 // |negated_content_region| specifies the region to be clipped out of the
82 // raster operation, i.e., the parts of the canvas which will not get drawn 77 // raster operation, i.e., the parts of the canvas which will not get drawn
83 // to. 78 // to.
84 int Raster(SkCanvas* canvas, 79 int Raster(SkCanvas* canvas,
85 SkDrawPictureCallback* callback, 80 SkDrawPictureCallback* callback,
86 const Region& negated_content_region, 81 const Region& negated_content_region,
87 float contents_scale); 82 float contents_scale) const;
88 83
89 // Draw the picture directly into the given canvas, without applying any 84 // Draw the picture directly into the given canvas, without applying any
90 // clip/scale/layer transformations. 85 // clip/scale/layer transformations.
91 void Replay(SkCanvas* canvas); 86 void Replay(SkCanvas* canvas);
92 87
93 scoped_ptr<base::Value> AsValue() const; 88 scoped_ptr<base::Value> AsValue() const;
94 89
95 // This iterator imprecisely returns the set of pixel refs that are needed to 90 // This iterator imprecisely returns the set of pixel refs that are needed to
96 // raster this layer rect from this picture. Internally, pixel refs are 91 // raster this layer rect from this picture. Internally, pixel refs are
97 // clumped into tile grid buckets, so there may be false positives. 92 // clumped into tile grid buckets, so there may be false positives.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Picture(const skia::RefPtr<SkPicture>&, 135 Picture(const skia::RefPtr<SkPicture>&,
141 const gfx::Rect& layer_rect, 136 const gfx::Rect& layer_rect,
142 const gfx::Rect& opaque_rect, 137 const gfx::Rect& opaque_rect,
143 const PixelRefMap& pixel_refs); 138 const PixelRefMap& pixel_refs);
144 // This constructor will call AdoptRef on the SkPicture. 139 // This constructor will call AdoptRef on the SkPicture.
145 Picture(SkPicture*, 140 Picture(SkPicture*,
146 const gfx::Rect& layer_rect, 141 const gfx::Rect& layer_rect,
147 const gfx::Rect& opaque_rect); 142 const gfx::Rect& opaque_rect);
148 ~Picture(); 143 ~Picture();
149 144
150 // Make thread-safe clones for rasterizing with.
151 void CloneForDrawing(int num_threads);
152
153 // Record a paint operation. To be able to safely use this SkPicture for 145 // Record a paint operation. To be able to safely use this SkPicture for
154 // playback on a different thread this can only be called once. 146 // playback on a different thread this can only be called once.
155 void Record(ContentLayerClient* client, 147 void Record(ContentLayerClient* client,
156 const SkTileGridFactory::TileGridInfo& tile_grid_info, 148 const SkTileGridFactory::TileGridInfo& tile_grid_info,
157 RecordingMode recording_mode); 149 RecordingMode recording_mode);
158 150
159 // Gather pixel refs from recording. 151 // Gather pixel refs from recording.
160 void GatherPixelRefs(const SkTileGridFactory::TileGridInfo& tile_grid_info); 152 void GatherPixelRefs(const SkTileGridFactory::TileGridInfo& tile_grid_info);
161 153
162 gfx::Rect layer_rect_; 154 gfx::Rect layer_rect_;
163 gfx::Rect opaque_rect_; 155 gfx::Rect opaque_rect_;
164 skia::RefPtr<SkPicture> picture_; 156 skia::RefPtr<SkPicture> picture_;
165 scoped_ptr<const EXPERIMENTAL::SkPlayback> playback_; 157 scoped_ptr<const EXPERIMENTAL::SkPlayback> playback_;
166 158
167 typedef std::vector<scoped_refptr<Picture> > PictureVector;
168 PictureVector clones_;
169
170 PixelRefMap pixel_refs_; 159 PixelRefMap pixel_refs_;
171 gfx::Point min_pixel_cell_; 160 gfx::Point min_pixel_cell_;
172 gfx::Point max_pixel_cell_; 161 gfx::Point max_pixel_cell_;
173 gfx::Size cell_size_; 162 gfx::Size cell_size_;
174 163
175 scoped_refptr<base::debug::ConvertableToTraceFormat> 164 scoped_refptr<base::debug::ConvertableToTraceFormat>
176 AsTraceableRasterData(float scale) const; 165 AsTraceableRasterData(float scale) const;
177 scoped_refptr<base::debug::ConvertableToTraceFormat> 166 scoped_refptr<base::debug::ConvertableToTraceFormat>
178 AsTraceableRecordData() const; 167 AsTraceableRecordData() const;
179 168
180 base::ThreadChecker raster_thread_checker_;
181
182 friend class base::RefCountedThreadSafe<Picture>; 169 friend class base::RefCountedThreadSafe<Picture>;
183 friend class PixelRefIterator; 170 friend class PixelRefIterator;
184 DISALLOW_COPY_AND_ASSIGN(Picture); 171 DISALLOW_COPY_AND_ASSIGN(Picture);
185 }; 172 };
186 173
187 } // namespace cc 174 } // namespace cc
188 175
189 #endif // CC_RESOURCES_PICTURE_H_ 176 #endif // CC_RESOURCES_PICTURE_H_
OLDNEW
« no previous file with comments | « cc/output/software_renderer_unittest.cc ('k') | cc/resources/picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698