add a use_alsa gyp setting
[chromium-blink-merge.git] / cc / test / tiled_layer_test_common.h
blob2e09b79c792eaaea23fc62af4473c462bc121b55
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.
5 #ifndef CC_TEST_TILED_LAYER_TEST_COMMON_H_
6 #define CC_TEST_TILED_LAYER_TEST_COMMON_H_
8 #include "cc/layer_updater.h"
9 #include "cc/prioritized_resource.h"
10 #include "cc/region.h"
11 #include "cc/resource_provider.h"
12 #include "cc/resource_update_queue.h"
13 #include "cc/texture_copier.h"
14 #include "cc/texture_uploader.h"
15 #include "cc/tiled_layer.h"
16 #include "cc/tiled_layer_impl.h"
17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/size.h"
20 namespace cc {
22 class FakeTiledLayer;
24 class FakeLayerUpdater : public cc::LayerUpdater {
25 public:
26 class Resource : public cc::LayerUpdater::Resource {
27 public:
28 Resource(FakeLayerUpdater*, scoped_ptr<cc::PrioritizedResource>);
29 virtual ~Resource();
31 virtual void update(cc::ResourceUpdateQueue&, const gfx::Rect&, const gfx::Vector2d&, bool, cc::RenderingStats*) OVERRIDE;
33 private:
34 FakeLayerUpdater* m_layer;
35 SkBitmap m_bitmap;
38 FakeLayerUpdater();
40 virtual scoped_ptr<cc::LayerUpdater::Resource> createResource(cc::PrioritizedResourceManager*) OVERRIDE;
42 virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float, float, gfx::Rect& resultingOpaqueRect, cc::RenderingStats*) OVERRIDE;
43 // Sets the rect to invalidate during the next call to prepareToUpdate(). After the next
44 // call to prepareToUpdate() the rect is reset.
45 void setRectToInvalidate(const gfx::Rect&, FakeTiledLayer*);
46 // Last rect passed to prepareToUpdate().
47 const gfx::Rect& lastUpdateRect() const { return m_lastUpdateRect; }
49 // Number of times prepareToUpdate has been invoked.
50 int prepareCount() const { return m_prepareCount; }
51 void clearPrepareCount() { m_prepareCount = 0; }
53 // Number of times update() has been invoked on a texture.
54 int updateCount() const { return m_updateCount; }
55 void clearUpdateCount() { m_updateCount = 0; }
56 void update() { m_updateCount++; }
58 void setOpaquePaintRect(const gfx::Rect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; }
60 protected:
61 virtual ~FakeLayerUpdater();
63 private:
64 int m_prepareCount;
65 int m_updateCount;
66 gfx::Rect m_rectToInvalidate;
67 gfx::Rect m_lastUpdateRect;
68 gfx::Rect m_opaquePaintRect;
69 scoped_refptr<FakeTiledLayer> m_layer;
72 class FakeTiledLayerImpl : public cc::TiledLayerImpl {
73 public:
74 FakeTiledLayerImpl(LayerTreeImpl* treeImpl, int id);
75 virtual ~FakeTiledLayerImpl();
77 using cc::TiledLayerImpl::hasTileAt;
78 using cc::TiledLayerImpl::hasResourceIdForTileAt;
81 class FakeTiledLayer : public cc::TiledLayer {
82 public:
83 explicit FakeTiledLayer(cc::PrioritizedResourceManager*);
85 static gfx::Size tileSize() { return gfx::Size(100, 100); }
87 using cc::TiledLayer::invalidateContentRect;
88 using cc::TiledLayer::needsIdlePaint;
89 using cc::TiledLayer::skipsDraw;
90 using cc::TiledLayer::numPaintedTiles;
91 using cc::TiledLayer::idlePaintRect;
93 virtual void setNeedsDisplayRect(const gfx::RectF&) OVERRIDE;
94 const gfx::RectF& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRect; }
96 virtual void setTexturePriorities(const cc::PriorityCalculator&) OVERRIDE;
98 virtual cc::PrioritizedResourceManager* resourceManager() const OVERRIDE;
99 FakeLayerUpdater* fakeLayerUpdater() { return m_fakeUpdater.get(); }
100 gfx::RectF updateRect() { return m_updateRect; }
102 // Simulate calcDrawProperties.
103 void updateContentsScale(float idealContentsScale);
105 protected:
106 virtual cc::LayerUpdater* updater() const OVERRIDE;
107 virtual void createUpdaterIfNeeded() OVERRIDE { }
108 virtual ~FakeTiledLayer();
110 private:
111 scoped_refptr<FakeLayerUpdater> m_fakeUpdater;
112 cc::PrioritizedResourceManager* m_resourceManager;
113 gfx::RectF m_lastNeedsDisplayRect;
116 class FakeTiledLayerWithScaledBounds : public FakeTiledLayer {
117 public:
118 explicit FakeTiledLayerWithScaledBounds(cc::PrioritizedResourceManager*);
120 void setContentBounds(const gfx::Size& contentBounds);
121 virtual void calculateContentsScale(
122 float idealContentsScale,
123 bool animatingTransformToScreen,
124 float* contentsScaleX,
125 float* contentsScaleY,
126 gfx::Size* contentBounds) OVERRIDE;
127 virtual void didUpdateBounds() OVERRIDE;
129 protected:
130 virtual ~FakeTiledLayerWithScaledBounds();
131 gfx::Size m_forcedContentBounds;
134 } // namespace cc
136 #endif // CC_TEST_TILED_LAYER_TEST_COMMON_H_