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

Side by Side Diff: content/browser/renderer_host/compositing_iosurface_shader_programs_mac.h

Issue 472663004: Revert of Remove code used by --disable-delegated-renderer on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_SHADER_PROGRAMS_MAC_ H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_SHADER_PROGRAMS_MAC_ H_
7
8 #include <OpenGL/gl.h>
9
10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h"
12
13 namespace content {
14
15 // Provides caching of the compile-and-link step for shader programs at runtime
16 // since, once compiled and linked, the programs can be shared. Callers invoke
17 // one of the UseXXX() methods to glUseProgram() the program and have its
18 // uniform variables bound with the given parameters.
19 //
20 // Note: All public methods must be invoked within the the same GL context!
21 class CompositingIOSurfaceShaderPrograms {
22 public:
23 CompositingIOSurfaceShaderPrograms();
24 ~CompositingIOSurfaceShaderPrograms();
25
26 // Reset the cache, deleting any references to currently-cached shader
27 // programs. This must be called within an active OpenGL context just before
28 // destruction.
29 void Reset();
30
31 // Begin using the "blit" program, which is set up to sample the texture at
32 // GL_TEXTURE_0. Returns false on error.
33 bool UseBlitProgram();
34
35 // Begin using the program that just draws solid white very efficiently.
36 // Returns false on error.
37 bool UseSolidWhiteProgram();
38
39 // Begin using one of the two RGB-to-YV12 color conversion programs, as
40 // specified by |pass_number| 1 or 2. The programs will sample the texture at
41 // GL_TEXTURE0, and account for scaling in the X direction by |texel_scale_x|.
42 // Returns false on error.
43 bool UseRGBToYV12Program(int pass_number, float texel_scale_x);
44
45 // |format| argument to use for glReadPixels() when reading back textures
46 // generated by the RGBToYV12 program.
47 GLenum rgb_to_yv12_output_format() const {
48 return rgb_to_yv12_output_format_;
49 }
50
51 protected:
52 FRIEND_TEST_ALL_PREFIXES(CompositingIOSurfaceTransformerTest,
53 TransformsRGBToYV12);
54
55 // Side effect: Calls Reset(), deleting any cached programs.
56 void SetOutputFormatForTesting(GLenum format);
57
58 private:
59 enum { kNumShaderPrograms = 4 };
60
61 // Helper methods to cache uniform variable locations.
62 GLuint GetShaderProgram(int which);
63 void BindUniformTextureVariable(int which, int texture_unit_offset);
64 void BindUniformTexelScaleXVariable(int which, float texel_scale_x);
65
66 // Cached values for previously-compiled/linked shader programs, and the
67 // locations of their uniform variables.
68 GLuint shader_programs_[kNumShaderPrograms];
69 GLint texture_var_locations_[kNumShaderPrograms];
70 GLint texel_scale_x_var_locations_[kNumShaderPrograms];
71
72 // Byte order of the quads generated by the RGBToYV12 shader program. Must
73 // always be GL_BGRA (default) or GL_RGBA (workaround case).
74 GLenum rgb_to_yv12_output_format_;
75
76 DISALLOW_COPY_AND_ASSIGN(CompositingIOSurfaceShaderPrograms);
77 };
78
79 } // namespace content
80
81 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_SHADER_PROGRAMS_M AC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698