1 // Copyright 2014 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 "build/build_config.h"
6 #include "cc/layers/content_layer_client.h"
7 #include "cc/layers/picture_image_layer.h"
8 #include "cc/layers/picture_layer.h"
9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/test/fake_content_layer_client.h"
11 #include "cc/test/layer_tree_pixel_test.h"
12 #include "cc/test/pixel_comparator.h"
14 #if !defined(OS_ANDROID)
19 class LayerTreeHostSynchronousPixelTest
: public LayerTreePixelTest
{
21 void InitializeSettings(LayerTreeSettings
* settings
) override
{
22 LayerTreePixelTest::InitializeSettings(settings
);
23 settings
->single_thread_proxy_scheduler
= false;
24 settings
->use_zero_copy
= true;
25 settings
->use_one_copy
= false;
28 void BeginTest() override
{
29 LayerTreePixelTest::BeginTest();
30 PostCompositeImmediatelyToMainThread();
34 TEST_F(LayerTreeHostSynchronousPixelTest
, OneContentLayer
) {
35 gfx::Size
bounds(200, 200);
37 FakeContentLayerClient client
;
39 green_paint
.setColor(SkColorSetARGB(255, 0, 255, 0));
40 client
.add_draw_rect(gfx::RectF(bounds
), green_paint
);
41 scoped_refptr
<PictureLayer
> root
=
42 PictureLayer::Create(layer_settings(), &client
);
43 root
->SetBounds(bounds
);
44 root
->SetIsDrawable(true);
46 RunSingleThreadedPixelTest(
47 PIXEL_TEST_GL
, root
, base::FilePath(FILE_PATH_LITERAL("green.png")));
50 class LayerTreeHostSynchronousGPUPixelTest
: public LayerTreePixelTest
{
52 void InitializeSettings(LayerTreeSettings
* settings
) override
{
53 LayerTreePixelTest::InitializeSettings(settings
);
54 settings
->single_thread_proxy_scheduler
= false;
55 settings
->gpu_rasterization_enabled
= true;
56 settings
->gpu_rasterization_forced
= true;
59 void BeginTest() override
{
60 LayerTreePixelTest::BeginTest();
61 PostCompositeImmediatelyToMainThread();
65 TEST_F(LayerTreeHostSynchronousGPUPixelTest
, OneContentLayer
) {
66 gfx::Size
bounds(200, 200);
68 FakeContentLayerClient client
;
70 green_paint
.setColor(SkColorSetARGB(255, 0, 255, 0));
71 client
.add_draw_rect(gfx::RectF(bounds
), green_paint
);
72 scoped_refptr
<PictureLayer
> root
=
73 PictureLayer::Create(layer_settings(), &client
);
74 root
->SetBounds(bounds
);
75 root
->SetIsDrawable(true);
77 RunSingleThreadedPixelTest(PIXEL_TEST_GL
, root
,
78 base::FilePath(FILE_PATH_LITERAL("green.png")));