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

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

Issue 111143005: cc: Gather and lock/unlock SkDiscardablePixelRefs instead of skia::LazyPixelRefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/lazy/discardable/ to fix cc_unittests Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 "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/lazy_pixel_ref.h"
22 #include "skia/ext/refptr.h" 21 #include "skia/ext/refptr.h"
23 #include "third_party/skia/include/core/SkPixelRef.h"
24 #include "third_party/skia/include/core/SkTileGridPicture.h" 22 #include "third_party/skia/include/core/SkTileGridPicture.h"
25 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
26 24
25 class SkPixelRef;
26
27 namespace base { 27 namespace base {
28 class Value; 28 class Value;
29 } 29 }
30 30
31 namespace skia { 31 namespace skia {
32 class AnalysisCanvas; 32 class AnalysisCanvas;
33 } 33 }
34 34
35 namespace cc { 35 namespace cc {
36 36
37 class ContentLayerClient; 37 class ContentLayerClient;
38 38
39 class CC_EXPORT Picture 39 class CC_EXPORT Picture
40 : public base::RefCountedThreadSafe<Picture> { 40 : public base::RefCountedThreadSafe<Picture> {
41 public: 41 public:
42 typedef std::pair<int, int> PixelRefMapKey; 42 typedef std::pair<int, int> PixelRefMapKey;
43 typedef std::vector<skia::LazyPixelRef*> PixelRefs; 43 typedef std::vector<SkPixelRef*> PixelRefs;
44 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; 44 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap;
45 45
46 static scoped_refptr<Picture> Create(gfx::Rect layer_rect); 46 static scoped_refptr<Picture> Create(gfx::Rect layer_rect);
47 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); 47 static scoped_refptr<Picture> CreateFromValue(const base::Value* value);
48 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); 48 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value);
49 49
50 gfx::Rect LayerRect() const { return layer_rect_; } 50 gfx::Rect LayerRect() const { return layer_rect_; }
51 gfx::Rect OpaqueRect() const { return opaque_rect_; } 51 gfx::Rect OpaqueRect() const { return opaque_rect_; }
52 52
53 // Get thread-safe clone for rasterizing with on a specific thread. 53 // Get thread-safe clone for rasterizing with on a specific thread.
(...skipping 26 matching lines...) Expand all
80 void Replay(SkCanvas* canvas); 80 void Replay(SkCanvas* canvas);
81 81
82 scoped_ptr<base::Value> AsValue() const; 82 scoped_ptr<base::Value> AsValue() const;
83 83
84 class CC_EXPORT PixelRefIterator { 84 class CC_EXPORT PixelRefIterator {
85 public: 85 public:
86 PixelRefIterator(); 86 PixelRefIterator();
87 PixelRefIterator(gfx::Rect layer_rect, const Picture* picture); 87 PixelRefIterator(gfx::Rect layer_rect, const Picture* picture);
88 ~PixelRefIterator(); 88 ~PixelRefIterator();
89 89
90 skia::LazyPixelRef* operator->() const { 90 SkPixelRef* operator->() const {
91 DCHECK_LT(current_index_, current_pixel_refs_->size()); 91 DCHECK_LT(current_index_, current_pixel_refs_->size());
92 return (*current_pixel_refs_)[current_index_]; 92 return (*current_pixel_refs_)[current_index_];
93 } 93 }
94 94
95 skia::LazyPixelRef* operator*() const { 95 SkPixelRef* operator*() const {
96 DCHECK_LT(current_index_, current_pixel_refs_->size()); 96 DCHECK_LT(current_index_, current_pixel_refs_->size());
97 return (*current_pixel_refs_)[current_index_]; 97 return (*current_pixel_refs_)[current_index_];
98 } 98 }
99 99
100 PixelRefIterator& operator++(); 100 PixelRefIterator& operator++();
101 operator bool() const { 101 operator bool() const {
102 return current_index_ < current_pixel_refs_->size(); 102 return current_index_ < current_pixel_refs_->size();
103 } 103 }
104 104
105 private: 105 private:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 AsTraceableRecordData() const; 151 AsTraceableRecordData() const;
152 152
153 friend class base::RefCountedThreadSafe<Picture>; 153 friend class base::RefCountedThreadSafe<Picture>;
154 friend class PixelRefIterator; 154 friend class PixelRefIterator;
155 DISALLOW_COPY_AND_ASSIGN(Picture); 155 DISALLOW_COPY_AND_ASSIGN(Picture);
156 }; 156 };
157 157
158 } // namespace cc 158 } // namespace cc
159 159
160 #endif // CC_RESOURCES_PICTURE_H_ 160 #endif // CC_RESOURCES_PICTURE_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698