Revert 264226 "Reduce dependency of TiclInvalidationService on P..."
[chromium-blink-merge.git] / cc / test / layer_tree_pixel_test.h
blob16873e59e2ddffd5efe9c6734e8a5de594319899
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_
8 #include <vector>
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"
17 class SkBitmap;
19 namespace gpu {
20 class GLInProcessContext;
23 namespace cc {
24 class CopyOutputRequest;
25 class CopyOutputResult;
26 class LayerTreeHost;
27 class PixelComparator;
28 class SolidColorLayer;
29 class TextureLayer;
30 class TextureMailbox;
32 class LayerTreePixelTest : public LayerTreeTest {
33 protected:
34 LayerTreePixelTest();
35 virtual ~LayerTreePixelTest();
37 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE;
38 virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE;
39 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE;
41 virtual scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest();
43 void ReadbackResult(scoped_ptr<CopyOutputResult> result);
45 virtual void BeginTest() OVERRIDE;
46 virtual void SetupTree() OVERRIDE;
47 virtual void AfterTest() OVERRIDE;
48 virtual void EndTest() OVERRIDE;
50 void TryEndTest();
52 scoped_refptr<SolidColorLayer> CreateSolidColorLayer(const gfx::Rect& rect,
53 SkColor color);
54 scoped_refptr<SolidColorLayer> CreateSolidColorLayerWithBorder(
55 const gfx::Rect& rect,
56 SkColor color,
57 int border_width,
58 SkColor border_color);
59 scoped_refptr<TextureLayer> CreateTextureLayer(const gfx::Rect& rect,
60 const SkBitmap& bitmap);
62 enum PixelTestType {
63 GL_WITH_DEFAULT,
64 GL_WITH_BITMAP,
65 SOFTWARE_WITH_DEFAULT,
66 SOFTWARE_WITH_BITMAP
69 void RunPixelTest(PixelTestType type,
70 scoped_refptr<Layer> content_root,
71 base::FilePath file_name);
73 void RunPixelTestWithReadbackTarget(PixelTestType type,
74 scoped_refptr<Layer> content_root,
75 Layer* target,
76 base::FilePath file_name);
78 scoped_ptr<SkBitmap> CopyTextureMailboxToBitmap(
79 const gfx::Size& size,
80 const TextureMailbox& texture_mailbox);
82 void CopyBitmapToTextureMailboxAsTexture(
83 const SkBitmap& bitmap,
84 TextureMailbox* texture_mailbox,
85 scoped_ptr<SingleReleaseCallback>* release_callback);
87 void ReleaseTextureMailbox(scoped_ptr<gpu::GLInProcessContext> context,
88 uint32 texture,
89 uint32 sync_point,
90 bool lost_resource);
92 // Common CSS colors defined for tests to use.
93 enum Colors {
94 kCSSOrange = 0xffffa500,
95 kCSSBrown = 0xffa52a2a,
96 kCSSGreen = 0xff008000,
99 gfx::DisableNullDrawGLBindings enable_pixel_output_;
100 scoped_ptr<PixelComparator> pixel_comparator_;
101 PixelTestType test_type_;
102 scoped_refptr<Layer> content_root_;
103 Layer* readback_target_;
104 base::FilePath ref_file_;
105 scoped_ptr<SkBitmap> result_bitmap_;
106 std::vector<scoped_refptr<TextureLayer> > texture_layers_;
107 int pending_texture_mailbox_callbacks_;
108 bool impl_side_painting_;
111 } // namespace cc
113 #endif // CC_TEST_LAYER_TREE_PIXEL_TEST_H_