| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_PICTURE_PILE_IMPL_H_ | |
| 6 #define CC_PICTURE_PILE_IMPL_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 #include <map> | |
| 10 | |
| 11 #include "cc/base/cc_export.h" | |
| 12 #include "cc/picture_pile_base.h" | |
| 13 #include "skia/ext/refptr.h" | |
| 14 #include "third_party/skia/include/core/SkPicture.h" | |
| 15 | |
| 16 namespace cc { | |
| 17 struct RenderingStats; | |
| 18 | |
| 19 class CC_EXPORT PicturePileImpl : public PicturePileBase { | |
| 20 public: | |
| 21 static scoped_refptr<PicturePileImpl> Create(); | |
| 22 static scoped_refptr<PicturePileImpl> CreateFromOther( | |
| 23 const PicturePileBase* other); | |
| 24 | |
| 25 // Get paint-safe version of this picture for a specific thread. | |
| 26 PicturePileImpl* GetCloneForDrawingOnThread(unsigned thread_index) const; | |
| 27 | |
| 28 // Raster a subrect of this PicturePileImpl into the given canvas. | |
| 29 // It's only safe to call paint on a cloned version. | |
| 30 // It is assumed that contentsScale has already been applied to this canvas. | |
| 31 void Raster( | |
| 32 SkCanvas* canvas, | |
| 33 gfx::Rect canvas_rect, | |
| 34 float contents_scale, | |
| 35 int64* total_pixels_rasterized); | |
| 36 | |
| 37 void GatherPixelRefs( | |
| 38 gfx::Rect content_rect, | |
| 39 float contents_scale, | |
| 40 std::list<skia::LazyPixelRef*>& pixel_refs); | |
| 41 | |
| 42 skia::RefPtr<SkPicture> GetFlattenedPicture(); | |
| 43 | |
| 44 struct Analysis { | |
| 45 Analysis(); | |
| 46 | |
| 47 bool is_solid_color; | |
| 48 bool is_transparent; | |
| 49 bool is_cheap_to_raster; | |
| 50 SkColor solid_color; | |
| 51 }; | |
| 52 | |
| 53 void AnalyzeInRect(const gfx::Rect& content_rect, | |
| 54 float contents_scale, | |
| 55 Analysis* analysis); | |
| 56 | |
| 57 protected: | |
| 58 friend class PicturePile; | |
| 59 | |
| 60 PicturePileImpl(); | |
| 61 PicturePileImpl(const PicturePileBase* other); | |
| 62 virtual ~PicturePileImpl(); | |
| 63 | |
| 64 private: | |
| 65 class ClonesForDrawing { | |
| 66 public: | |
| 67 ClonesForDrawing(const PicturePileImpl* pile, int num_threads); | |
| 68 ~ClonesForDrawing(); | |
| 69 | |
| 70 typedef std::vector<scoped_refptr<PicturePileImpl> > PicturePileVector; | |
| 71 PicturePileVector clones_; | |
| 72 }; | |
| 73 | |
| 74 static scoped_refptr<PicturePileImpl> CreateCloneForDrawing( | |
| 75 const PicturePileImpl* other, unsigned thread_index); | |
| 76 | |
| 77 PicturePileImpl(const PicturePileImpl* other, unsigned thread_index); | |
| 78 | |
| 79 // Once instantiated, |clones_for_drawing_| can't be modified. | |
| 80 // This guarantees thread-safe access during the life | |
| 81 // time of a PicturePileImpl instance. | |
| 82 const ClonesForDrawing clones_for_drawing_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); | |
| 85 }; | |
| 86 | |
| 87 } // namespace cc | |
| 88 | |
| 89 #endif // CC_PICTURE_PILE_IMPL_H_ | |
| OLD | NEW |