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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 7541074: Fix 2 Dr. Memory issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | gpu/command_buffer/service/texture_manager_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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "../client/gles2_implementation.h" 7 #include "../client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include <GLES2/gles2_command_buffer.h> 10 #include <GLES2/gles2_command_buffer.h>
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 return; 1377 return;
1378 } 1378 }
1379 1379
1380 GLsizei original_height = height; 1380 GLsizei original_height = height;
1381 if (padded_row_size <= max_size) { 1381 if (padded_row_size <= max_size) {
1382 // Transfer by rows. 1382 // Transfer by rows.
1383 GLint max_rows = max_size / std::max(padded_row_size, 1383 GLint max_rows = max_size / std::max(padded_row_size,
1384 static_cast<GLsizeiptr>(1)); 1384 static_cast<GLsizeiptr>(1));
1385 while (height) { 1385 while (height) {
1386 GLint num_rows = std::min(height, max_rows); 1386 GLint num_rows = std::min(height, max_rows);
1387 GLsizeiptr part_size = num_rows * padded_row_size; 1387 GLsizeiptr part_size =
1388 (num_rows - 1) * padded_row_size + unpadded_row_size;
1388 void* buffer = transfer_buffer_.Alloc(part_size); 1389 void* buffer = transfer_buffer_.Alloc(part_size);
1389 GLint y; 1390 GLint y;
1390 if (unpack_flip_y_) { 1391 if (unpack_flip_y_) {
1391 CopyRectToBufferFlipped( 1392 CopyRectToBufferFlipped(
1392 source, width, num_rows, format, type, buffer); 1393 source, width, num_rows, format, type, buffer);
1393 // GPU_DCHECK(copy_success); // can't check this because bot fails! 1394 // GPU_DCHECK(copy_success); // can't check this because bot fails!
1394 y = original_height - yoffset - num_rows; 1395 y = original_height - yoffset - num_rows;
1395 } else { 1396 } else {
1396 memcpy(buffer, source, part_size); 1397 memcpy(buffer, source, part_size);
1397 y = yoffset; 1398 y = yoffset;
1398 } 1399 }
1399 helper_->TexSubImage2D( 1400 helper_->TexSubImage2D(
1400 target, level, xoffset, y, width, num_rows, format, type, 1401 target, level, xoffset, y, width, num_rows, format, type,
1401 transfer_buffer_id_, transfer_buffer_.GetOffset(buffer), internal); 1402 transfer_buffer_id_, transfer_buffer_.GetOffset(buffer), internal);
1402 transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken()); 1403 transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken());
1403 yoffset += num_rows; 1404 yoffset += num_rows;
1404 source += part_size; 1405 source += num_rows * padded_row_size;
1405 height -= num_rows; 1406 height -= num_rows;
1406 } 1407 }
1407 } else { 1408 } else {
1408 // Transfer by sub rows. Because GL has no maximum texture dimensions. 1409 // Transfer by sub rows. Because GL has no maximum texture dimensions.
1409 uint32 temp; 1410 uint32 temp;
1410 GLES2Util::ComputeImageDataSize( 1411 GLES2Util::ComputeImageDataSize(
1411 1, 1, format, type, unpack_alignment_, &temp); 1412 1, 1, format, type, unpack_alignment_, &temp);
1412 GLsizeiptr element_size = temp; 1413 GLsizeiptr element_size = temp;
1413 max_size -= max_size % element_size; 1414 max_size -= max_size % element_size;
1414 GLint max_sub_row_pixels = max_size / element_size; 1415 GLint max_sub_row_pixels = max_size / element_size;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 // Transfer by rows. 1735 // Transfer by rows.
1735 // The max rows we can transfer. 1736 // The max rows we can transfer.
1736 GLint max_rows = max_size / std::max(padded_row_size, 1737 GLint max_rows = max_size / std::max(padded_row_size,
1737 static_cast<GLsizeiptr>(1)); 1738 static_cast<GLsizeiptr>(1));
1738 while (height) { 1739 while (height) {
1739 // Compute how many rows to transfer. 1740 // Compute how many rows to transfer.
1740 GLint num_rows = std::min(height, max_rows); 1741 GLint num_rows = std::min(height, max_rows);
1741 // Compute how much space those rows will take. The last row will not 1742 // Compute how much space those rows will take. The last row will not
1742 // include padding. 1743 // include padding.
1743 GLsizeiptr part_size = 1744 GLsizeiptr part_size =
1744 unpadded_row_size + (padded_row_size * std::max(num_rows - 1, 0)); 1745 unpadded_row_size + padded_row_size * (num_rows - 1);
1745 void* buffer = transfer_buffer_.Alloc(part_size); 1746 void* buffer = transfer_buffer_.Alloc(part_size);
1746 *result = 0; // mark as failed. 1747 *result = 0; // mark as failed.
1747 helper_->ReadPixels( 1748 helper_->ReadPixels(
1748 xoffset, yoffset, width, num_rows, format, type, 1749 xoffset, yoffset, width, num_rows, format, type,
1749 transfer_buffer_id_, transfer_buffer_.GetOffset(buffer), 1750 transfer_buffer_id_, transfer_buffer_.GetOffset(buffer),
1750 result_shm_id(), result_shm_offset()); 1751 result_shm_id(), result_shm_offset());
1751 WaitForCmd(); 1752 WaitForCmd();
1752 if (*result != 0) { 1753 if (*result != 0) {
1753 // We have to copy 1 row at a time to avoid writing pad bytes. 1754 // We have to copy 1 row at a time to avoid writing pad bytes.
1754 const int8* src = static_cast<const int8*>(buffer); 1755 const int8* src = static_cast<const int8*>(buffer);
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 if (static_cast<size_t>(bufsize) < result.size()) { 2361 if (static_cast<size_t>(bufsize) < result.size()) {
2361 SetGLError(GL_INVALID_OPERATION, 2362 SetGLError(GL_INVALID_OPERATION,
2362 "glProgramInfoCHROMIUM: bufsize is too small for result."); 2363 "glProgramInfoCHROMIUM: bufsize is too small for result.");
2363 return; 2364 return;
2364 } 2365 }
2365 memcpy(info, &result[0], result.size()); 2366 memcpy(info, &result[0], result.size());
2366 } 2367 }
2367 2368
2368 } // namespace gles2 2369 } // namespace gles2
2369 } // namespace gpu 2370 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698