1 // Copyright 2013 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/layers/picture_layer.h"
7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/picture_layer_impl.h"
9 #include "cc/resources/resource_update_queue.h"
10 #include "cc/test/fake_layer_tree_host.h"
11 #include "cc/test/fake_picture_layer_impl.h"
12 #include "cc/test/fake_proxy.h"
13 #include "cc/test/impl_side_painting_settings.h"
14 #include "cc/trees/occlusion_tracker.h"
15 #include "testing/gtest/include/gtest/gtest.h"
20 class MockContentLayerClient
: public ContentLayerClient
{
22 virtual void PaintContents(SkCanvas
* canvas
,
23 const gfx::Rect
& clip
,
24 gfx::RectF
* opaque
) OVERRIDE
{}
25 virtual void DidChangeLayerCanUseLCDText() OVERRIDE
{}
28 TEST(PictureLayerTest
, NoTilesIfEmptyBounds
) {
29 MockContentLayerClient client
;
30 scoped_refptr
<PictureLayer
> layer
= PictureLayer::Create(&client
);
31 layer
->SetBounds(gfx::Size(10, 10));
33 scoped_ptr
<FakeLayerTreeHost
> host
= FakeLayerTreeHost::Create();
34 host
->SetRootLayer(layer
);
35 layer
->SetIsDrawable(true);
36 layer
->SavePaintProperties();
38 OcclusionTracker
occlusion(gfx::Rect(0, 0, 1000, 1000), false);
39 scoped_ptr
<ResourceUpdateQueue
> queue(new ResourceUpdateQueue
);
40 layer
->Update(queue
.get(), &occlusion
);
42 layer
->SetBounds(gfx::Size(0, 0));
43 layer
->SavePaintProperties();
44 // Intentionally skipping Update since it would normally be skipped on
45 // a layer with empty bounds.
49 proxy
.SetCurrentThreadIsImplThread(true);
52 FakeLayerTreeHostImpl
host_impl(ImplSidePaintingSettings(), &proxy
);
53 host_impl
.CreatePendingTree();
54 scoped_ptr
<FakePictureLayerImpl
> layer_impl
=
55 FakePictureLayerImpl::Create(host_impl
.pending_tree(), 1);
57 layer
->PushPropertiesTo(layer_impl
.get());
58 EXPECT_FALSE(layer_impl
->CanHaveTilings());
59 EXPECT_TRUE(layer_impl
->bounds() == gfx::Size(0, 0));
60 EXPECT_TRUE(layer_impl
->pile()->size() == gfx::Size(0, 0));
61 EXPECT_TRUE(layer_impl
->pile()->recorded_region().IsEmpty());
64 proxy
.SetCurrentThreadIsImplThread(false);