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/resources/single_release_callback.h"
11 #include "cc/test/layer_tree_test.h"
13 #ifndef CC_TEST_LAYER_TREE_PIXEL_TEST_H_
14 #define CC_TEST_LAYER_TREE_PIXEL_TEST_H_
19 class CopyOutputRequest;
20 class CopyOutputResult;
22 class PixelComparator;
23 class SolidColorLayer;
27 class LayerTreePixelTest : public LayerTreeTest {
30 virtual ~LayerTreePixelTest();
32 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE;
33 virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE;
35 virtual scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest();
37 void ReadbackResult(scoped_ptr<CopyOutputResult> result);
39 virtual void BeginTest() OVERRIDE;
40 virtual void SetupTree() OVERRIDE;
41 virtual void AfterTest() OVERRIDE;
42 virtual void EndTest() OVERRIDE;
46 scoped_refptr<SolidColorLayer> CreateSolidColorLayer(gfx::Rect rect,
48 scoped_refptr<SolidColorLayer> CreateSolidColorLayerWithBorder(
52 SkColor border_color);
53 scoped_refptr<TextureLayer> CreateTextureLayer(gfx::Rect rect,
54 const SkBitmap& bitmap);
59 SOFTWARE_WITH_DEFAULT,
63 void RunPixelTest(PixelTestType type,
64 scoped_refptr<Layer> content_root,
65 base::FilePath file_name);
67 void RunPixelTestWithReadbackTarget(PixelTestType type,
68 scoped_refptr<Layer> content_root,
70 base::FilePath file_name);
72 scoped_ptr<SkBitmap> CopyTextureMailboxToBitmap(
74 const TextureMailbox& texture_mailbox);
76 void CopyBitmapToTextureMailboxAsTexture(
77 const SkBitmap& bitmap,
78 TextureMailbox* texture_mailbox,
79 scoped_ptr<SingleReleaseCallback>* release_callback);
81 void ReleaseTextureMailbox(
82 scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
87 // Common CSS colors defined for tests to use.
89 kCSSOrange = 0xffffa500,
90 kCSSBrown = 0xffa52a2a,
91 kCSSGreen = 0xff008000,
94 scoped_ptr<PixelComparator> pixel_comparator_;
95 PixelTestType test_type_;
96 scoped_refptr<Layer> content_root_;
97 Layer* readback_target_;
98 base::FilePath ref_file_;
99 scoped_ptr<SkBitmap> result_bitmap_;
100 std::vector<scoped_refptr<TextureLayer> > texture_layers_;
101 int pending_texture_mailbox_callbacks_;
102 bool impl_side_painting_;
107 #endif // CC_TEST_LAYER_TREE_PIXEL_TEST_H_