OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdio.h> | 5 #include <stdio.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <deque> | 7 #include <deque> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "media/base/media.h" |
16 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
17 #include "media/tools/shader_bench/cpu_color_painter.h" | 18 #include "media/tools/shader_bench/cpu_color_painter.h" |
18 #include "media/tools/shader_bench/gpu_color_painter.h" | 19 #include "media/tools/shader_bench/gpu_color_painter.h" |
19 #include "media/tools/shader_bench/painter.h" | 20 #include "media/tools/shader_bench/painter.h" |
20 #include "media/tools/shader_bench/window.h" | 21 #include "media/tools/shader_bench/window.h" |
21 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
22 #include "ui/gl/gl_bindings.h" | 23 #include "ui/gl/gl_bindings.h" |
23 #include "ui/gl/gl_context.h" | 24 #include "ui/gl/gl_context.h" |
24 #include "ui/gl/gl_implementation.h" | 25 #include "ui/gl/gl_implementation.h" |
25 #include "ui/gl/gl_surface.h" | 26 #include "ui/gl/gl_surface.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 dimensions.substr(x_index + 1, dimensions.length() - x_index - 1); | 121 dimensions.substr(x_index + 1, dimensions.length() - x_index - 1); |
121 base::StringToInt(str_width, &width); | 122 base::StringToInt(str_width, &width); |
122 base::StringToInt(str_height, &height); | 123 base::StringToInt(str_height, &height); |
123 | 124 |
124 // Process files. | 125 // Process files. |
125 std::deque<scoped_refptr<media::VideoFrame> > frames; | 126 std::deque<scoped_refptr<media::VideoFrame> > frames; |
126 GetFrames(file_name, width, height, num_frames, frames); | 127 GetFrames(file_name, width, height, num_frames, frames); |
127 | 128 |
128 // Initialize window and graphics context. | 129 // Initialize window and graphics context. |
129 base::AtExitManager at_exit_manager; | 130 base::AtExitManager at_exit_manager; |
| 131 media::InitializeMediaLibraryForTesting(); |
130 gfx::GLSurface::InitializeOneOff(); | 132 gfx::GLSurface::InitializeOneOff(); |
131 scoped_ptr<media::Window> window(new media::Window(width, height)); | 133 scoped_ptr<media::Window> window(new media::Window(width, height)); |
132 gfx::GLSurface* surface = | 134 scoped_refptr<gfx::GLSurface> surface = |
133 gfx::GLSurface::CreateViewGLSurface(window->PluginWindow()).get(); | 135 gfx::GLSurface::CreateViewGLSurface(window->PluginWindow()); |
134 gfx::GLContext* context = gfx::GLContext::CreateGLContext( | 136 scoped_refptr<gfx::GLContext> context = gfx::GLContext::CreateGLContext( |
135 NULL, surface, gfx::PreferDiscreteGpu).get(); | 137 NULL, surface.get(), gfx::PreferDiscreteGpu); |
136 context->MakeCurrent(surface); | 138 context->MakeCurrent(surface.get()); |
137 // This sets D3DPRESENT_INTERVAL_IMMEDIATE on Windows. | 139 // This sets D3DPRESENT_INTERVAL_IMMEDIATE on Windows. |
138 context->SetSwapInterval(0); | 140 context->SetSwapInterval(0); |
139 | 141 |
140 // Initialize and name GPU painters. | 142 // Initialize and name GPU painters. |
141 static const struct { | 143 const struct { |
142 const char* name; | 144 const char* name; |
143 GPUPainter* painter; | 145 GPUPainter* painter; |
144 } painters[] = { | 146 } painters[] = { |
145 { "CPU CSC + GPU Render", new CPUColorPainter() }, | 147 { "CPU CSC + GPU Render", new CPUColorPainter() }, |
146 { "GPU CSC/Render", new GPUColorWithLuminancePainter() }, | 148 { "GPU CSC/Render", new GPUColorWithLuminancePainter() }, |
147 }; | 149 }; |
148 | 150 |
149 // Run GPU painter tests. | 151 // Run GPU painter tests. |
150 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(painters); i++) { | 152 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(painters); i++) { |
151 scoped_ptr<GPUPainter> painter(painters[i].painter); | 153 scoped_ptr<GPUPainter> painter(painters[i].painter); |
152 painter->LoadFrames(&frames); | 154 painter->LoadFrames(&frames); |
153 painter->SetGLContext(surface, context); | 155 painter->SetGLContext(surface, context); |
154 painter->Initialize(width, height); | 156 painter->Initialize(width, height); |
155 printf("Running %s tests...", painters[i].name); | 157 printf("Running %s tests...", painters[i].name); |
156 RunTest(window.get(), painter.get()); | 158 RunTest(window.get(), painter.get()); |
157 } | 159 } |
158 | 160 |
159 return 0; | 161 return 0; |
160 } | 162 } |
OLD | NEW |