OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_APPLY_FRAMEBUFFER_ATTACHMENT_CMAA_I
NTEL_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_APPLY_FRAMEBUFFER_ATTACHMENT_CMAA_I
NTEL_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_APPLY_FRAMEBUFFER_ATTACHMENT_CMAA_I
NTEL_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_APPLY_FRAMEBUFFER_ATTACHMENT_CMAA_I
NTEL_H_ |
7 | 7 |
8 #include "gpu/command_buffer/service/gl_utils.h" | 8 #include "gpu/command_buffer/service/gl_utils.h" |
9 #include "gpu/gpu_export.h" | 9 #include "gpu/gpu_export.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 class CMAAEffect; | 12 class CMAAEffect; |
13 } | 13 } |
14 | 14 |
15 namespace gpu { | 15 namespace gpu { |
16 namespace gles2 { | 16 namespace gles2 { |
| 17 class CopyTextureCHROMIUMResourceManager; |
17 class GLES2Decoder; | 18 class GLES2Decoder; |
18 class Framebuffer; | 19 class Framebuffer; |
19 | 20 |
20 // This class encapsulates the resources required to implement the | 21 // This class encapsulates the resources required to implement the |
21 // GL_INTEL_framebuffer_CMAA extension via shaders. | 22 // GL_INTEL_framebuffer_CMAA extension via shaders. |
22 // | 23 // |
23 // The CMAA Conservative Morphological Anti-Aliasing) algorithm is applied to | 24 // The CMAA Conservative Morphological Anti-Aliasing) algorithm is applied to |
24 // all color attachments of the currently bound draw framebuffer. | 25 // all color attachments of the currently bound draw framebuffer. |
25 // | 26 // |
26 // Reference GL_INTEL_framebuffer_CMAA for details. | 27 // Reference GL_INTEL_framebuffer_CMAA for details. |
27 class GPU_EXPORT ApplyFramebufferAttachmentCMAAINTELResourceManager { | 28 class GPU_EXPORT ApplyFramebufferAttachmentCMAAINTELResourceManager { |
28 public: | 29 public: |
29 ApplyFramebufferAttachmentCMAAINTELResourceManager(); | 30 ApplyFramebufferAttachmentCMAAINTELResourceManager(); |
30 ~ApplyFramebufferAttachmentCMAAINTELResourceManager(); | 31 ~ApplyFramebufferAttachmentCMAAINTELResourceManager(); |
31 | 32 |
32 void Initialize(gles2::GLES2Decoder* decoder); | 33 void Initialize(gles2::GLES2Decoder* decoder); |
33 void Destroy(); | 34 void Destroy(); |
34 | 35 |
35 // Applies the algorithm to the color attachments of the currently bound draw | 36 // Applies the algorithm to the color attachments of the currently bound draw |
36 // framebuffer. | 37 // framebuffer. |
37 void ApplyFramebufferAttachmentCMAAINTEL(gles2::GLES2Decoder* decoder, | 38 void ApplyFramebufferAttachmentCMAAINTEL( |
38 gles2::Framebuffer* framebuffer); | 39 gles2::GLES2Decoder* decoder, |
| 40 gles2::Framebuffer* framebuffer, |
| 41 gles2::CopyTextureCHROMIUMResourceManager* copier); |
39 | 42 |
40 private: | 43 private: |
41 // Applies the CMAA algorithm to a texture. | 44 // Applies the CMAA algorithm to a texture. |
42 void ApplyCMAAEffectTexture(GLuint source_texture, | 45 void ApplyCMAAEffectTexture(GLuint source_texture, |
43 GLuint dest_texture, | 46 GLuint dest_texture, |
44 bool do_copy); | 47 bool do_copy); |
45 | 48 |
46 void OnSize(GLint width, GLint height); | 49 void OnSize(GLint width, GLint height); |
47 void ReleaseTextures(); | 50 void ReleaseTextures(); |
48 | 51 |
49 void CopyTexture(GLint source, GLint dest); | |
50 GLuint CreateProgram(const char* defines, | 52 GLuint CreateProgram(const char* defines, |
51 const char* vs_source, | 53 const char* vs_source, |
52 const char* fs_source); | 54 const char* fs_source); |
53 GLuint CreateShader(GLenum type, const char* defines, const char* source); | 55 GLuint CreateShader(GLenum type, const char* defines, const char* source); |
54 | 56 |
55 bool initialized_; | 57 bool initialized_; |
56 bool textures_initialized_; | 58 bool textures_initialized_; |
57 bool is_in_gamma_correct_mode_; | 59 bool is_in_gamma_correct_mode_; |
58 bool supports_usampler_; | 60 bool supports_usampler_; |
59 bool supports_r8_image_; | 61 bool supports_r8_image_; |
60 bool supports_r8_read_format_; | 62 bool supports_r8_read_format_; |
61 bool is_gles31_compatible_; | 63 bool is_gles31_compatible_; |
62 | 64 |
63 int frame_id_; | 65 int frame_id_; |
64 | 66 |
65 GLint width_; | 67 GLint width_; |
66 GLint height_; | 68 GLint height_; |
67 | 69 |
68 GLuint copy_to_framebuffer_shader_; | |
69 GLuint edges0_shader_; | 70 GLuint edges0_shader_; |
70 GLuint edges1_shader_; | 71 GLuint edges1_shader_; |
71 GLuint edges_combine_shader_; | 72 GLuint edges_combine_shader_; |
72 GLuint process_and_apply_shader_; | 73 GLuint process_and_apply_shader_; |
73 GLuint debug_display_edges_shader_; | 74 GLuint debug_display_edges_shader_; |
74 | 75 |
75 GLuint cmaa_framebuffer_; | 76 GLuint cmaa_framebuffer_; |
76 GLuint copy_framebuffer_; | |
77 | 77 |
78 GLuint rgba8_texture_; | 78 GLuint rgba8_texture_; |
79 GLuint working_color_texture_; | 79 GLuint working_color_texture_; |
80 GLuint edges0_texture_; | 80 GLuint edges0_texture_; |
81 GLuint edges1_texture_; | 81 GLuint edges1_texture_; |
82 GLuint mini4_edge_texture_; | 82 GLuint mini4_edge_texture_; |
83 GLuint mini4_edge_depth_texture_; | 83 GLuint mini4_edge_depth_texture_; |
84 | 84 |
85 GLuint edges0_shader_result_rgba_texture_slot1_; | 85 GLuint edges0_shader_result_rgba_texture_slot1_; |
86 GLuint edges0_shader_target_texture_slot2_; | 86 GLuint edges0_shader_target_texture_slot2_; |
87 GLuint edges1_shader_result_edge_texture_; | 87 GLuint edges1_shader_result_edge_texture_; |
88 GLuint process_and_apply_shader_result_rgba_texture_slot1_; | 88 GLuint process_and_apply_shader_result_rgba_texture_slot1_; |
89 GLuint edges_combine_shader_result_edge_texture_; | 89 GLuint edges_combine_shader_result_edge_texture_; |
90 | 90 |
91 static const char vert_str_[]; | 91 static const char vert_str_[]; |
92 static const char cmaa_frag_s1_[]; | 92 static const char cmaa_frag_s1_[]; |
93 static const char cmaa_frag_s2_[]; | 93 static const char cmaa_frag_s2_[]; |
94 static const char copy_frag_str_[]; | |
95 | 94 |
96 DISALLOW_COPY_AND_ASSIGN(ApplyFramebufferAttachmentCMAAINTELResourceManager); | 95 DISALLOW_COPY_AND_ASSIGN(ApplyFramebufferAttachmentCMAAINTELResourceManager); |
97 }; | 96 }; |
98 | 97 |
99 } // namespace gles2 | 98 } // namespace gles2 |
100 } // namespace gpu | 99 } // namespace gpu |
101 | 100 |
102 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_APPLY_FRAMEBUFFER_ATTACHMENT_CMA
A_INTEL_H_ | 101 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_APPLY_FRAMEBUFFER_ATTACHMENT_CMA
A_INTEL_H_ |
OLD | NEW |