OLD | NEW |
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" | 22 #include "third_party/skia/include/core/SkBBHFactory.h" |
23 #include "third_party/skia/include/core/SkPicture.h" | 23 #include "third_party/skia/include/core/SkPicture.h" |
24 #include "third_party/skia/include/record/SkRecording.h" | |
25 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
26 | 25 |
27 class SkPixelRef; | 26 class SkPixelRef; |
28 | 27 |
29 namespace base { | 28 namespace base { |
30 class Value; | 29 class Value; |
31 } | 30 } |
32 | 31 |
33 namespace skia { | 32 namespace skia { |
34 class AnalysisCanvas; | 33 class AnalysisCanvas; |
35 } | 34 } |
36 | 35 |
37 namespace cc { | 36 namespace cc { |
38 | 37 |
39 class ContentLayerClient; | 38 class ContentLayerClient; |
40 | 39 |
41 class CC_EXPORT Picture | 40 class CC_EXPORT Picture |
42 : public base::RefCountedThreadSafe<Picture> { | 41 : public base::RefCountedThreadSafe<Picture> { |
43 public: | 42 public: |
44 typedef std::pair<int, int> PixelRefMapKey; | 43 typedef std::pair<int, int> PixelRefMapKey; |
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 RECORD_WITH_SKRECORD, | |
53 RECORDING_MODE_COUNT, // Must be the last entry. | 51 RECORDING_MODE_COUNT, // Must be the last entry. |
54 }; | 52 }; |
55 | 53 |
56 static scoped_refptr<Picture> Create( | 54 static scoped_refptr<Picture> Create( |
57 const gfx::Rect& layer_rect, | 55 const gfx::Rect& layer_rect, |
58 ContentLayerClient* client, | 56 ContentLayerClient* client, |
59 const SkTileGridFactory::TileGridInfo& tile_grid_info, | 57 const SkTileGridFactory::TileGridInfo& tile_grid_info, |
60 bool gather_pixels_refs, | 58 bool gather_pixels_refs, |
61 RecordingMode recording_mode); | 59 RecordingMode recording_mode); |
62 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); | 60 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SkTileGridFactory::TileGridInfo& tile_grid_info, |
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 SkTileGridFactory::TileGridInfo& 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 scoped_ptr<const EXPERIMENTAL::SkPlayback> playback_; | |
154 | 151 |
155 PixelRefMap pixel_refs_; | 152 PixelRefMap pixel_refs_; |
156 gfx::Point min_pixel_cell_; | 153 gfx::Point min_pixel_cell_; |
157 gfx::Point max_pixel_cell_; | 154 gfx::Point max_pixel_cell_; |
158 gfx::Size cell_size_; | 155 gfx::Size cell_size_; |
159 | 156 |
160 scoped_refptr<base::debug::ConvertableToTraceFormat> | 157 scoped_refptr<base::debug::ConvertableToTraceFormat> |
161 AsTraceableRasterData(float scale) const; | 158 AsTraceableRasterData(float scale) const; |
162 scoped_refptr<base::debug::ConvertableToTraceFormat> | 159 scoped_refptr<base::debug::ConvertableToTraceFormat> |
163 AsTraceableRecordData() const; | 160 AsTraceableRecordData() const; |
164 | 161 |
165 friend class base::RefCountedThreadSafe<Picture>; | 162 friend class base::RefCountedThreadSafe<Picture>; |
166 friend class PixelRefIterator; | 163 friend class PixelRefIterator; |
167 DISALLOW_COPY_AND_ASSIGN(Picture); | 164 DISALLOW_COPY_AND_ASSIGN(Picture); |
168 }; | 165 }; |
169 | 166 |
170 } // namespace cc | 167 } // namespace cc |
171 | 168 |
172 #endif // CC_RESOURCES_PICTURE_H_ | 169 #endif // CC_RESOURCES_PICTURE_H_ |
OLD | NEW |