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 #ifndef CC_TEST_LAYER_TREE_PIXEL_TEST_H_
6 #define CC_TEST_LAYER_TREE_PIXEL_TEST_H_
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/resources/single_release_callback.h"
14 #include "cc/test/layer_tree_test.h"
15 #include "ui/gl/gl_implementation.h"
20 class GLInProcessContext
;
24 class CopyOutputRequest
;
25 class CopyOutputResult
;
27 class PixelComparator
;
28 class SolidColorLayer
;
32 class LayerTreePixelTest
: public LayerTreeTest
{
35 virtual ~LayerTreePixelTest();
37 virtual scoped_ptr
<OutputSurface
> CreateOutputSurface(bool fallback
) OVERRIDE
;
38 virtual void CommitCompleteOnThread(LayerTreeHostImpl
* impl
) OVERRIDE
;
40 virtual scoped_ptr
<CopyOutputRequest
> CreateCopyOutputRequest();
42 void ReadbackResult(scoped_ptr
<CopyOutputResult
> result
);
44 virtual void BeginTest() OVERRIDE
;
45 virtual void SetupTree() OVERRIDE
;
46 virtual void AfterTest() OVERRIDE
;
47 virtual void EndTest() OVERRIDE
;
51 scoped_refptr
<SolidColorLayer
> CreateSolidColorLayer(const gfx::Rect
& rect
,
53 scoped_refptr
<SolidColorLayer
> CreateSolidColorLayerWithBorder(
54 const gfx::Rect
& rect
,
57 SkColor border_color
);
58 scoped_refptr
<TextureLayer
> CreateTextureLayer(const gfx::Rect
& rect
,
59 const SkBitmap
& bitmap
);
64 SOFTWARE_WITH_DEFAULT
,
68 void RunPixelTest(PixelTestType type
,
69 scoped_refptr
<Layer
> content_root
,
70 base::FilePath file_name
);
72 void RunPixelTestWithReadbackTarget(PixelTestType type
,
73 scoped_refptr
<Layer
> content_root
,
75 base::FilePath file_name
);
77 scoped_ptr
<SkBitmap
> CopyTextureMailboxToBitmap(
78 const gfx::Size
& size
,
79 const TextureMailbox
& texture_mailbox
);
81 void CopyBitmapToTextureMailboxAsTexture(
82 const SkBitmap
& bitmap
,
83 TextureMailbox
* texture_mailbox
,
84 scoped_ptr
<SingleReleaseCallback
>* release_callback
);
86 void ReleaseTextureMailbox(scoped_ptr
<gpu::GLInProcessContext
> context
,
91 // Common CSS colors defined for tests to use.
92 static const SkColor kCSSOrange
= 0xffffa500;
93 static const SkColor kCSSBrown
= 0xffa52a2a;
94 static const SkColor kCSSGreen
= 0xff008000;
96 gfx::DisableNullDrawGLBindings enable_pixel_output_
;
97 scoped_ptr
<PixelComparator
> pixel_comparator_
;
98 PixelTestType test_type_
;
99 scoped_refptr
<Layer
> content_root_
;
100 Layer
* readback_target_
;
101 base::FilePath ref_file_
;
102 scoped_ptr
<SkBitmap
> result_bitmap_
;
103 std::vector
<scoped_refptr
<TextureLayer
> > texture_layers_
;
104 int pending_texture_mailbox_callbacks_
;
105 bool impl_side_painting_
;
110 #endif // CC_TEST_LAYER_TREE_PIXEL_TEST_H_