| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "cc/output/texture_copier.h" | 5 #include "cc/output/texture_copier.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 9 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
| 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 11 #include "third_party/khronos/GLES2/gl2.h" | 11 #include "third_party/khronos/GLES2/gl2.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 AcceleratedTextureCopier::AcceleratedTextureCopier( | 15 AcceleratedTextureCopier::AcceleratedTextureCopier( |
| 16 WebKit::WebGraphicsContext3D* context, | 16 WebKit::WebGraphicsContext3D* context, |
| 17 bool using_bind_uniforms, | 17 bool using_bind_uniforms, |
| 18 int highp_threshold_min) | 18 int highp_threshold_min) |
| 19 : context_(context) | 19 : context_(context) |
| 20 , using_bind_uniforms_(using_bind_uniforms) | 20 , using_bind_uniforms_(using_bind_uniforms) |
| 21 , highp_threshold_min_(highp_threshold_min) { | 21 , highp_threshold_min_(highp_threshold_min) |
| 22 , highp_threshold_cache_(0) { |
| 22 DCHECK(context_); | 23 DCHECK(context_); |
| 23 GLC(context_, fbo_ = context_->createFramebuffer()); | 24 GLC(context_, fbo_ = context_->createFramebuffer()); |
| 24 GLC(context_, position_buffer_ = context_->createBuffer()); | 25 GLC(context_, position_buffer_ = context_->createBuffer()); |
| 25 | 26 |
| 26 static const float kPositions[4][4] = { { -1, -1, 0, 1 }, { 1, -1, 0, 1 }, | 27 static const float kPositions[4][4] = { { -1, -1, 0, 1 }, { 1, -1, 0, 1 }, |
| 27 { 1, 1, 0, 1 }, { -1, 1, 0, 1 } }; | 28 { 1, 1, 0, 1 }, { -1, 1, 0, 1 } }; |
| 28 | 29 |
| 29 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); | 30 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); |
| 30 GLC(context_, | 31 GLC(context_, |
| 31 context_->bufferData( | 32 context_->bufferData( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 GLC(context_, | 73 GLC(context_, |
| 73 context_->bindTexture(GL_TEXTURE_2D, parameters.source_texture)); | 74 context_->bindTexture(GL_TEXTURE_2D, parameters.source_texture)); |
| 74 GLC(context_, | 75 GLC(context_, |
| 75 context_->texParameteri( | 76 context_->texParameteri( |
| 76 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); | 77 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); |
| 77 GLC(context_, | 78 GLC(context_, |
| 78 context_->texParameteri( | 79 context_->texParameteri( |
| 79 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); | 80 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); |
| 80 | 81 |
| 81 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( | 82 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 82 context_, highp_threshold_min_, parameters.size); | 83 context_, &highp_threshold_cache_, highp_threshold_min_, parameters.size); |
| 83 if (texCoordPrecision == TexCoordPrecisionHigh) { | 84 if (texCoordPrecision == TexCoordPrecisionHigh) { |
| 84 if (!blit_program_highp_->initialized()) | 85 if (!blit_program_highp_->initialized()) |
| 85 blit_program_highp_->Initialize(context_, using_bind_uniforms_); | 86 blit_program_highp_->Initialize(context_, using_bind_uniforms_); |
| 86 | 87 |
| 87 // TODO(danakj): Use EXT_framebuffer_blit if available. | 88 // TODO(danakj): Use EXT_framebuffer_blit if available. |
| 88 GLC(context_, context_->useProgram(blit_program_highp_->program())); | 89 GLC(context_, context_->useProgram(blit_program_highp_->program())); |
| 89 } else { | 90 } else { |
| 90 if (!blit_program_->initialized()) | 91 if (!blit_program_->initialized()) |
| 91 blit_program_->Initialize(context_, using_bind_uniforms_); | 92 blit_program_->Initialize(context_, using_bind_uniforms_); |
| 92 | 93 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 123 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); | 124 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); |
| 124 | 125 |
| 125 GLC(context_, context_->enable(GL_SCISSOR_TEST)); | 126 GLC(context_, context_->enable(GL_SCISSOR_TEST)); |
| 126 } | 127 } |
| 127 | 128 |
| 128 void AcceleratedTextureCopier::Flush() { | 129 void AcceleratedTextureCopier::Flush() { |
| 129 GLC(context_, context_->flush()); | 130 GLC(context_, context_->flush()); |
| 130 } | 131 } |
| 131 | 132 |
| 132 } // namespace cc | 133 } // namespace cc |
| OLD | NEW |