Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Side by Side Diff: cc/test/pixel_test.h

Issue 13863015: Add flag for drawing layers to screen with Ganesh (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use kTopLeft Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "cc/output/gl_renderer.h"
6 #include "cc/quads/render_pass.h" 7 #include "cc/quads/render_pass.h"
7 #include "cc/test/pixel_comparator.h" 8 #include "cc/test/pixel_comparator.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/size.h" 10 #include "ui/gfx/size.h"
10 11
11 #ifndef CC_TEST_PIXEL_TEST_H_ 12 #ifndef CC_TEST_PIXEL_TEST_H_
12 #define CC_TEST_PIXEL_TEST_H_ 13 #define CC_TEST_PIXEL_TEST_H_
13 14
14 namespace cc { 15 namespace cc {
15 class DirectRenderer; 16 class DirectRenderer;
16 class GLRenderer;
17 class SoftwareRenderer; 17 class SoftwareRenderer;
18 class OutputSurface; 18 class OutputSurface;
19 class ResourceProvider; 19 class ResourceProvider;
20 20
21 class PixelTest : public testing::Test { 21 class PixelTest : public testing::Test {
22 protected: 22 protected:
23 PixelTest(); 23 PixelTest();
24 virtual ~PixelTest(); 24 virtual ~PixelTest();
25 25
26 bool RunPixelTest(RenderPassList* pass_list, 26 bool RunPixelTest(RenderPassList* pass_list,
27 const base::FilePath& ref_file, 27 const base::FilePath& ref_file,
28 const PixelComparator& comparator); 28 const PixelComparator& comparator);
29 29
30 bool RunPixelTestWithReadbackTarget(RenderPassList* pass_list, 30 bool RunPixelTestWithReadbackTarget(RenderPassList* pass_list,
31 RenderPass* target, 31 RenderPass* target,
32 const base::FilePath& ref_file, 32 const base::FilePath& ref_file,
33 const PixelComparator& comparator); 33 const PixelComparator& comparator);
34 34
35 gfx::Size device_viewport_size_; 35 gfx::Size device_viewport_size_;
36 scoped_ptr<OutputSurface> output_surface_; 36 scoped_ptr<OutputSurface> output_surface_;
37 scoped_ptr<ResourceProvider> resource_provider_; 37 scoped_ptr<ResourceProvider> resource_provider_;
38 class PixelTestRendererClient; 38 class PixelTestRendererClient;
39 scoped_ptr<PixelTestRendererClient> fake_client_; 39 scoped_ptr<PixelTestRendererClient> fake_client_;
40 scoped_ptr<DirectRenderer> renderer_; 40 scoped_ptr<DirectRenderer> renderer_;
41 scoped_ptr<SkBitmap> result_bitmap_; 41 scoped_ptr<SkBitmap> result_bitmap_;
42 42
43 void SetUpGLRenderer(); 43 void SetUpGLRenderer(bool use_ganesh);
44 void SetUpSoftwareRenderer(); 44 void SetUpSoftwareRenderer();
45 45
46 private: 46 private:
47 void ReadbackResult(base::Closure quit_run_loop, scoped_ptr<SkBitmap> bitmap); 47 void ReadbackResult(base::Closure quit_run_loop, scoped_ptr<SkBitmap> bitmap);
48 48
49 bool PixelsMatchReference(const base::FilePath& ref_file, 49 bool PixelsMatchReference(const base::FilePath& ref_file,
50 const PixelComparator& comparator); 50 const PixelComparator& comparator);
51 }; 51 };
52 52
53 template<typename RendererType> 53 template<typename RendererType>
54 class RendererPixelTest : public PixelTest { 54 class RendererPixelTest : public PixelTest {
55 public: 55 public:
56 RendererType* renderer() { 56 RendererType* renderer() {
57 return static_cast<RendererType*>(renderer_.get()); 57 return static_cast<RendererType*>(renderer_.get());
58 } 58 }
59 59
60 bool UseGanesh() const;
61
60 protected: 62 protected:
61 virtual void SetUp() OVERRIDE; 63 void SetUp();
danakj 2013/05/15 20:33:16 why isnt it virtual anymore?
enne (OOO) 2013/05/15 22:34:38 Changed back. (At some point as I was iterating o
64 };
65
66 // A simple wrapper to differentiate a renderer that should use ganesh
67 // and one that shouldn't in templates.
68 class GLRendererWithGanesh : public GLRenderer {
69 public:
70 GLRendererWithGanesh(RendererClient* client,
71 OutputSurface* output_surface,
72 ResourceProvider* resource_provider,
73 int highp_threshold_min)
74 : GLRenderer(client,
75 output_surface,
76 resource_provider,
77 highp_threshold_min) {}
62 }; 78 };
63 79
64 template<> 80 template<>
65 inline void RendererPixelTest<GLRenderer>::SetUp() { 81 inline void RendererPixelTest<GLRenderer>::SetUp() {
66 SetUpGLRenderer(); 82 SetUpGLRenderer(false);
67 } 83 }
68 84
69 template<> 85 template<>
86 inline bool RendererPixelTest<GLRenderer>::UseGanesh() const {
87 return false;
88 }
89
90 template<>
91 inline void RendererPixelTest<GLRendererWithGanesh>::SetUp() {
92 SetUpGLRenderer(true);
93 }
94
95 template<>
96 inline bool RendererPixelTest<GLRendererWithGanesh>::UseGanesh() const {
97 return true;
98 }
99
100 template<>
70 inline void RendererPixelTest<SoftwareRenderer>::SetUp() { 101 inline void RendererPixelTest<SoftwareRenderer>::SetUp() {
71 SetUpSoftwareRenderer(); 102 SetUpSoftwareRenderer();
72 } 103 }
73 104
105 template<>
106 inline bool RendererPixelTest<SoftwareRenderer>::UseGanesh() const {
107 return false;
108 }
109
74 typedef RendererPixelTest<GLRenderer> GLRendererPixelTest; 110 typedef RendererPixelTest<GLRenderer> GLRendererPixelTest;
111 typedef RendererPixelTest<GLRendererWithGanesh> GLRendererGaneshPixelTest;
75 typedef RendererPixelTest<SoftwareRenderer> SoftwareRendererPixelTest; 112 typedef RendererPixelTest<SoftwareRenderer> SoftwareRendererPixelTest;
76 113
77 } // namespace cc 114 } // namespace cc
78 115
79 #endif // CC_TEST_PIXEL_TEST_H_ 116 #endif // CC_TEST_PIXEL_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698