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.
7 #include "base/files/file_path.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/test/layer_tree_test.h"
12 #ifndef CC_TEST_LAYER_TREE_PIXEL_TEST_H_
13 #define CC_TEST_LAYER_TREE_PIXEL_TEST_H_
18 class CopyOutputRequest
;
19 class CopyOutputResult
;
21 class PixelComparator
;
22 class SolidColorLayer
;
26 class LayerTreePixelTest
: public LayerTreeTest
{
29 virtual ~LayerTreePixelTest();
31 virtual scoped_ptr
<OutputSurface
> CreateOutputSurface(bool fallback
) OVERRIDE
;
32 virtual scoped_refptr
<cc::ContextProvider
>
33 OffscreenContextProviderForMainThread() OVERRIDE
;
34 virtual scoped_refptr
<cc::ContextProvider
>
35 OffscreenContextProviderForCompositorThread() OVERRIDE
;
37 virtual scoped_ptr
<CopyOutputRequest
> CreateCopyOutputRequest();
39 void ReadbackResult(scoped_ptr
<CopyOutputResult
> result
);
41 virtual void BeginTest() OVERRIDE
;
42 virtual void SetupTree() OVERRIDE
;
43 virtual void AfterTest() OVERRIDE
;
44 virtual void EndTest() OVERRIDE
;
48 scoped_refptr
<SolidColorLayer
> CreateSolidColorLayer(gfx::Rect rect
,
50 scoped_refptr
<SolidColorLayer
> CreateSolidColorLayerWithBorder(
54 SkColor border_color
);
55 scoped_refptr
<TextureLayer
> CreateTextureLayer(gfx::Rect rect
,
56 const SkBitmap
& bitmap
);
61 SOFTWARE_WITH_DEFAULT
,
65 void RunPixelTest(PixelTestType type
,
66 scoped_refptr
<Layer
> content_root
,
67 base::FilePath file_name
);
69 void RunPixelTestWithReadbackTarget(PixelTestType type
,
70 scoped_refptr
<Layer
> content_root
,
72 base::FilePath file_name
);
74 scoped_ptr
<SkBitmap
> CopyTextureMailboxToBitmap(
76 const TextureMailbox
& texture_mailbox
);
78 TextureMailbox
CopyBitmapToTextureMailboxAsTexture(const SkBitmap
& bitmap
);
80 void ReleaseTextureMailbox(
81 scoped_ptr
<WebKit::WebGraphicsContext3D
> context3d
,
86 // Common CSS colors defined for tests to use.
88 kCSSOrange
= 0xffffa500,
89 kCSSBrown
= 0xffa52a2a,
90 kCSSGreen
= 0xff008000,
93 scoped_ptr
<PixelComparator
> pixel_comparator_
;
94 PixelTestType test_type_
;
95 scoped_refptr
<Layer
> content_root_
;
96 Layer
* readback_target_
;
97 base::FilePath ref_file_
;
98 scoped_ptr
<SkBitmap
> result_bitmap_
;
99 std::vector
<scoped_refptr
<TextureLayer
> > texture_layers_
;
100 int pending_texture_mailbox_callbacks_
;
105 #endif // CC_TEST_LAYER_TREE_PIXEL_TEST_H_