Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: cc/output/texture_copier.cc

Issue 12665005: cc: Use highp precision for texture coords if available and needed (Closed) Base URL: http://git.chromium.org/chromium/src.git@highp2
Patch Set: rebase after all dependencies landed Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/texture_copier.h ('k') | cc/output/texture_copier_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 : context_(context), using_bind_uniforms_(using_bind_uniforms) { 18 int highp_threshold_min)
19 : context_(context)
20 , using_bind_uniforms_(using_bind_uniforms)
21 , highp_threshold_min_(highp_threshold_min) {
19 DCHECK(context_); 22 DCHECK(context_);
20 GLC(context_, fbo_ = context_->createFramebuffer()); 23 GLC(context_, fbo_ = context_->createFramebuffer());
21 GLC(context_, position_buffer_ = context_->createBuffer()); 24 GLC(context_, position_buffer_ = context_->createBuffer());
22 25
23 static const float kPositions[4][4] = { { -1, -1, 0, 1 }, { 1, -1, 0, 1 }, 26 static const float kPositions[4][4] = { { -1, -1, 0, 1 }, { 1, -1, 0, 1 },
24 { 1, 1, 0, 1 }, { -1, 1, 0, 1 } }; 27 { 1, 1, 0, 1 }, { -1, 1, 0, 1 } };
25 28
26 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); 29 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_));
27 GLC(context_, 30 GLC(context_,
28 context_->bufferData( 31 context_->bufferData(
29 GL_ARRAY_BUFFER, sizeof(kPositions), kPositions, GL_STATIC_DRAW)); 32 GL_ARRAY_BUFFER, sizeof(kPositions), kPositions, GL_STATIC_DRAW));
30 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0)); 33 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0));
31 34
32 blit_program_.reset(new BlitProgram(context_)); 35 blit_program_.reset(new BlitProgram(context_, TexCoordPrecisionMedium));
36 blit_program_highp_.reset(new BlitProgram(context_, TexCoordPrecisionHigh));
33 } 37 }
34 38
35 AcceleratedTextureCopier::~AcceleratedTextureCopier() { 39 AcceleratedTextureCopier::~AcceleratedTextureCopier() {
36 if (blit_program_) 40 if (blit_program_)
37 blit_program_->Cleanup(context_); 41 blit_program_->Cleanup(context_);
42 if (blit_program_highp_)
43 blit_program_highp_->Cleanup(context_);
38 if (position_buffer_) 44 if (position_buffer_)
39 GLC(context_, context_->deleteBuffer(position_buffer_)); 45 GLC(context_, context_->deleteBuffer(position_buffer_));
40 if (fbo_) 46 if (fbo_)
41 GLC(context_, context_->deleteFramebuffer(fbo_)); 47 GLC(context_, context_->deleteFramebuffer(fbo_));
42 } 48 }
43 49
44 void AcceleratedTextureCopier::CopyTexture(Parameters parameters) { 50 void AcceleratedTextureCopier::CopyTexture(Parameters parameters) {
45 TRACE_EVENT0("cc", "TextureCopier::CopyTexture"); 51 TRACE_EVENT0("cc", "TextureCopier::CopyTexture");
46 52
47 GLC(context_, context_->disable(GL_SCISSOR_TEST)); 53 GLC(context_, context_->disable(GL_SCISSOR_TEST));
(...skipping 17 matching lines...) Expand all
65 71
66 GLC(context_, 72 GLC(context_,
67 context_->bindTexture(GL_TEXTURE_2D, parameters.source_texture)); 73 context_->bindTexture(GL_TEXTURE_2D, parameters.source_texture));
68 GLC(context_, 74 GLC(context_,
69 context_->texParameteri( 75 context_->texParameteri(
70 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); 76 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
71 GLC(context_, 77 GLC(context_,
72 context_->texParameteri( 78 context_->texParameteri(
73 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); 79 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
74 80
75 if (!blit_program_->initialized()) 81 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired(
76 blit_program_->Initialize(context_, using_bind_uniforms_); 82 context_, highp_threshold_min_, parameters.size);
83 if (texCoordPrecision == TexCoordPrecisionHigh) {
84 if (!blit_program_highp_->initialized())
85 blit_program_highp_->Initialize(context_, using_bind_uniforms_);
77 86
78 // TODO(danakj): Use EXT_framebuffer_blit if available. 87 // TODO(danakj): Use EXT_framebuffer_blit if available.
79 GLC(context_, context_->useProgram(blit_program_->program())); 88 GLC(context_, context_->useProgram(blit_program_highp_->program()));
89 } else {
90 if (!blit_program_->initialized())
91 blit_program_->Initialize(context_, using_bind_uniforms_);
92
93 // TODO(danakj: Use EXT_framebuffer_blit if available.
94 GLC(context_, context_->useProgram(blit_program_->program()));
95 }
80 96
81 const int kPositionAttribute = 0; 97 const int kPositionAttribute = 0;
82 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_)); 98 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, position_buffer_));
83 GLC(context_, 99 GLC(context_,
84 context_->vertexAttribPointer( 100 context_->vertexAttribPointer(
85 kPositionAttribute, 4, GL_FLOAT, false, 0, 0)); 101 kPositionAttribute, 4, GL_FLOAT, false, 0, 0));
86 GLC(context_, context_->enableVertexAttribArray(kPositionAttribute)); 102 GLC(context_, context_->enableVertexAttribArray(kPositionAttribute));
87 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0)); 103 GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, 0));
88 104
89 GLC(context_, 105 GLC(context_,
(...skipping 17 matching lines...) Expand all
107 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); 123 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
108 124
109 GLC(context_, context_->enable(GL_SCISSOR_TEST)); 125 GLC(context_, context_->enable(GL_SCISSOR_TEST));
110 } 126 }
111 127
112 void AcceleratedTextureCopier::Flush() { 128 void AcceleratedTextureCopier::Flush() {
113 GLC(context_, context_->flush()); 129 GLC(context_, context_->flush());
114 } 130 }
115 131
116 } // namespace cc 132 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/texture_copier.h ('k') | cc/output/texture_copier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698