Chromium Code Reviews

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 "cc/base/cc_export.h" 19 #include "cc/base/cc_export.h"
20 #include "cc/base/region.h" 20 #include "cc/base/region.h"
21 #include "skia/ext/refptr.h" 21 #include "skia/ext/refptr.h"
22 #include "third_party/skia/include/core/SkBBHFactory.h"
23 #include "third_party/skia/include/core/SkPicture.h" 22 #include "third_party/skia/include/core/SkPicture.h"
24 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
25 24
26 class SkDrawPictureCallback; 25 class SkDrawPictureCallback;
27 class SkPixelRef; 26 class SkPixelRef;
28 27
29 namespace base { 28 namespace base {
30 class Value; 29 class Value;
31 } 30 }
32 31
(...skipping 12 matching lines...)
45 typedef std::vector<SkPixelRef*> PixelRefs; 44 typedef std::vector<SkPixelRef*> PixelRefs;
46 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; 45 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap;
47 46
48 enum RecordingMode { 47 enum RecordingMode {
49 RECORD_NORMALLY, 48 RECORD_NORMALLY,
50 RECORD_WITH_SK_NULL_CANVAS, 49 RECORD_WITH_SK_NULL_CANVAS,
51 RECORD_WITH_PAINTING_DISABLED, 50 RECORD_WITH_PAINTING_DISABLED,
52 RECORDING_MODE_COUNT, // Must be the last entry. 51 RECORDING_MODE_COUNT, // Must be the last entry.
53 }; 52 };
54 53
55 static scoped_refptr<Picture> Create( 54 static scoped_refptr<Picture> Create(const gfx::Rect& layer_rect,
56 const gfx::Rect& layer_rect, 55 ContentLayerClient* client,
57 ContentLayerClient* client, 56 const gfx::Size& tile_grid_size,
58 const SkTileGridFactory::TileGridInfo& tile_grid_info, 57 bool gather_pixels_refs,
59 bool gather_pixels_refs, 58 RecordingMode recording_mode);
60 RecordingMode recording_mode);
61 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); 59 static scoped_refptr<Picture> CreateFromValue(const base::Value* value);
62 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); 60 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value);
63 61
64 gfx::Rect LayerRect() const { return layer_rect_; } 62 gfx::Rect LayerRect() const { return layer_rect_; }
65 63
66 // Has Record() been called yet? 64 // Has Record() been called yet?
67 bool HasRecording() const { return picture_.get() != NULL; } 65 bool HasRecording() const { return picture_.get() != NULL; }
68 66
69 bool IsSuitableForGpuRasterization(const char** reason) const; 67 bool IsSuitableForGpuRasterization(const char** reason) const;
70 int ApproximateOpCount() const; 68 int ApproximateOpCount() const;
(...skipping 64 matching lines...)
135 Picture(const skia::RefPtr<SkPicture>&, 133 Picture(const skia::RefPtr<SkPicture>&,
136 const gfx::Rect& layer_rect, 134 const gfx::Rect& layer_rect,
137 const PixelRefMap& pixel_refs); 135 const PixelRefMap& pixel_refs);
138 // This constructor will call AdoptRef on the SkPicture. 136 // This constructor will call AdoptRef on the SkPicture.
139 Picture(SkPicture*, const gfx::Rect& layer_rect); 137 Picture(SkPicture*, const gfx::Rect& layer_rect);
140 ~Picture(); 138 ~Picture();
141 139
142 // Record a paint operation. To be able to safely use this SkPicture for 140 // Record a paint operation. To be able to safely use this SkPicture for
143 // playback on a different thread this can only be called once. 141 // playback on a different thread this can only be called once.
144 void Record(ContentLayerClient* client, 142 void Record(ContentLayerClient* client,
145 const SkTileGridFactory::TileGridInfo& tile_grid_info, 143 const gfx::Size& tile_grid_size,
146 RecordingMode recording_mode); 144 RecordingMode recording_mode);
147 145
148 // Gather pixel refs from recording. 146 // Gather pixel refs from recording.
149 void GatherPixelRefs(const SkTileGridFactory::TileGridInfo& tile_grid_info); 147 void GatherPixelRefs(const gfx::Size& tile_grid_info);
150 148
151 gfx::Rect layer_rect_; 149 gfx::Rect layer_rect_;
152 skia::RefPtr<SkPicture> picture_; 150 skia::RefPtr<SkPicture> picture_;
153 151
154 PixelRefMap pixel_refs_; 152 PixelRefMap pixel_refs_;
155 gfx::Point min_pixel_cell_; 153 gfx::Point min_pixel_cell_;
156 gfx::Point max_pixel_cell_; 154 gfx::Point max_pixel_cell_;
157 gfx::Size cell_size_; 155 gfx::Size cell_size_;
158 156
159 scoped_refptr<base::debug::ConvertableToTraceFormat> 157 scoped_refptr<base::debug::ConvertableToTraceFormat>
160 AsTraceableRasterData(float scale) const; 158 AsTraceableRasterData(float scale) const;
161 scoped_refptr<base::debug::ConvertableToTraceFormat> 159 scoped_refptr<base::debug::ConvertableToTraceFormat>
162 AsTraceableRecordData() const; 160 AsTraceableRecordData() const;
163 161
164 friend class base::RefCountedThreadSafe<Picture>; 162 friend class base::RefCountedThreadSafe<Picture>;
165 friend class PixelRefIterator; 163 friend class PixelRefIterator;
166 DISALLOW_COPY_AND_ASSIGN(Picture); 164 DISALLOW_COPY_AND_ASSIGN(Picture);
167 }; 165 };
168 166
169 } // namespace cc 167 } // namespace cc
170 168
171 #endif // CC_RESOURCES_PICTURE_H_ 169 #endif // CC_RESOURCES_PICTURE_H_
OLDNEW

Powered by Google App Engine