| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_LAYERS_TILED_LAYER_H_ | 5 #ifndef CC_LAYERS_TILED_LAYER_H_ |
| 6 #define CC_LAYERS_TILED_LAYER_H_ | 6 #define CC_LAYERS_TILED_LAYER_H_ |
| 7 | 7 |
| 8 #include "cc/base/cc_export.h" | 8 #include "cc/base/cc_export.h" |
| 9 #include "cc/layers/contents_scaling_layer.h" | 9 #include "cc/layers/contents_scaling_layer.h" |
| 10 #include "cc/resources/layer_tiling_data.h" | 10 #include "cc/resources/layer_tiling_data.h" |
| 11 #include "cc/resources/resource_format.h" | 11 #include "cc/resources/resource_format.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 class LayerUpdater; | 14 class LayerUpdater; |
| 15 class PrioritizedResourceManager; | 15 class PrioritizedResourceManager; |
| 16 class PrioritizedResource; | 16 class PrioritizedResource; |
| 17 class UpdatableTile; | 17 class UpdatableTile; |
| 18 | 18 |
| 19 class CC_EXPORT TiledLayer : public ContentsScalingLayer { | 19 class CC_EXPORT TiledLayer : public ContentsScalingLayer { |
| 20 public: | 20 public: |
| 21 enum TilingOption { | 21 enum TilingOption { |
| 22 ALWAYS_TILE, | 22 ALWAYS_TILE, |
| 23 NEVER_TILE, | 23 NEVER_TILE, |
| 24 AUTO_TILE, | 24 AUTO_TILE, |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 // Layer implementation. | 27 // Layer implementation. |
| 28 virtual void SetIsMask(bool is_mask) override; | 28 void SetIsMask(bool is_mask) override; |
| 29 virtual void PushPropertiesTo(LayerImpl* layer) override; | 29 void PushPropertiesTo(LayerImpl* layer) override; |
| 30 virtual void ReduceMemoryUsage() override; | 30 void ReduceMemoryUsage() override; |
| 31 virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect) override; | 31 void SetNeedsDisplayRect(const gfx::Rect& dirty_rect) override; |
| 32 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) override; | 32 void SetLayerTreeHost(LayerTreeHost* layer_tree_host) override; |
| 33 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) | 33 void SetTexturePriorities(const PriorityCalculator& priority_calc) override; |
| 34 override; | 34 SimpleEnclosedRegion VisibleContentOpaqueRegion() const override; |
| 35 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const override; | 35 bool Update(ResourceUpdateQueue* queue, |
| 36 virtual bool Update(ResourceUpdateQueue* queue, | 36 const OcclusionTracker<Layer>* occlusion) override; |
| 37 const OcclusionTracker<Layer>* occlusion) override; | 37 void OnOutputSurfaceCreated() override; |
| 38 virtual void OnOutputSurfaceCreated() override; | |
| 39 | 38 |
| 40 protected: | 39 protected: |
| 41 TiledLayer(); | 40 TiledLayer(); |
| 42 virtual ~TiledLayer(); | 41 ~TiledLayer() override; |
| 43 | 42 |
| 44 void UpdateTileSizeAndTilingOption(); | 43 void UpdateTileSizeAndTilingOption(); |
| 45 void UpdateBounds(); | 44 void UpdateBounds(); |
| 46 | 45 |
| 47 // Exposed to subclasses for testing. | 46 // Exposed to subclasses for testing. |
| 48 void SetTileSize(const gfx::Size& size); | 47 void SetTileSize(const gfx::Size& size); |
| 49 void SetTextureFormat(ResourceFormat texture_format) { | 48 void SetTextureFormat(ResourceFormat texture_format) { |
| 50 texture_format_ = texture_format; | 49 texture_format_ = texture_format; |
| 51 } | 50 } |
| 52 void SetBorderTexelOption(LayerTilingData::BorderTexelOption option); | 51 void SetBorderTexelOption(LayerTilingData::BorderTexelOption option); |
| 53 size_t NumPaintedTiles() { return tiler_->tiles().size(); } | 52 size_t NumPaintedTiles() { return tiler_->tiles().size(); } |
| 54 | 53 |
| 55 virtual LayerUpdater* Updater() const = 0; | 54 virtual LayerUpdater* Updater() const = 0; |
| 56 virtual void CreateUpdaterIfNeeded() = 0; | 55 virtual void CreateUpdaterIfNeeded() = 0; |
| 57 | 56 |
| 58 // Set invalidations to be potentially repainted during Update(). | 57 // Set invalidations to be potentially repainted during Update(). |
| 59 void InvalidateContentRect(const gfx::Rect& content_rect); | 58 void InvalidateContentRect(const gfx::Rect& content_rect); |
| 60 | 59 |
| 61 // Reset state on tiles that will be used for updating the layer. | 60 // Reset state on tiles that will be used for updating the layer. |
| 62 void ResetUpdateState(); | 61 void ResetUpdateState(); |
| 63 | 62 |
| 64 // After preparing an update, returns true if more painting is needed. | 63 // After preparing an update, returns true if more painting is needed. |
| 65 bool NeedsIdlePaint(); | 64 bool NeedsIdlePaint(); |
| 66 gfx::Rect IdlePaintRect(); | 65 gfx::Rect IdlePaintRect(); |
| 67 | 66 |
| 68 bool SkipsDraw() const { return skips_draw_; } | 67 bool SkipsDraw() const { return skips_draw_; } |
| 69 | 68 |
| 70 virtual bool HasDrawableContent() const override; | 69 bool HasDrawableContent() const override; |
| 71 | 70 |
| 72 // Virtual for testing | 71 // Virtual for testing |
| 73 virtual PrioritizedResourceManager* ResourceManager(); | 72 virtual PrioritizedResourceManager* ResourceManager(); |
| 74 const LayerTilingData* TilerForTesting() const { return tiler_.get(); } | 73 const LayerTilingData* TilerForTesting() const { return tiler_.get(); } |
| 75 const PrioritizedResource* ResourceAtForTesting(int i, int j) const; | 74 const PrioritizedResource* ResourceAtForTesting(int i, int j) const; |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 77 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
| 79 override; | |
| 80 | 78 |
| 81 void CreateTilerIfNeeded(); | 79 void CreateTilerIfNeeded(); |
| 82 void set_tiling_option(TilingOption tiling_option) { | 80 void set_tiling_option(TilingOption tiling_option) { |
| 83 tiling_option_ = tiling_option; | 81 tiling_option_ = tiling_option; |
| 84 } | 82 } |
| 85 | 83 |
| 86 bool TileOnlyNeedsPartialUpdate(UpdatableTile* tile); | 84 bool TileOnlyNeedsPartialUpdate(UpdatableTile* tile); |
| 87 bool TileNeedsBufferedUpdate(UpdatableTile* tile); | 85 bool TileNeedsBufferedUpdate(UpdatableTile* tile); |
| 88 | 86 |
| 89 void MarkOcclusionsAndRequestTextures( | 87 void MarkOcclusionsAndRequestTextures( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 137 |
| 140 TilingOption tiling_option_; | 138 TilingOption tiling_option_; |
| 141 scoped_ptr<LayerTilingData> tiler_; | 139 scoped_ptr<LayerTilingData> tiler_; |
| 142 | 140 |
| 143 DISALLOW_COPY_AND_ASSIGN(TiledLayer); | 141 DISALLOW_COPY_AND_ASSIGN(TiledLayer); |
| 144 }; | 142 }; |
| 145 | 143 |
| 146 } // namespace cc | 144 } // namespace cc |
| 147 | 145 |
| 148 #endif // CC_LAYERS_TILED_LAYER_H_ | 146 #endif // CC_LAYERS_TILED_LAYER_H_ |
| OLD | NEW |