layer_tree_pixel_test.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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.
4
5#include "base/files/file_path.h"
6#include "base/memory/ref_counted.h"
7#include "base/memory/scoped_ptr.h"
8#include "cc/layers/solid_color_layer.h"
9#include "cc/test/layer_tree_test.h"
10
11#ifndef CC_TEST_LAYER_TREE_PIXEL_TEST_H_
12#define CC_TEST_LAYER_TREE_PIXEL_TEST_H_
13
14namespace cc {
15class LayerTreeHost;
16class PixelComparator;
17
18class LayerTreePixelTest : public LayerTreeTest {
19 protected:
20  LayerTreePixelTest();
21  virtual ~LayerTreePixelTest();
22
23  virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE;
24  virtual scoped_refptr<cc::ContextProvider>
25      OffscreenContextProviderForMainThread() OVERRIDE;
26  virtual scoped_refptr<cc::ContextProvider>
27      OffscreenContextProviderForCompositorThread() OVERRIDE;
28
29  void ReadbackResult(scoped_ptr<SkBitmap> bitmap);
30
31  virtual void BeginTest() OVERRIDE;
32  virtual void SetupTree() OVERRIDE;
33  virtual void AfterTest() OVERRIDE;
34
35  scoped_refptr<SolidColorLayer> CreateSolidColorLayer(gfx::Rect rect,
36                                                       SkColor color);
37  scoped_refptr<SolidColorLayer> CreateSolidColorLayerWithBorder(
38      gfx::Rect rect,
39      SkColor color,
40      int border_width,
41      SkColor border_color);
42
43  void RunPixelTest(scoped_refptr<Layer> content_root,
44                    base::FilePath file_name);
45
46  // Common CSS colors defined for tests to use.
47  enum Colors {
48    kCSSOrange = 0xffffa500,
49    kCSSBrown = 0xffa52a2a,
50    kCSSGreen = 0xff008000,
51  };
52
53  scoped_ptr<PixelComparator> pixel_comparator_;
54
55 private:
56  scoped_refptr<Layer> content_root_;
57  base::FilePath ref_file_;
58};
59
60}  // namespace cc
61
62#endif  // CC_TEST_LAYER_TREE_PIXEL_TEST_H_
63