| 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/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" | 22 #include "third_party/skia/include/core/SkPixelRef.h" |
| 24 #include "third_party/skia/include/core/SkTileGridPicture.h" | 23 #include "third_party/skia/include/core/SkTileGridPicture.h" |
| 25 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 class Value; | 27 class Value; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace skia { | 30 namespace skia { |
| 32 class AnalysisCanvas; | 31 class AnalysisCanvas; |
| 33 } | 32 } |
| 34 | 33 |
| 35 namespace cc { | 34 namespace cc { |
| 36 | 35 |
| 37 class ContentLayerClient; | 36 class ContentLayerClient; |
| 38 | 37 |
| 39 class CC_EXPORT Picture | 38 class CC_EXPORT Picture |
| 40 : public base::RefCountedThreadSafe<Picture> { | 39 : public base::RefCountedThreadSafe<Picture> { |
| 41 public: | 40 public: |
| 42 typedef std::pair<int, int> PixelRefMapKey; | 41 typedef std::pair<int, int> PixelRefMapKey; |
| 43 typedef std::vector<skia::LazyPixelRef*> PixelRefs; | 42 typedef std::vector<SkPixelRef*> PixelRefs; |
| 44 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; | 43 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; |
| 45 | 44 |
| 46 static scoped_refptr<Picture> Create(gfx::Rect layer_rect); | 45 static scoped_refptr<Picture> Create(gfx::Rect layer_rect); |
| 47 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); | 46 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); |
| 48 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); | 47 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); |
| 49 | 48 |
| 50 gfx::Rect LayerRect() const { return layer_rect_; } | 49 gfx::Rect LayerRect() const { return layer_rect_; } |
| 51 gfx::Rect OpaqueRect() const { return opaque_rect_; } | 50 gfx::Rect OpaqueRect() const { return opaque_rect_; } |
| 52 | 51 |
| 53 // Get thread-safe clone for rasterizing with on a specific thread. | 52 // Get thread-safe clone for rasterizing with on a specific thread. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 80 void Replay(SkCanvas* canvas); | 79 void Replay(SkCanvas* canvas); |
| 81 | 80 |
| 82 scoped_ptr<base::Value> AsValue() const; | 81 scoped_ptr<base::Value> AsValue() const; |
| 83 | 82 |
| 84 class CC_EXPORT PixelRefIterator { | 83 class CC_EXPORT PixelRefIterator { |
| 85 public: | 84 public: |
| 86 PixelRefIterator(); | 85 PixelRefIterator(); |
| 87 PixelRefIterator(gfx::Rect layer_rect, const Picture* picture); | 86 PixelRefIterator(gfx::Rect layer_rect, const Picture* picture); |
| 88 ~PixelRefIterator(); | 87 ~PixelRefIterator(); |
| 89 | 88 |
| 90 skia::LazyPixelRef* operator->() const { | 89 SkPixelRef* operator->() const { |
| 91 DCHECK_LT(current_index_, current_pixel_refs_->size()); | 90 DCHECK_LT(current_index_, current_pixel_refs_->size()); |
| 92 return (*current_pixel_refs_)[current_index_]; | 91 return (*current_pixel_refs_)[current_index_]; |
| 93 } | 92 } |
| 94 | 93 |
| 95 skia::LazyPixelRef* operator*() const { | 94 SkPixelRef* operator*() const { |
| 96 DCHECK_LT(current_index_, current_pixel_refs_->size()); | 95 DCHECK_LT(current_index_, current_pixel_refs_->size()); |
| 97 return (*current_pixel_refs_)[current_index_]; | 96 return (*current_pixel_refs_)[current_index_]; |
| 98 } | 97 } |
| 99 | 98 |
| 100 PixelRefIterator& operator++(); | 99 PixelRefIterator& operator++(); |
| 101 operator bool() const { | 100 operator bool() const { |
| 102 return current_index_ < current_pixel_refs_->size(); | 101 return current_index_ < current_pixel_refs_->size(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 private: | 104 private: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 AsTraceableRecordData() const; | 150 AsTraceableRecordData() const; |
| 152 | 151 |
| 153 friend class base::RefCountedThreadSafe<Picture>; | 152 friend class base::RefCountedThreadSafe<Picture>; |
| 154 friend class PixelRefIterator; | 153 friend class PixelRefIterator; |
| 155 DISALLOW_COPY_AND_ASSIGN(Picture); | 154 DISALLOW_COPY_AND_ASSIGN(Picture); |
| 156 }; | 155 }; |
| 157 | 156 |
| 158 } // namespace cc | 157 } // namespace cc |
| 159 | 158 |
| 160 #endif // CC_RESOURCES_PICTURE_H_ | 159 #endif // CC_RESOURCES_PICTURE_H_ |
| OLD | NEW |