OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" |
6 | 6 |
7 #include "gpu/command_buffer/service/texture_manager.h" | 7 #include "gpu/command_buffer/service/texture_manager.h" |
8 #include "ui/gl/gl_version_info.h" | 8 #include "ui/gl/gl_version_info.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 23 matching lines...) Expand all Loading... |
34 CopyTexImageResourceManager::~CopyTexImageResourceManager() {} | 34 CopyTexImageResourceManager::~CopyTexImageResourceManager() {} |
35 | 35 |
36 void CopyTexImageResourceManager::Initialize( | 36 void CopyTexImageResourceManager::Initialize( |
37 const gles2::GLES2Decoder* decoder) { | 37 const gles2::GLES2Decoder* decoder) { |
38 if (initialized_) { | 38 if (initialized_) { |
39 return; | 39 return; |
40 } | 40 } |
41 | 41 |
42 blit_program_ = glCreateProgram(); | 42 blit_program_ = glCreateProgram(); |
43 | 43 |
44 // Compile the fragment shader | 44 // Compile the vertex shader |
45 const char* vs_source = | 45 const char* vs_source = |
46 "#version 150\n" | 46 "#version 150\n" |
47 "out vec2 v_texcoord;\n" | 47 "out vec2 v_texcoord;\n" |
48 "\n" | 48 "\n" |
49 "void main()\n" | 49 "void main()\n" |
50 "{\n" | 50 "{\n" |
51 " const vec2 quad_positions[6] = vec2[6]\n" | 51 " const vec2 quad_positions[6] = vec2[6]\n" |
52 " (\n" | 52 " (\n" |
53 " vec2(0.0f, 0.0f),\n" | 53 " vec2(0.0f, 0.0f),\n" |
54 " vec2(0.0f, 1.0f),\n" | 54 " vec2(0.0f, 1.0f),\n" |
55 " vec2(1.0f, 0.0f),\n" | 55 " vec2(1.0f, 0.0f),\n" |
56 "\n" | 56 "\n" |
57 " vec2(0.0f, 1.0f),\n" | 57 " vec2(0.0f, 1.0f),\n" |
58 " vec2(1.0f, 0.0f),\n" | 58 " vec2(1.0f, 0.0f),\n" |
59 " vec2(1.0f, 1.0f)\n" | 59 " vec2(1.0f, 1.0f)\n" |
60 " );\n" | 60 " );\n" |
61 "\n" | 61 "\n" |
62 " gl_Position = vec4((quad_positions[gl_VertexID] * 2.0) - 1.0, 0.0, " | 62 " gl_Position = vec4((quad_positions[gl_VertexID] * 2.0) - 1.0, 0.0, " |
63 "1.0);\n" | 63 "1.0);\n" |
64 " v_texcoord = quad_positions[gl_VertexID];\n" | 64 " v_texcoord = quad_positions[gl_VertexID];\n" |
65 "}\n"; | 65 "}\n"; |
66 | 66 |
67 GLuint vs = glCreateShader(GL_VERTEX_SHADER); | 67 GLuint vs = glCreateShader(GL_VERTEX_SHADER); |
68 CompileShader(vs, vs_source); | 68 CompileShader(vs, vs_source); |
69 glAttachShader(blit_program_, vs); | 69 glAttachShader(blit_program_, vs); |
70 glDeleteShader(vs); | 70 glDeleteShader(vs); |
71 | 71 |
72 // Compile the vertex shader | 72 // Compile the fragment shader |
73 const char* fs_source = | 73 const char* fs_source = |
74 "#version 150\n" | 74 "#version 150\n" |
75 "uniform sampler2D u_source_texture;\n" | 75 "uniform sampler2D u_source_texture;\n" |
76 "in vec2 v_texcoord;\n" | 76 "in vec2 v_texcoord;\n" |
77 "out vec4 output_color;\n" | 77 "out vec4 output_color;\n" |
78 "\n" | 78 "\n" |
79 "void main()\n" | 79 "void main()\n" |
80 "{\n" | 80 "{\n" |
81 " output_color = texture(u_source_texture, v_texcoord);\n" | 81 " output_color = texture(u_source_texture, v_texcoord);\n" |
82 "}\n"; | 82 "}\n"; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 case GL_LUMINANCE_ALPHA: | 272 case GL_LUMINANCE_ALPHA: |
273 return true; | 273 return true; |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 return false; | 277 return false; |
278 } | 278 } |
279 | 279 |
280 } // namespace gles2 | 280 } // namespace gles2 |
281 } // namespace gpu | 281 } // namespace gpu |
OLD | NEW |