| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 static const float kPositions[4][4] = { { -1, -1, 0, 1 }, { 1, -1, 0, 1 }, | 23 static const float kPositions[4][4] = { { -1, -1, 0, 1 }, { 1, -1, 0, 1 }, |
| 24 { 1, 1, 0, 1 }, { -1, 1, 0, 1 } }; | 24 { 1, 1, 0, 1 }, { -1, 1, 0, 1 } }; |
| 25 | 25 |
| 26 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); | 26 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); |
| 27 GLC(context_, | 27 GLC(context_, |
| 28 context_->bufferData( | 28 context_->bufferData( |
| 29 GL_ARRAY_BUFFER, sizeof(kPositions), kPositions, GL_STATIC_DRAW)); | 29 GL_ARRAY_BUFFER, sizeof(kPositions), kPositions, GL_STATIC_DRAW)); |
| 30 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0)); | 30 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0)); |
| 31 | 31 |
| 32 blit_program_.reset(new BlitProgram(context_)); | 32 blit_program_.reset(new BlitProgram(context_, TexCoordPrecisionMedium)); |
| 33 blit_program_highp_.reset(new BlitProgram(context_, TexCoordPrecisionHigh)); |
| 33 } | 34 } |
| 34 | 35 |
| 35 AcceleratedTextureCopier::~AcceleratedTextureCopier() { | 36 AcceleratedTextureCopier::~AcceleratedTextureCopier() { |
| 36 if (blit_program_) | 37 if (blit_program_) |
| 37 blit_program_->Cleanup(context_); | 38 blit_program_->Cleanup(context_); |
| 39 if (blit_program_highp_) |
| 40 blit_program_highp_->Cleanup(context_); |
| 38 if (position_buffer_) | 41 if (position_buffer_) |
| 39 GLC(context_, context_->deleteBuffer(position_buffer_)); | 42 GLC(context_, context_->deleteBuffer(position_buffer_)); |
| 40 if (fbo_) | 43 if (fbo_) |
| 41 GLC(context_, context_->deleteFramebuffer(fbo_)); | 44 GLC(context_, context_->deleteFramebuffer(fbo_)); |
| 42 } | 45 } |
| 43 | 46 |
| 44 void AcceleratedTextureCopier::CopyTexture(Parameters parameters) { | 47 void AcceleratedTextureCopier::CopyTexture(Parameters parameters) { |
| 45 TRACE_EVENT0("cc", "TextureCopier::CopyTexture"); | 48 TRACE_EVENT0("cc", "TextureCopier::CopyTexture"); |
| 46 | 49 |
| 47 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | 50 GLC(context_, context_->disable(GL_SCISSOR_TEST)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 64 | 67 |
| 65 GLC(context_, | 68 GLC(context_, |
| 66 context_->bindTexture(GL_TEXTURE_2D, parameters.source_texture)); | 69 context_->bindTexture(GL_TEXTURE_2D, parameters.source_texture)); |
| 67 GLC(context_, | 70 GLC(context_, |
| 68 context_->texParameteri( | 71 context_->texParameteri( |
| 69 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); | 72 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); |
| 70 GLC(context_, | 73 GLC(context_, |
| 71 context_->texParameteri( | 74 context_->texParameteri( |
| 72 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); | 75 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); |
| 73 | 76 |
| 74 if (!blit_program_->initialized()) | 77 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 75 blit_program_->Initialize(context_, using_bind_uniforms_); | 78 context_, gfx::Point(parameters.size.width(), parameters.size.height())); |
| 79 if (texCoordPrecision == TexCoordPrecisionHigh) { |
| 80 if (!blit_program_highp_->initialized()) |
| 81 blit_program_highp_->Initialize(context_, using_bind_uniforms_); |
| 76 | 82 |
| 77 // TODO: Use EXT_framebuffer_blit if available. | 83 // TODO: Use EXT_framebuffer_blit if available. |
| 78 GLC(context_, context_->useProgram(blit_program_->program())); | 84 GLC(context_, context_->useProgram(blit_program_highp_->program())); |
| 85 } else { |
| 86 if (!blit_program_->initialized()) |
| 87 blit_program_->Initialize(context_, using_bind_uniforms_); |
| 88 |
| 89 // TODO: Use EXT_framebuffer_blit if available. |
| 90 GLC(context_, context_->useProgram(blit_program_->program())); |
| 91 } |
| 92 |
| 79 | 93 |
| 80 const int kPositionAttribute = 0; | 94 const int kPositionAttribute = 0; |
| 81 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); | 95 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); |
| 82 GLC(context_, | 96 GLC(context_, |
| 83 context_->vertexAttribPointer( | 97 context_->vertexAttribPointer( |
| 84 kPositionAttribute, 4, GL_FLOAT, false, 0, 0)); | 98 kPositionAttribute, 4, GL_FLOAT, false, 0, 0)); |
| 85 GLC(context_, context_->enableVertexAttribArray(kPositionAttribute)); | 99 GLC(context_, context_->enableVertexAttribArray(kPositionAttribute)); |
| 86 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0)); | 100 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0)); |
| 87 | 101 |
| 88 GLC(context_, | 102 GLC(context_, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 106 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); | 120 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); |
| 107 | 121 |
| 108 GLC(context_, context_->enable(GL_SCISSOR_TEST)); | 122 GLC(context_, context_->enable(GL_SCISSOR_TEST)); |
| 109 } | 123 } |
| 110 | 124 |
| 111 void AcceleratedTextureCopier::Flush() { | 125 void AcceleratedTextureCopier::Flush() { |
| 112 GLC(context_, context_->flush()); | 126 GLC(context_, context_->flush()); |
| 113 } | 127 } |
| 114 | 128 |
| 115 } // namespace cc | 129 } // namespace cc |
| OLD | NEW |