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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "gpu/command_buffer/service/gl_utils.h" 10 #include "gpu/command_buffer/service/gl_utils.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 #endif 212 #endif
213 return true; 213 return true;
214 } 214 }
215 215
216 void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder, 216 void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder,
217 GLenum source_target, 217 GLenum source_target,
218 GLuint source_id, 218 GLuint source_id,
219 GLuint dest_id, 219 GLuint dest_id,
220 GLint dest_level, 220 GLint dest_level,
221 GLenum dest_internal_format,
221 GLsizei width, 222 GLsizei width,
222 GLsizei height, 223 GLsizei height,
223 GLuint framebuffer) { 224 GLuint framebuffer) {
224 DCHECK(source_target == GL_TEXTURE_2D || 225 DCHECK(source_target == GL_TEXTURE_2D ||
225 source_target == GL_TEXTURE_RECTANGLE_ARB); 226 source_target == GL_TEXTURE_RECTANGLE_ARB);
226 if (BindFramebufferTexture2D( 227 if (BindFramebufferTexture2D(
227 source_target, source_id, 0 /* level */, framebuffer)) { 228 source_target, source_id, 0 /* level */, framebuffer)) {
228 glBindTexture(GL_TEXTURE_2D, dest_id); 229 glBindTexture(GL_TEXTURE_2D, dest_id);
229 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 230 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
230 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 231 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
231 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 232 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
232 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 233 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
233 glCopyTexSubImage2D(GL_TEXTURE_2D, dest_level, 0 /* xoffset */, 234 glCopyTexImage2D(GL_TEXTURE_2D,
234 0 /* yoffset */, 0 /* x */, 0 /* y */, width, height); 235 dest_level,
236 dest_internal_format,
237 0 /* x */,
238 0 /* y */,
239 width,
240 height,
241 0 /* border */);
235 } 242 }
236 243
237 decoder->RestoreTextureState(source_id); 244 decoder->RestoreTextureState(source_id);
238 decoder->RestoreTextureState(dest_id); 245 decoder->RestoreTextureState(dest_id);
239 decoder->RestoreTextureUnitBindings(0); 246 decoder->RestoreTextureUnitBindings(0);
240 decoder->RestoreActiveTexture(); 247 decoder->RestoreActiveTexture();
241 decoder->RestoreFramebufferBindings(); 248 decoder->RestoreFramebufferBindings();
242 } 249 }
243 250
244 } // namespace 251 } // namespace
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 bool premultiply_alpha, 325 bool premultiply_alpha,
319 bool unpremultiply_alpha) { 326 bool unpremultiply_alpha) {
320 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; 327 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
321 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's 328 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's
322 // format does not contain a superset of the components required by the base 329 // format does not contain a superset of the components required by the base
323 // format of internalformat. 330 // format of internalformat.
324 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml 331 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
325 bool source_format_contain_superset_of_dest_format = 332 bool source_format_contain_superset_of_dest_format =
326 source_internal_format == dest_internal_format || 333 source_internal_format == dest_internal_format ||
327 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); 334 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB);
328 bool source_target_allowed = source_target == GL_TEXTURE_2D || 335 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
329 source_target == GL_TEXTURE_RECTANGLE_ARB; 336 // so restrict this to GL_TEXTURE_2D.
330 if (source_target_allowed && !flip_y && !premultiply_alpha_change && 337 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change &&
331 source_format_contain_superset_of_dest_format) { 338 source_format_contain_superset_of_dest_format) {
332 DoCopyTexImage2D(decoder, 339 DoCopyTexImage2D(decoder,
333 source_target, 340 source_target,
334 source_id, 341 source_id,
335 dest_id, 342 dest_id,
336 dest_level, 343 dest_level,
344 dest_internal_format,
337 width, 345 width,
338 height, 346 height,
339 framebuffer_); 347 framebuffer_);
340 return; 348 return;
341 } 349 }
342 350
343 // Use default transform matrix if no transform passed in. 351 // Use default transform matrix if no transform passed in.
344 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 352 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
345 0.0f, 1.0f, 0.0f, 0.0f, 353 0.0f, 1.0f, 0.0f, 0.0f,
346 0.0f, 0.0f, 1.0f, 0.0f, 354 0.0f, 0.0f, 1.0f, 0.0f,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 decoder->RestoreTextureState(dest_id); 473 decoder->RestoreTextureState(dest_id);
466 decoder->RestoreTextureUnitBindings(0); 474 decoder->RestoreTextureUnitBindings(0);
467 decoder->RestoreActiveTexture(); 475 decoder->RestoreActiveTexture();
468 decoder->RestoreProgramBindings(); 476 decoder->RestoreProgramBindings();
469 decoder->RestoreBufferBindings(); 477 decoder->RestoreBufferBindings();
470 decoder->RestoreFramebufferBindings(); 478 decoder->RestoreFramebufferBindings();
471 decoder->RestoreGlobalState(); 479 decoder->RestoreGlobalState();
472 } 480 }
473 481
474 } // namespace gpu 482 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698