tiled_layer_impl.h revision 116680a4aac90f2aa7413d9095a592090648e557
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.
4
5#ifndef CC_LAYERS_TILED_LAYER_IMPL_H_
6#define CC_LAYERS_TILED_LAYER_IMPL_H_
7
8#include <string>
9
10#include "cc/base/cc_export.h"
11#include "cc/layers/layer_impl.h"
12
13namespace cc {
14
15class LayerTilingData;
16class DrawableTile;
17
18class CC_EXPORT TiledLayerImpl : public LayerImpl {
19 public:
20  static scoped_ptr<TiledLayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
21    return make_scoped_ptr(new TiledLayerImpl(tree_impl, id));
22  }
23  virtual ~TiledLayerImpl();
24
25  virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
26      OVERRIDE;
27  virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
28
29  virtual bool WillDraw(DrawMode draw_mode,
30                        ResourceProvider* resource_provider) OVERRIDE;
31  virtual void AppendQuads(RenderPass* render_pass,
32                           const OcclusionTracker<LayerImpl>& occlusion_tracker,
33                           AppendQuadsData* append_quads_data) OVERRIDE;
34
35  virtual ResourceProvider::ResourceId ContentsResourceId() const OVERRIDE;
36
37  void set_skips_draw(bool skips_draw) { skips_draw_ = skips_draw; }
38  void SetTilingData(const LayerTilingData& tiler);
39  void PushTileProperties(int i,
40                          int j,
41                          ResourceProvider::ResourceId resource,
42                          const gfx::Rect& opaque_rect,
43                          bool contents_swizzled);
44  void PushInvalidTile(int i, int j);
45
46  virtual Region VisibleContentOpaqueRegion() const OVERRIDE;
47  virtual void ReleaseResources() OVERRIDE;
48
49  const LayerTilingData* TilingForTesting() const { return tiler_.get(); }
50
51  virtual size_t GPUMemoryUsageInBytes() const OVERRIDE;
52
53 protected:
54  TiledLayerImpl(LayerTreeImpl* tree_impl, int id);
55  // Exposed for testing.
56  bool HasTileAt(int i, int j) const;
57  bool HasResourceIdForTileAt(int i, int j) const;
58
59  virtual void GetDebugBorderProperties(SkColor* color, float* width) const
60      OVERRIDE;
61  virtual void AsValueInto(base::DictionaryValue* state) const OVERRIDE;
62
63 private:
64  virtual const char* LayerTypeAsString() const OVERRIDE;
65
66  DrawableTile* TileAt(int i, int j) const;
67  DrawableTile* CreateTile(int i, int j);
68
69  bool skips_draw_;
70
71  scoped_ptr<LayerTilingData> tiler_;
72
73  DISALLOW_COPY_AND_ASSIGN(TiledLayerImpl);
74};
75
76}  // namespace cc
77
78#endif  // CC_LAYERS_TILED_LAYER_IMPL_H_
79