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

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

Issue 157033009: Explicitly disable all attribs before drawing in CopyTextureCHROMIUM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string.h> 7 #include <string.h>
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "gpu/command_buffer/common/types.h" 9 #include "gpu/command_buffer/common/types.h"
10 #include "gpu/command_buffer/service/gl_utils.h" 10 #include "gpu/command_buffer/service/gl_utils.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // NVidia drivers require texture settings to be a certain way 381 // NVidia drivers require texture settings to be a certain way
382 // or they won't report FRAMEBUFFER_COMPLETE. 382 // or they won't report FRAMEBUFFER_COMPLETE.
383 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 383 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
384 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 384 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
385 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 385 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
387 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_); 387 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_);
388 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, 388 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target,
389 dest_id, level); 389 dest_id, level);
390 390
391 GLint maxAttribs = 0;
Zhenyao Mo 2014/02/11 19:01:20 name should be max_attribs
392 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
393
391 #ifndef NDEBUG 394 #ifndef NDEBUG
392 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 395 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
393 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { 396 if (GL_FRAMEBUFFER_COMPLETE != fb_status) {
394 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; 397 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer.";
395 } else 398 } else
396 #endif 399 #endif
397 { 400 {
398 glEnableVertexAttribArray(kVertexPositionAttrib); 401 glEnableVertexAttribArray(kVertexPositionAttrib);
402 for(int i = 1; i < maxAttribs; ++i)
Zhenyao Mo 2014/02/11 19:01:20 space after for
403 glDisableVertexAttribArray(i);
Zhenyao Mo 2014/02/11 19:01:20 Here you should not make the assumption kVertexPos
399 404
400 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); 405 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_);
401 glVertexAttribPointer(kVertexPositionAttrib, 4, GL_FLOAT, GL_FALSE, 406 glVertexAttribPointer(kVertexPositionAttrib, 4, GL_FLOAT, GL_FALSE,
402 4 * sizeof(GLfloat), 0); 407 4 * sizeof(GLfloat), 0);
403 408
404 glUniform1i(sampler_locations_[program], 0); 409 glUniform1i(sampler_locations_[program], 0);
405 410
406 glBindTexture(source_target, source_id); 411 glBindTexture(source_target, source_id);
407 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 412 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
408 glTexParameterf(source_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 413 glTexParameterf(source_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
409 glTexParameteri(source_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 414 glTexParameteri(source_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
410 glTexParameteri(source_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 415 glTexParameteri(source_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
411 416
412 glDisable(GL_DEPTH_TEST); 417 glDisable(GL_DEPTH_TEST);
413 glDisable(GL_SCISSOR_TEST); 418 glDisable(GL_SCISSOR_TEST);
414 glDisable(GL_STENCIL_TEST); 419 glDisable(GL_STENCIL_TEST);
415 glDisable(GL_CULL_FACE); 420 glDisable(GL_CULL_FACE);
416 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 421 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
417 glDepthMask(GL_FALSE); 422 glDepthMask(GL_FALSE);
418 glDisable(GL_BLEND); 423 glDisable(GL_BLEND);
419 424
420 glViewport(0, 0, width, height); 425 glViewport(0, 0, width, height);
421 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 426 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
422 } 427 }
423 428
424 decoder->RestoreAttribute(kVertexPositionAttrib); 429 for(int i = 0; i < maxAttribs; ++i)
Zhenyao Mo 2014/02/11 19:01:20 space after for
430 decoder->RestoreAttribute(i);
425 decoder->RestoreTextureState(source_id); 431 decoder->RestoreTextureState(source_id);
426 decoder->RestoreTextureState(dest_id); 432 decoder->RestoreTextureState(dest_id);
427 decoder->RestoreTextureUnitBindings(0); 433 decoder->RestoreTextureUnitBindings(0);
428 decoder->RestoreActiveTexture(); 434 decoder->RestoreActiveTexture();
429 decoder->RestoreProgramBindings(); 435 decoder->RestoreProgramBindings();
430 decoder->RestoreBufferBindings(); 436 decoder->RestoreBufferBindings();
431 decoder->RestoreFramebufferBindings(); 437 decoder->RestoreFramebufferBindings();
432 decoder->RestoreGlobalState(); 438 decoder->RestoreGlobalState();
433 } 439 }
434 440
435 } // namespace 441 } // namespace
436 442
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698