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