| 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_PICTURE_LAYER_IMPL_H_ | 5 #ifndef CC_PICTURE_LAYER_IMPL_H_ |
| 6 #define CC_PICTURE_LAYER_IMPL_H_ | 6 #define CC_PICTURE_LAYER_IMPL_H_ |
| 7 | 7 |
| 8 #include "cc/layer_impl.h" | 8 #include "cc/layer_impl.h" |
| 9 #include "cc/picture_layer_tiling.h" | 9 #include "cc/picture_layer_tiling.h" |
| 10 #include "cc/picture_layer_tiling_set.h" | 10 #include "cc/picture_layer_tiling_set.h" |
| 11 #include "cc/picture_pile_impl.h" | 11 #include "cc/picture_pile_impl.h" |
| 12 #include "cc/scoped_ptr_vector.h" | 12 #include "cc/scoped_ptr_vector.h" |
| 13 #include "skia/ext/refptr.h" | 13 #include "skia/ext/refptr.h" |
| 14 #include "third_party/skia/include/core/SkPicture.h" | 14 #include "third_party/skia/include/core/SkPicture.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 struct AppendQuadsData; | 18 struct AppendQuadsData; |
| 19 class QuadSink; | 19 class QuadSink; |
| 20 | 20 |
| 21 class CC_EXPORT PictureLayerImpl : public LayerImpl, | 21 class CC_EXPORT PictureLayerImpl : public LayerImpl, |
| 22 public PictureLayerTilingClient { | 22 public PictureLayerTilingClient { |
| 23 public: | 23 public: |
| 24 static scoped_ptr<PictureLayerImpl> create(LayerTreeImpl* treeImpl, int id) | 24 static scoped_ptr<PictureLayerImpl> Create(LayerTreeImpl* treeImpl, int id) |
| 25 { | 25 { |
| 26 return make_scoped_ptr(new PictureLayerImpl(treeImpl, id)); | 26 return make_scoped_ptr(new PictureLayerImpl(treeImpl, id)); |
| 27 } | 27 } |
| 28 virtual ~PictureLayerImpl(); | 28 virtual ~PictureLayerImpl(); |
| 29 | 29 |
| 30 // LayerImpl overrides. | 30 // LayerImpl overrides. |
| 31 virtual const char* layerTypeAsString() const OVERRIDE; | 31 virtual const char* LayerTypeAsString() const OVERRIDE; |
| 32 virtual scoped_ptr<LayerImpl> createLayerImpl( | 32 virtual scoped_ptr<LayerImpl> CreateLayerImpl( |
| 33 LayerTreeImpl* treeImpl) OVERRIDE; | 33 LayerTreeImpl* treeImpl) OVERRIDE; |
| 34 virtual void pushPropertiesTo(LayerImpl* layer) OVERRIDE; | 34 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
| 35 virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; | 35 virtual void AppendQuads(QuadSink* quad_sink, |
| 36 virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; | 36 AppendQuadsData* append_quads_data) OVERRIDE; |
| 37 virtual void updateTilePriorities() OVERRIDE; | 37 virtual void DumpLayerProperties(std::string* str, int indent) const OVERRIDE; |
| 38 virtual void didBecomeActive() OVERRIDE; | 38 virtual void UpdateTilePriorities() OVERRIDE; |
| 39 virtual void didLoseOutputSurface() OVERRIDE; | 39 virtual void DidBecomeActive() OVERRIDE; |
| 40 virtual void calculateContentsScale( | 40 virtual void DidLoseOutputSurface() OVERRIDE; |
| 41 float ideal_contents_scale, | 41 virtual void CalculateContentsScale(float ideal_contents_scale, |
| 42 bool animating_transform_to_screen, | 42 bool animating_transform_to_screen, |
| 43 float* contents_scale_x, | 43 float* contents_scale_x, |
| 44 float* contents_scale_y, | 44 float* contents_scale_y, |
| 45 gfx::Size* content_bounds) OVERRIDE; | 45 gfx::Size* content_bounds) OVERRIDE; |
| 46 virtual skia::RefPtr<SkPicture> getPicture() OVERRIDE; | 46 virtual skia::RefPtr<SkPicture> GetPicture() OVERRIDE; |
| 47 | 47 |
| 48 // PictureLayerTilingClient overrides. | 48 // PictureLayerTilingClient overrides. |
| 49 virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, | 49 virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, |
| 50 gfx::Rect content_rect) OVERRIDE; | 50 gfx::Rect content_rect) OVERRIDE; |
| 51 virtual void UpdatePile(Tile* tile) OVERRIDE; | 51 virtual void UpdatePile(Tile* tile) OVERRIDE; |
| 52 virtual gfx::Size CalculateTileSize( | 52 virtual gfx::Size CalculateTileSize( |
| 53 gfx::Size current_tile_size, | 53 gfx::Size current_tile_size, |
| 54 gfx::Size content_bounds) OVERRIDE; | 54 gfx::Size content_bounds) OVERRIDE; |
| 55 | 55 |
| 56 // PushPropertiesTo active tree => pending tree | 56 // PushPropertiesTo active tree => pending tree |
| 57 void SyncFromActiveLayer(); | 57 void SyncFromActiveLayer(); |
| 58 void SyncTiling( | 58 void SyncTiling( |
| 59 const PictureLayerTiling* tiling, | 59 const PictureLayerTiling* tiling, |
| 60 const Region& pending_layer_invalidation); | 60 const Region& pending_layer_invalidation); |
| 61 | 61 |
| 62 void CreateTilingSet(); | 62 void CreateTilingSet(); |
| 63 void TransferTilingSet(scoped_ptr<PictureLayerTilingSet> tilings); | 63 void TransferTilingSet(scoped_ptr<PictureLayerTilingSet> tilings); |
| 64 | 64 |
| 65 // Mask-related functions | 65 // Mask-related functions |
| 66 void SetIsMask(bool is_mask); | 66 void SetIsMask(bool is_mask); |
| 67 virtual ResourceProvider::ResourceId contentsResourceId() const OVERRIDE; | 67 virtual ResourceProvider::ResourceId ContentsResourceId() const OVERRIDE; |
| 68 | 68 |
| 69 virtual bool areVisibleResourcesReady() const OVERRIDE; | 69 virtual bool AreVisibleResourcesReady() const OVERRIDE; |
| 70 | 70 |
| 71 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; | 71 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; |
| 72 | 72 |
| 73 protected: | 73 protected: |
| 74 PictureLayerImpl(LayerTreeImpl* treeImpl, int id); | 74 PictureLayerImpl(LayerTreeImpl* treeImpl, int id); |
| 75 PictureLayerTiling* AddTiling(float contents_scale); | 75 PictureLayerTiling* AddTiling(float contents_scale); |
| 76 void RemoveTiling(float contents_scale); | 76 void RemoveTiling(float contents_scale); |
| 77 void SyncFromActiveLayer(const PictureLayerImpl* other); | 77 void SyncFromActiveLayer(const PictureLayerImpl* other); |
| 78 void ManageTilings(bool animating_transform_to_screen); | 78 void ManageTilings(bool animating_transform_to_screen); |
| 79 virtual void CalculateRasterContentsScale( | 79 virtual void CalculateRasterContentsScale( |
| 80 bool animating_transform_to_screen, | 80 bool animating_transform_to_screen, |
| 81 float* raster_contents_scale, | 81 float* raster_contents_scale, |
| 82 float* low_res_raster_contents_scale); | 82 float* low_res_raster_contents_scale); |
| 83 void CleanUpTilingsOnActiveLayer( | 83 void CleanUpTilingsOnActiveLayer( |
| 84 std::vector<PictureLayerTiling*> used_tilings); | 84 std::vector<PictureLayerTiling*> used_tilings); |
| 85 PictureLayerImpl* PendingTwin() const; | 85 PictureLayerImpl* PendingTwin() const; |
| 86 PictureLayerImpl* ActiveTwin() const; | 86 PictureLayerImpl* ActiveTwin() const; |
| 87 float MinimumContentsScale() const; | 87 float MinimumContentsScale() const; |
| 88 | 88 |
| 89 virtual void getDebugBorderProperties( | 89 virtual void GetDebugBorderProperties( |
| 90 SkColor* color, float* width) const OVERRIDE; | 90 SkColor* color, float* width) const OVERRIDE; |
| 91 | 91 |
| 92 scoped_ptr<PictureLayerTilingSet> tilings_; | 92 scoped_ptr<PictureLayerTilingSet> tilings_; |
| 93 scoped_refptr<PicturePileImpl> pile_; | 93 scoped_refptr<PicturePileImpl> pile_; |
| 94 Region invalidation_; | 94 Region invalidation_; |
| 95 | 95 |
| 96 gfx::Transform last_screen_space_transform_; | 96 gfx::Transform last_screen_space_transform_; |
| 97 gfx::Size last_bounds_; | 97 gfx::Size last_bounds_; |
| 98 float last_content_scale_; | 98 float last_content_scale_; |
| 99 float ideal_contents_scale_; | 99 float ideal_contents_scale_; |
| 100 bool is_mask_; | 100 bool is_mask_; |
| 101 | 101 |
| 102 float ideal_page_scale_; | 102 float ideal_page_scale_; |
| 103 float ideal_device_scale_; | 103 float ideal_device_scale_; |
| 104 float ideal_source_scale_; | 104 float ideal_source_scale_; |
| 105 | 105 |
| 106 float raster_page_scale_; | 106 float raster_page_scale_; |
| 107 float raster_device_scale_; | 107 float raster_device_scale_; |
| 108 float raster_source_scale_; | 108 float raster_source_scale_; |
| 109 bool raster_source_scale_was_animating_; | 109 bool raster_source_scale_was_animating_; |
| 110 | 110 |
| 111 friend class PictureLayer; | 111 friend class PictureLayer; |
| 112 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); | 112 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } | 115 } |
| 116 | 116 |
| 117 #endif // CC_PICTURE_LAYER_IMPL_H_ | 117 #endif // CC_PICTURE_LAYER_IMPL_H_ |
| OLD | NEW |