Remove NavigationRequestInfo::is_showing.
[chromium-blink-merge.git] / cc / layers / tiled_layer.h
blob9f482c834546e03632a9cd9e355cdaabbbb4af79
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
3 // found in the LICENSE file.
5 #ifndef CC_LAYERS_TILED_LAYER_H_
6 #define CC_LAYERS_TILED_LAYER_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/layers/contents_scaling_layer.h"
10 #include "cc/resources/layer_tiling_data.h"
11 #include "cc/resources/resource_format.h"
13 namespace cc {
14 class LayerUpdater;
15 class PrioritizedResourceManager;
16 class PrioritizedResource;
17 class UpdatableTile;
19 class CC_EXPORT TiledLayer : public ContentsScalingLayer {
20 public:
21 enum TilingOption {
22 ALWAYS_TILE,
23 NEVER_TILE,
24 AUTO_TILE,
27 // Layer implementation.
28 virtual void SetIsMask(bool is_mask) OVERRIDE;
29 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
30 virtual void ReduceMemoryUsage() OVERRIDE;
31 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE;
32 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
33 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
34 OVERRIDE;
35 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const OVERRIDE;
36 virtual bool Update(ResourceUpdateQueue* queue,
37 const OcclusionTracker<Layer>* occlusion) OVERRIDE;
38 virtual void OnOutputSurfaceCreated() OVERRIDE;
40 protected:
41 TiledLayer();
42 virtual ~TiledLayer();
44 void UpdateTileSizeAndTilingOption();
45 void UpdateBounds();
47 // Exposed to subclasses for testing.
48 void SetTileSize(const gfx::Size& size);
49 void SetTextureFormat(ResourceFormat texture_format) {
50 texture_format_ = texture_format;
52 void SetBorderTexelOption(LayerTilingData::BorderTexelOption option);
53 size_t NumPaintedTiles() { return tiler_->tiles().size(); }
55 virtual LayerUpdater* Updater() const = 0;
56 virtual void CreateUpdaterIfNeeded() = 0;
58 // Set invalidations to be potentially repainted during Update().
59 void InvalidateContentRect(const gfx::Rect& content_rect);
61 // Reset state on tiles that will be used for updating the layer.
62 void ResetUpdateState();
64 // After preparing an update, returns true if more painting is needed.
65 bool NeedsIdlePaint();
66 gfx::Rect IdlePaintRect();
68 bool SkipsDraw() const { return skips_draw_; }
70 virtual bool HasDrawableContent() const OVERRIDE;
72 // Virtual for testing
73 virtual PrioritizedResourceManager* ResourceManager();
74 const LayerTilingData* TilerForTesting() const { return tiler_.get(); }
75 const PrioritizedResource* ResourceAtForTesting(int i, int j) const;
77 private:
78 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
79 OVERRIDE;
81 void CreateTilerIfNeeded();
82 void set_tiling_option(TilingOption tiling_option) {
83 tiling_option_ = tiling_option;
86 bool TileOnlyNeedsPartialUpdate(UpdatableTile* tile);
87 bool TileNeedsBufferedUpdate(UpdatableTile* tile);
89 void MarkOcclusionsAndRequestTextures(
90 int left,
91 int top,
92 int right,
93 int bottom,
94 const OcclusionTracker<Layer>* occlusion);
96 bool UpdateTiles(int left,
97 int top,
98 int right,
99 int bottom,
100 ResourceUpdateQueue* queue,
101 const OcclusionTracker<Layer>* occlusion,
102 bool* did_paint);
103 bool HaveTexturesForTiles(int left,
104 int top,
105 int right,
106 int bottom,
107 bool ignore_occlusions);
108 void MarkTilesForUpdate(gfx::Rect* update_rect,
109 gfx::Rect* paint_rect,
110 int left,
111 int top,
112 int right,
113 int bottom,
114 bool ignore_occlusions);
115 void UpdateTileTextures(const gfx::Rect& update_rect,
116 const gfx::Rect& paint_rect,
117 int left,
118 int top,
119 int right,
120 int bottom,
121 ResourceUpdateQueue* queue,
122 const OcclusionTracker<Layer>* occlusion);
123 void UpdateScrollPrediction();
125 UpdatableTile* TileAt(int i, int j) const;
126 UpdatableTile* CreateTile(int i, int j);
128 bool IsSmallAnimatedLayer() const;
130 ResourceFormat texture_format_;
131 bool skips_draw_;
132 bool failed_update_;
134 // Used for predictive painting.
135 gfx::Vector2d predicted_scroll_;
136 gfx::Rect predicted_visible_rect_;
137 gfx::Rect previous_visible_rect_;
138 gfx::Size previous_content_bounds_;
140 TilingOption tiling_option_;
141 scoped_ptr<LayerTilingData> tiler_;
143 DISALLOW_COPY_AND_ASSIGN(TiledLayer);
146 } // namespace cc
148 #endif // CC_LAYERS_TILED_LAYER_H_