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 #include "cc/test/fake_content_layer.h"
7 #include "cc/resources/content_layer_updater.h"
8 #include "cc/resources/prioritized_resource.h"
9 #include "cc/test/fake_content_layer_impl.h"
13 class FakeContentLayerUpdater
: public ContentLayerUpdater
{
15 using ContentLayerUpdater::paint_rect
;
18 ~FakeContentLayerUpdater() override
{}
21 FakeContentLayer::FakeContentLayer(const LayerSettings
& settings
,
22 ContentLayerClient
* client
)
23 : ContentLayer(settings
, client
),
25 push_properties_count_(0),
26 output_surface_created_count_(0),
27 always_update_resources_(false) {
28 SetBounds(gfx::Size(1, 1));
32 FakeContentLayer::~FakeContentLayer() {}
34 scoped_ptr
<LayerImpl
> FakeContentLayer::CreateLayerImpl(
35 LayerTreeImpl
* tree_impl
) {
36 return FakeContentLayerImpl::Create(tree_impl
, layer_id_
);
39 bool FakeContentLayer::Update(ResourceUpdateQueue
* queue
,
40 const OcclusionTracker
<Layer
>* occlusion
) {
41 bool updated
= ContentLayer::Update(queue
, occlusion
);
43 return updated
|| always_update_resources_
;
46 gfx::Rect
FakeContentLayer::LastPaintRect() const {
47 return (static_cast<FakeContentLayerUpdater
*>(Updater()))->paint_rect();
50 void FakeContentLayer::PushPropertiesTo(LayerImpl
* layer
) {
51 ContentLayer::PushPropertiesTo(layer
);
52 push_properties_count_
++;
55 void FakeContentLayer::OnOutputSurfaceCreated() {
56 ContentLayer::OnOutputSurfaceCreated();
57 output_surface_created_count_
++;
60 bool FakeContentLayer::HaveBackingAt(int i
, int j
) {
61 const PrioritizedResource
* resource
= ResourceAtForTesting(i
, j
);
62 return resource
&& resource
->have_backing_texture();