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.
4
5 #include "cc/test/fake_content_layer.h"
6
7 #include "cc/resources/content_layer_updater.h"
8 #include "cc/resources/prioritized_resource.h"
9 #include "cc/test/fake_content_layer_impl.h"
10
11 namespace cc {
12
13 class FakeContentLayerUpdater : public ContentLayerUpdater {
14 public:
15 using ContentLayerUpdater::content_rect;
16
17 private:
~FakeContentLayerUpdater()18 virtual ~FakeContentLayerUpdater() {}
19 };
20
FakeContentLayer(ContentLayerClient * client)21 FakeContentLayer::FakeContentLayer(ContentLayerClient* client)
22 : ContentLayer(client),
23 update_count_(0),
24 push_properties_count_(0),
25 output_surface_created_count_(0),
26 always_update_resources_(false) {
27 SetAnchorPoint(gfx::PointF(0.f, 0.f));
28 SetBounds(gfx::Size(1, 1));
29 SetIsDrawable(true);
30 }
31
~FakeContentLayer()32 FakeContentLayer::~FakeContentLayer() {}
33
CreateLayerImpl(LayerTreeImpl * tree_impl)34 scoped_ptr<LayerImpl> FakeContentLayer::CreateLayerImpl(
35 LayerTreeImpl* tree_impl) {
36 return FakeContentLayerImpl::Create(tree_impl, layer_id_).PassAs<LayerImpl>();
37 }
38
Update(ResourceUpdateQueue * queue,const OcclusionTracker * occlusion)39 bool FakeContentLayer::Update(ResourceUpdateQueue* queue,
40 const OcclusionTracker* occlusion) {
41 bool updated = ContentLayer::Update(queue, occlusion);
42 update_count_++;
43 return updated || always_update_resources_;
44 }
45
LastPaintRect() const46 gfx::Rect FakeContentLayer::LastPaintRect() const {
47 return (static_cast<FakeContentLayerUpdater*>
48 (Updater()))->content_rect();
49 }
50
PushPropertiesTo(LayerImpl * layer)51 void FakeContentLayer::PushPropertiesTo(LayerImpl* layer) {
52 ContentLayer::PushPropertiesTo(layer);
53 push_properties_count_++;
54 }
55
OnOutputSurfaceCreated()56 void FakeContentLayer::OnOutputSurfaceCreated() {
57 ContentLayer::OnOutputSurfaceCreated();
58 output_surface_created_count_++;
59 }
60
HaveBackingAt(int i,int j)61 bool FakeContentLayer::HaveBackingAt(int i, int j) {
62 const PrioritizedResource* resource = ResourceAtForTesting(i, j);
63 return resource && resource->have_backing_texture();
64 }
65
66 } // namespace cc
67