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 #ifndef MEDIA_TOOLS_SHADER_BENCH_GPU_PAINTER_H_ | 5 #ifndef MEDIA_TOOLS_SHADER_BENCH_GPU_PAINTER_H_ |
6 #define MEDIA_TOOLS_SHADER_BENCH_GPU_PAINTER_H_ | 6 #define MEDIA_TOOLS_SHADER_BENCH_GPU_PAINTER_H_ |
7 | 7 |
8 #include "media/tools/shader_bench/painter.h" | 8 #include "media/tools/shader_bench/painter.h" |
9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
11 #include "ui/gl/gl_implementation.h" | 11 #include "ui/gl/gl_implementation.h" |
12 #include "ui/gl/gl_surface.h" | 12 #include "ui/gl/gl_surface.h" |
13 | 13 |
14 // Class that renders video frames to a window via GPU. | 14 // Class that renders video frames to a window via GPU. |
15 class GPUPainter : public Painter { | 15 class GPUPainter : public Painter { |
16 public: | 16 public: |
17 GPUPainter(); | 17 GPUPainter(); |
18 virtual ~GPUPainter(); | 18 virtual ~GPUPainter(); |
19 | 19 |
20 // Returns a reference to the GL context. | 20 // Returns a reference to the GL context. |
21 gfx::GLSurface* surface() const { return surface_; } | 21 gfx::GLSurface* surface() const { return surface_; } |
22 gfx::GLContext* context() const { return context_; } | |
23 | 22 |
24 // Sets context for subsequent gl calls in this painter. | 23 // Sets context for subsequent gl calls in this painter. |
25 virtual void SetGLContext(gfx::GLSurface* surface, gfx::GLContext* context); | 24 virtual void SetGLContext(gfx::GLSurface* surface, gfx::GLContext* context); |
26 | 25 |
27 // Creates shader program into given context, from the vertex and fragment | 26 // Creates shader program into given context, from the vertex and fragment |
28 // shader source code. Returns the id of the shader program. | 27 // shader source code. Returns the id of the shader program. |
29 virtual GLuint CreateShaderProgram(const char* vertex_shader_source, | 28 virtual GLuint CreateShaderProgram(const char* vertex_shader_source, |
30 const char* fragment_shader_source); | 29 const char* fragment_shader_source); |
31 | 30 |
32 private: | 31 private: |
33 // Loads shader into given context, from the source code of the | 32 // Loads shader into given context, from the source code of the |
34 // shader. type refers to the shader type, either GL_VERTEX_SHADER or | 33 // shader. type refers to the shader type, either GL_VERTEX_SHADER or |
35 // GL_FRAGMENT_SHADER. Returns id of shader. | 34 // GL_FRAGMENT_SHADER. Returns id of shader. |
36 GLuint LoadShader(unsigned type, const char* shader_source); | 35 GLuint LoadShader(unsigned type, const char* shader_source); |
37 | 36 |
38 // Reference to the gl context. | 37 // Reference to the gl context. |
39 gfx::GLSurface* surface_; | 38 gfx::GLSurface* surface_; |
40 gfx::GLContext* context_; | 39 gfx::GLContext* context_; |
41 | 40 |
42 DISALLOW_COPY_AND_ASSIGN(GPUPainter); | 41 DISALLOW_COPY_AND_ASSIGN(GPUPainter); |
43 }; | 42 }; |
44 | 43 |
45 #endif // MEDIA_TOOLS_SHADER_BENCH_GPU_PAINTER_H_ | 44 #endif // MEDIA_TOOLS_SHADER_BENCH_GPU_PAINTER_H_ |
OLD | NEW |