Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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_LAYERS_PICTURE_LAYER_IMPL_H_ |
| 6 | #define CC_LAYERS_PICTURE_LAYER_IMPL_H_ |
| 7 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "cc/base/cc_export.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 12 | #include "cc/base/scoped_ptr_vector.h" |
| 13 | #include "cc/layers/layer_impl.h" |
| 14 | #include "cc/resources/picture_layer_tiling.h" |
| 15 | #include "cc/resources/picture_layer_tiling_set.h" |
| 16 | #include "cc/resources/picture_pile_impl.h" |
| 17 | #include "skia/ext/refptr.h" |
| 18 | #include "third_party/skia/include/core/SkPicture.h" |
| 19 | |
| 20 | namespace cc { |
| 21 | |
| 22 | struct AppendQuadsData; |
| 23 | class QuadSink; |
| 24 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 25 | class CC_EXPORT PictureLayerImpl |
| 26 | : public LayerImpl, |
| 27 | NON_EXPORTED_BASE(public PictureLayerTilingClient) { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 28 | public: |
| 29 | static scoped_ptr<PictureLayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 30 | return make_scoped_ptr(new PictureLayerImpl(tree_impl, id)); |
| 31 | } |
| 32 | virtual ~PictureLayerImpl(); |
| 33 | |
| 34 | // LayerImpl overrides. |
| 35 | virtual const char* LayerTypeAsString() const OVERRIDE; |
| 36 | virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
| 37 | OVERRIDE; |
| 38 | virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
| 39 | virtual void AppendQuads(QuadSink* quad_sink, |
| 40 | AppendQuadsData* append_quads_data) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 41 | virtual void UpdateTilePriorities() OVERRIDE; |
| 42 | virtual void DidBecomeActive() OVERRIDE; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 43 | virtual void DidBeginTracing() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 44 | virtual void DidLoseOutputSurface() OVERRIDE; |
| 45 | virtual void CalculateContentsScale(float ideal_contents_scale, |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 46 | float device_scale_factor, |
| 47 | float page_scale_factor, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 48 | bool animating_transform_to_screen, |
| 49 | float* contents_scale_x, |
| 50 | float* contents_scale_y, |
| 51 | gfx::Size* content_bounds) OVERRIDE; |
| 52 | virtual skia::RefPtr<SkPicture> GetPicture() OVERRIDE; |
| 53 | |
| 54 | // PictureLayerTilingClient overrides. |
| 55 | virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, |
| 56 | gfx::Rect content_rect) OVERRIDE; |
| 57 | virtual void UpdatePile(Tile* tile) OVERRIDE; |
| 58 | virtual gfx::Size CalculateTileSize( |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 59 | gfx::Size content_bounds) const OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 60 | virtual const Region* GetInvalidation() OVERRIDE; |
| 61 | virtual const PictureLayerTiling* GetTwinTiling( |
| 62 | const PictureLayerTiling* tiling) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 63 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 64 | // PushPropertiesTo active tree => pending tree. |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 65 | void SyncFromActiveLayer(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 66 | void SyncTiling(const PictureLayerTiling* tiling); |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 67 | void UpdateTwinLayer(); |
| 68 | |
| 69 | void CreateTilingSetIfNeeded(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 70 | |
| 71 | // Mask-related functions |
| 72 | void SetIsMask(bool is_mask); |
| 73 | virtual ResourceProvider::ResourceId ContentsResourceId() const OVERRIDE; |
| 74 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 75 | virtual size_t GPUMemoryUsageInBytes() const OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 76 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 77 | protected: |
| 78 | PictureLayerImpl(LayerTreeImpl* tree_impl, int id); |
| 79 | PictureLayerTiling* AddTiling(float contents_scale); |
| 80 | void RemoveTiling(float contents_scale); |
| 81 | void SyncFromActiveLayer(const PictureLayerImpl* other); |
| 82 | void ManageTilings(bool animating_transform_to_screen); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 83 | virtual bool ShouldAdjustRasterScale( |
| 84 | bool animating_transform_to_screen) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 85 | virtual void CalculateRasterContentsScale( |
| 86 | bool animating_transform_to_screen, |
| 87 | float* raster_contents_scale, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 88 | float* low_res_raster_contents_scale) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 89 | void CleanUpTilingsOnActiveLayer( |
| 90 | std::vector<PictureLayerTiling*> used_tilings); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 91 | float MinimumContentsScale() const; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 92 | void UpdateLCDTextStatus(bool new_status); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 93 | void ResetRasterScale(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 94 | void MarkVisibleResourcesAsRequired() const; |
| 95 | |
| 96 | bool CanHaveTilings() const; |
| 97 | bool CanHaveTilingWithScale(float contents_scale) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 98 | |
| 99 | virtual void GetDebugBorderProperties( |
| 100 | SkColor* color, float* width) const OVERRIDE; |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 101 | virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 102 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 103 | PictureLayerImpl* twin_layer_; |
| 104 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 105 | scoped_ptr<PictureLayerTilingSet> tilings_; |
| 106 | scoped_refptr<PicturePileImpl> pile_; |
| 107 | Region invalidation_; |
| 108 | |
| 109 | gfx::Transform last_screen_space_transform_; |
| 110 | gfx::Size last_bounds_; |
| 111 | float last_content_scale_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 112 | bool is_mask_; |
| 113 | |
| 114 | float ideal_page_scale_; |
| 115 | float ideal_device_scale_; |
| 116 | float ideal_source_scale_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 117 | float ideal_contents_scale_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 118 | |
| 119 | float raster_page_scale_; |
| 120 | float raster_device_scale_; |
| 121 | float raster_source_scale_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 122 | float raster_contents_scale_; |
| 123 | float low_res_raster_contents_scale_; |
| 124 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 125 | bool raster_source_scale_was_animating_; |
| 126 | bool is_using_lcd_text_; |
| 127 | |
| 128 | friend class PictureLayer; |
| 129 | DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); |
| 130 | }; |
| 131 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 132 | } // namespace cc |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 133 | |
| 134 | #endif // CC_LAYERS_PICTURE_LAYER_IMPL_H_ |