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

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

Issue 1609983003: Reland of Untouch out of bound pixels for CopyTexSubImage2D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « 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_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 11375 matching lines...) Expand 10 before | Expand all | Expand 10 after
11386 11386
11387 ScopedResolvedFrameBufferBinder binder(this, false, true); 11387 ScopedResolvedFrameBufferBinder binder(this, false, true);
11388 gfx::Size size = GetBoundReadFrameBufferSize(); 11388 gfx::Size size = GetBoundReadFrameBufferSize();
11389 GLint copyX = 0; 11389 GLint copyX = 0;
11390 GLint copyY = 0; 11390 GLint copyY = 0;
11391 GLint copyWidth = 0; 11391 GLint copyWidth = 0;
11392 GLint copyHeight = 0; 11392 GLint copyHeight = 0;
11393 Clip(x, width, size.width(), &copyX, &copyWidth); 11393 Clip(x, width, size.width(), &copyX, &copyWidth);
11394 Clip(y, height, size.height(), &copyY, &copyHeight); 11394 Clip(y, height, size.height(), &copyY, &copyHeight);
11395 11395
11396 if (xoffset != 0 || yoffset != 0 || width != size.width() || 11396 GLint dx = copyX - x;
11397 height != size.height()) { 11397 GLint dy = copyY - y;
11398 GLint destX = xoffset + dx;
11399 GLint destY = yoffset + dy;
11400 if (destX != 0 || destY != 0 || copyWidth != size.width() ||
11401 copyHeight != size.height()) {
11398 gfx::Rect cleared_rect; 11402 gfx::Rect cleared_rect;
11399 if (TextureManager::CombineAdjacentRects( 11403 if (TextureManager::CombineAdjacentRects(
11400 texture->GetLevelClearedRect(target, level), 11404 texture->GetLevelClearedRect(target, level),
11401 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) { 11405 gfx::Rect(destX, destY, copyWidth, copyHeight), &cleared_rect)) {
11402 DCHECK_GE(cleared_rect.size().GetArea(), 11406 DCHECK_GE(cleared_rect.size().GetArea(),
11403 texture->GetLevelClearedRect(target, level).size().GetArea()); 11407 texture->GetLevelClearedRect(target, level).size().GetArea());
11404 texture_manager()->SetLevelClearedRect(texture_ref, target, level, 11408 texture_manager()->SetLevelClearedRect(texture_ref, target, level,
11405 cleared_rect); 11409 cleared_rect);
11406 } else { 11410 } else {
11407 // Otherwise clear part of texture level that is not already cleared. 11411 // Otherwise clear part of texture level that is not already cleared.
11408 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, 11412 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target,
11409 level)) { 11413 level)) {
11410 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D", 11414 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D",
11411 "dimensions too big"); 11415 "dimensions too big");
11412 return; 11416 return;
11413 } 11417 }
11414 } 11418 }
11415 } else { 11419 } else {
11416 // Write all pixels in below. 11420 // Write all pixels in below.
11417 texture_manager()->SetLevelCleared(texture_ref, target, level, true); 11421 texture_manager()->SetLevelCleared(texture_ref, target, level, true);
11418 } 11422 }
11419 11423
11420 if (copyX != x ||
11421 copyY != y ||
11422 copyWidth != width ||
11423 copyHeight != height) {
11424 // some part was clipped so clear the sub rect.
11425 uint32_t pixels_size = 0;
11426 if (!GLES2Util::ComputeImageDataSizes(
11427 width, height, 1, format, type, state_.unpack_alignment, &pixels_size,
11428 NULL, NULL)) {
11429 LOCAL_SET_GL_ERROR(
11430 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large");
11431 return;
11432 }
11433 scoped_ptr<char[]> zero(new char[pixels_size]);
11434 memset(zero.get(), 0, pixels_size);
11435 glTexSubImage2D(
11436 target, level, xoffset, yoffset, width, height,
11437 format, type, zero.get());
11438 }
11439
11440 if (copyHeight > 0 && copyWidth > 0) { 11424 if (copyHeight > 0 && copyWidth > 0) {
11441 GLint dx = copyX - x;
11442 GLint dy = copyY - y;
11443 GLint destX = xoffset + dx;
11444 GLint destY = yoffset + dy;
11445 glCopyTexSubImage2D(target, level, 11425 glCopyTexSubImage2D(target, level,
11446 destX, destY, copyX, copyY, 11426 destX, destY, copyX, copyY,
11447 copyWidth, copyHeight); 11427 copyWidth, copyHeight);
11448 } 11428 }
11449 11429
11450 // This may be a slow command. Exit command processing to allow for 11430 // This may be a slow command. Exit command processing to allow for
11451 // context preemption and GPU watchdog checks. 11431 // context preemption and GPU watchdog checks.
11452 ExitCommandProcessingEarly(); 11432 ExitCommandProcessingEarly();
11453 } 11433 }
11454 11434
(...skipping 4177 matching lines...) Expand 10 before | Expand all | Expand 10 after
15632 } 15612 }
15633 15613
15634 // Include the auto-generated part of this file. We split this because it means 15614 // Include the auto-generated part of this file. We split this because it means
15635 // we can easily edit the non-auto generated parts right here in this file 15615 // we can easily edit the non-auto generated parts right here in this file
15636 // instead of having to edit some template or the code generator. 15616 // instead of having to edit some template or the code generator.
15637 #include "base/macros.h" 15617 #include "base/macros.h"
15638 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15618 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15639 15619
15640 } // namespace gles2 15620 } // namespace gles2
15641 } // namespace gpu 15621 } // namespace gpu
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