Factor out a BluetoothChannelMac base class and a BluetoothRfcommChannelMac subclass.
[chromium-blink-merge.git] / cc / test / tiled_layer_test_common.h
blobd407f6baa012ec91836a87d827e3753551ce2f16
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/base/region.h"
9 #include "cc/layers/tiled_layer.h"
10 #include "cc/layers/tiled_layer_impl.h"
11 #include "cc/resources/layer_updater.h"
12 #include "cc/resources/prioritized_resource.h"
13 #include "cc/resources/resource_provider.h"
14 #include "cc/resources/resource_update_queue.h"
15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/size.h"
18 namespace cc {
20 class FakeTiledLayer;
22 class FakeLayerUpdater : public LayerUpdater {
23 public:
24 class Resource : public LayerUpdater::Resource {
25 public:
26 Resource(FakeLayerUpdater* updater,
27 scoped_ptr<PrioritizedResource> resource);
28 virtual ~Resource();
30 virtual void Update(ResourceUpdateQueue* queue,
31 const gfx::Rect& source_rect,
32 const gfx::Vector2d& dest_offset,
33 bool partial_update) OVERRIDE;
35 private:
36 FakeLayerUpdater* layer_;
37 SkBitmap bitmap_;
39 DISALLOW_COPY_AND_ASSIGN(Resource);
42 FakeLayerUpdater();
44 virtual scoped_ptr<LayerUpdater::Resource> CreateResource(
45 PrioritizedResourceManager* resource) OVERRIDE;
47 virtual void PrepareToUpdate(const gfx::Rect& content_rect,
48 const gfx::Size& tile_size,
49 float contents_width_scale,
50 float contents_height_scale,
51 gfx::Rect* resulting_opaque_rect) OVERRIDE;
52 // Sets the rect to invalidate during the next call to PrepareToUpdate().
53 // After the next call to PrepareToUpdate() the rect is reset.
54 void SetRectToInvalidate(const gfx::Rect& rect, FakeTiledLayer* layer);
55 // Last rect passed to PrepareToUpdate().
56 gfx::Rect last_update_rect() const { return last_update_rect_; }
58 // Number of times PrepareToUpdate has been invoked.
59 int prepare_count() const { return prepare_count_; }
60 void ClearPrepareCount() { prepare_count_ = 0; }
62 // Number of times Update() has been invoked on a texture.
63 int update_count() const { return update_count_; }
64 void ClearUpdateCount() { update_count_ = 0; }
65 void Update() { update_count_++; }
67 void SetOpaquePaintRect(const gfx::Rect& opaque_paint_rect) {
68 opaque_paint_rect_ = opaque_paint_rect;
71 protected:
72 virtual ~FakeLayerUpdater();
74 private:
75 int prepare_count_;
76 int update_count_;
77 gfx::Rect rect_to_invalidate_;
78 gfx::Rect last_update_rect_;
79 gfx::Rect opaque_paint_rect_;
80 scoped_refptr<FakeTiledLayer> layer_;
82 DISALLOW_COPY_AND_ASSIGN(FakeLayerUpdater);
85 class FakeTiledLayerImpl : public TiledLayerImpl {
86 public:
87 FakeTiledLayerImpl(LayerTreeImpl* tree_impl, int id);
88 virtual ~FakeTiledLayerImpl();
90 using TiledLayerImpl::HasTileAt;
91 using TiledLayerImpl::HasResourceIdForTileAt;
94 class FakeTiledLayer : public TiledLayer {
95 public:
96 explicit FakeTiledLayer(PrioritizedResourceManager* resource_manager);
98 static gfx::Size tile_size() { return gfx::Size(100, 100); }
100 using TiledLayer::InvalidateContentRect;
101 using TiledLayer::NeedsIdlePaint;
102 using TiledLayer::SkipsDraw;
103 using TiledLayer::NumPaintedTiles;
104 using TiledLayer::IdlePaintRect;
106 virtual void SetNeedsDisplayRect(const gfx::RectF& rect) OVERRIDE;
107 const gfx::RectF& last_needs_display_rect() const {
108 return last_needs_display_rect_;
111 virtual void SetTexturePriorities(
112 const PriorityCalculator& priority_calculator) OVERRIDE;
114 virtual PrioritizedResourceManager* ResourceManager() OVERRIDE;
115 FakeLayerUpdater* fake_layer_updater() { return fake_updater_.get(); }
116 gfx::RectF update_rect() { return update_rect_; }
118 // Simulate CalcDrawProperties.
119 void UpdateContentsScale(float ideal_contents_scale);
121 void ResetNumDependentsNeedPushProperties();
123 protected:
124 virtual LayerUpdater* Updater() const OVERRIDE;
125 virtual void CreateUpdaterIfNeeded() OVERRIDE {}
126 virtual ~FakeTiledLayer();
128 private:
129 scoped_refptr<FakeLayerUpdater> fake_updater_;
130 PrioritizedResourceManager* resource_manager_;
131 gfx::RectF last_needs_display_rect_;
133 DISALLOW_COPY_AND_ASSIGN(FakeTiledLayer);
136 class FakeTiledLayerWithScaledBounds : public FakeTiledLayer {
137 public:
138 explicit FakeTiledLayerWithScaledBounds(
139 PrioritizedResourceManager* resource_manager);
141 void SetContentBounds(const gfx::Size& content_bounds);
142 virtual void CalculateContentsScale(float ideal_contents_scale,
143 float device_scale_factor,
144 float page_scale_factor,
145 float maximum_animation_contents_scale,
146 bool animating_transform_to_screen,
147 float* contents_scale_x,
148 float* contents_scale_y,
149 gfx::Size* content_bounds) OVERRIDE;
151 protected:
152 virtual ~FakeTiledLayerWithScaledBounds();
153 gfx::Size forced_content_bounds_;
155 private:
156 DISALLOW_COPY_AND_ASSIGN(FakeTiledLayerWithScaledBounds);
159 } // namespace cc
161 #endif // CC_TEST_TILED_LAYER_TEST_COMMON_H_