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

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

Issue 13454036: Rewrite scoped_array<T> to scoped_ptr<T[]> in gpu/, Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yikes 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 | Annotate | Revision Log
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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 ScopedTexture2DBinder binder(decoder_, id_); 1994 ScopedTexture2DBinder binder(decoder_, id_);
1995 uint32 image_size = 0; 1995 uint32 image_size = 0;
1996 GLES2Util::ComputeImageDataSizes( 1996 GLES2Util::ComputeImageDataSizes(
1997 size.width(), size.height(), format, GL_UNSIGNED_BYTE, 8, &image_size, 1997 size.width(), size.height(), format, GL_UNSIGNED_BYTE, 8, &image_size,
1998 NULL, NULL); 1998 NULL, NULL);
1999 1999
2000 if (!memory_tracker_.EnsureGPUMemoryAvailable(image_size)) { 2000 if (!memory_tracker_.EnsureGPUMemoryAvailable(image_size)) {
2001 return false; 2001 return false;
2002 } 2002 }
2003 2003
2004 scoped_array<char> zero_data; 2004 scoped_ptr<char[]> zero_data;
2005 if (zero) { 2005 if (zero) {
2006 zero_data.reset(new char[image_size]); 2006 zero_data.reset(new char[image_size]);
2007 memset(zero_data.get(), 0, image_size); 2007 memset(zero_data.get(), 0, image_size);
2008 } 2008 }
2009 2009
2010 WrappedTexImage2D(GL_TEXTURE_2D, 2010 WrappedTexImage2D(GL_TEXTURE_2D,
2011 0, // mip level 2011 0, // mip level
2012 format, 2012 format,
2013 size.width(), 2013 size.width(),
2014 size.height(), 2014 size.height(),
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2668 } 2668 }
2669 return true; 2669 return true;
2670 } 2670 }
2671 2671
2672 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) { 2672 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) {
2673 for (GLsizei ii = 0; ii < n; ++ii) { 2673 for (GLsizei ii = 0; ii < n; ++ii) {
2674 if (GetBuffer(client_ids[ii])) { 2674 if (GetBuffer(client_ids[ii])) {
2675 return false; 2675 return false;
2676 } 2676 }
2677 } 2677 }
2678 scoped_array<GLuint> service_ids(new GLuint[n]); 2678 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
2679 glGenBuffersARB(n, service_ids.get()); 2679 glGenBuffersARB(n, service_ids.get());
2680 for (GLsizei ii = 0; ii < n; ++ii) { 2680 for (GLsizei ii = 0; ii < n; ++ii) {
2681 CreateBuffer(client_ids[ii], service_ids[ii]); 2681 CreateBuffer(client_ids[ii], service_ids[ii]);
2682 } 2682 }
2683 return true; 2683 return true;
2684 } 2684 }
2685 2685
2686 bool GLES2DecoderImpl::GenFramebuffersHelper( 2686 bool GLES2DecoderImpl::GenFramebuffersHelper(
2687 GLsizei n, const GLuint* client_ids) { 2687 GLsizei n, const GLuint* client_ids) {
2688 for (GLsizei ii = 0; ii < n; ++ii) { 2688 for (GLsizei ii = 0; ii < n; ++ii) {
2689 if (GetFramebuffer(client_ids[ii])) { 2689 if (GetFramebuffer(client_ids[ii])) {
2690 return false; 2690 return false;
2691 } 2691 }
2692 } 2692 }
2693 scoped_array<GLuint> service_ids(new GLuint[n]); 2693 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
2694 glGenFramebuffersEXT(n, service_ids.get()); 2694 glGenFramebuffersEXT(n, service_ids.get());
2695 for (GLsizei ii = 0; ii < n; ++ii) { 2695 for (GLsizei ii = 0; ii < n; ++ii) {
2696 CreateFramebuffer(client_ids[ii], service_ids[ii]); 2696 CreateFramebuffer(client_ids[ii], service_ids[ii]);
2697 } 2697 }
2698 return true; 2698 return true;
2699 } 2699 }
2700 2700
2701 bool GLES2DecoderImpl::GenRenderbuffersHelper( 2701 bool GLES2DecoderImpl::GenRenderbuffersHelper(
2702 GLsizei n, const GLuint* client_ids) { 2702 GLsizei n, const GLuint* client_ids) {
2703 for (GLsizei ii = 0; ii < n; ++ii) { 2703 for (GLsizei ii = 0; ii < n; ++ii) {
2704 if (GetRenderbuffer(client_ids[ii])) { 2704 if (GetRenderbuffer(client_ids[ii])) {
2705 return false; 2705 return false;
2706 } 2706 }
2707 } 2707 }
2708 scoped_array<GLuint> service_ids(new GLuint[n]); 2708 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
2709 glGenRenderbuffersEXT(n, service_ids.get()); 2709 glGenRenderbuffersEXT(n, service_ids.get());
2710 for (GLsizei ii = 0; ii < n; ++ii) { 2710 for (GLsizei ii = 0; ii < n; ++ii) {
2711 CreateRenderbuffer(client_ids[ii], service_ids[ii]); 2711 CreateRenderbuffer(client_ids[ii], service_ids[ii]);
2712 } 2712 }
2713 return true; 2713 return true;
2714 } 2714 }
2715 2715
2716 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) { 2716 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) {
2717 for (GLsizei ii = 0; ii < n; ++ii) { 2717 for (GLsizei ii = 0; ii < n; ++ii) {
2718 if (GetTexture(client_ids[ii])) { 2718 if (GetTexture(client_ids[ii])) {
2719 return false; 2719 return false;
2720 } 2720 }
2721 } 2721 }
2722 scoped_array<GLuint> service_ids(new GLuint[n]); 2722 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
2723 glGenTextures(n, service_ids.get()); 2723 glGenTextures(n, service_ids.get());
2724 for (GLsizei ii = 0; ii < n; ++ii) { 2724 for (GLsizei ii = 0; ii < n; ++ii) {
2725 CreateTexture(client_ids[ii], service_ids[ii]); 2725 CreateTexture(client_ids[ii], service_ids[ii]);
2726 } 2726 }
2727 return true; 2727 return true;
2728 } 2728 }
2729 2729
2730 void GLES2DecoderImpl::DeleteBuffersHelper( 2730 void GLES2DecoderImpl::DeleteBuffersHelper(
2731 GLsizei n, const GLuint* client_ids) { 2731 GLsizei n, const GLuint* client_ids) {
2732 for (GLsizei ii = 0; ii < n; ++ii) { 2732 for (GLsizei ii = 0; ii < n; ++ii) {
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
4432 if (state_.GetStateAsGLint(pname, NULL, num_values)) { 4432 if (state_.GetStateAsGLint(pname, NULL, num_values)) {
4433 return true; 4433 return true;
4434 } 4434 }
4435 return GetHelper(pname, NULL, num_values); 4435 return GetHelper(pname, NULL, num_values);
4436 } 4436 }
4437 4437
4438 void GLES2DecoderImpl::DoGetBooleanv(GLenum pname, GLboolean* params) { 4438 void GLES2DecoderImpl::DoGetBooleanv(GLenum pname, GLboolean* params) {
4439 DCHECK(params); 4439 DCHECK(params);
4440 GLsizei num_written = 0; 4440 GLsizei num_written = 0;
4441 if (GetNumValuesReturnedForGLGet(pname, &num_written)) { 4441 if (GetNumValuesReturnedForGLGet(pname, &num_written)) {
4442 scoped_array<GLint> values(new GLint[num_written]); 4442 scoped_ptr<GLint[]> values(new GLint[num_written]);
4443 if (!state_.GetStateAsGLint(pname, values.get(), &num_written)) { 4443 if (!state_.GetStateAsGLint(pname, values.get(), &num_written)) {
4444 GetHelper(pname, values.get(), &num_written); 4444 GetHelper(pname, values.get(), &num_written);
4445 } 4445 }
4446 for (GLsizei ii = 0; ii < num_written; ++ii) { 4446 for (GLsizei ii = 0; ii < num_written; ++ii) {
4447 params[ii] = static_cast<GLboolean>(values[ii]); 4447 params[ii] = static_cast<GLboolean>(values[ii]);
4448 } 4448 }
4449 } else { 4449 } else {
4450 glGetBooleanv(pname, params); 4450 glGetBooleanv(pname, params);
4451 } 4451 }
4452 } 4452 }
4453 4453
4454 void GLES2DecoderImpl::DoGetFloatv(GLenum pname, GLfloat* params) { 4454 void GLES2DecoderImpl::DoGetFloatv(GLenum pname, GLfloat* params) {
4455 DCHECK(params); 4455 DCHECK(params);
4456 GLsizei num_written = 0; 4456 GLsizei num_written = 0;
4457 if (!state_.GetStateAsGLfloat(pname, params, &num_written)) { 4457 if (!state_.GetStateAsGLfloat(pname, params, &num_written)) {
4458 if (GetHelper(pname, NULL, &num_written)) { 4458 if (GetHelper(pname, NULL, &num_written)) {
4459 scoped_array<GLint> values(new GLint[num_written]); 4459 scoped_ptr<GLint[]> values(new GLint[num_written]);
4460 GetHelper(pname, values.get(), &num_written); 4460 GetHelper(pname, values.get(), &num_written);
4461 for (GLsizei ii = 0; ii < num_written; ++ii) { 4461 for (GLsizei ii = 0; ii < num_written; ++ii) {
4462 params[ii] = static_cast<GLfloat>(values[ii]); 4462 params[ii] = static_cast<GLfloat>(values[ii]);
4463 } 4463 }
4464 } else { 4464 } else {
4465 glGetFloatv(pname, params); 4465 glGetFloatv(pname, params);
4466 } 4466 }
4467 } 4467 }
4468 } 4468 }
4469 4469
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
5511 void GLES2DecoderImpl::DoUniform1fv( 5511 void GLES2DecoderImpl::DoUniform1fv(
5512 GLint fake_location, GLsizei count, const GLfloat* value) { 5512 GLint fake_location, GLsizei count, const GLfloat* value) {
5513 GLenum type = 0; 5513 GLenum type = 0;
5514 GLint real_location = -1; 5514 GLint real_location = -1;
5515 if (!PrepForSetUniformByLocation( 5515 if (!PrepForSetUniformByLocation(
5516 fake_location, "glUniform1fv", valid_float_vec1_base_info, 5516 fake_location, "glUniform1fv", valid_float_vec1_base_info,
5517 &real_location, &type, &count)) { 5517 &real_location, &type, &count)) {
5518 return; 5518 return;
5519 } 5519 }
5520 if (type == GL_BOOL) { 5520 if (type == GL_BOOL) {
5521 scoped_array<GLint> temp(new GLint[count]); 5521 scoped_ptr<GLint[]> temp(new GLint[count]);
5522 for (GLsizei ii = 0; ii < count; ++ii) { 5522 for (GLsizei ii = 0; ii < count; ++ii) {
5523 temp[ii] = static_cast<GLint>(value[ii] != 0.0f); 5523 temp[ii] = static_cast<GLint>(value[ii] != 0.0f);
5524 } 5524 }
5525 DoUniform1iv(real_location, count, temp.get()); 5525 DoUniform1iv(real_location, count, temp.get());
5526 } else { 5526 } else {
5527 glUniform1fv(real_location, count, value); 5527 glUniform1fv(real_location, count, value);
5528 } 5528 }
5529 } 5529 }
5530 5530
5531 void GLES2DecoderImpl::DoUniform2fv( 5531 void GLES2DecoderImpl::DoUniform2fv(
5532 GLint fake_location, GLsizei count, const GLfloat* value) { 5532 GLint fake_location, GLsizei count, const GLfloat* value) {
5533 GLenum type = 0; 5533 GLenum type = 0;
5534 GLint real_location = -1; 5534 GLint real_location = -1;
5535 if (!PrepForSetUniformByLocation( 5535 if (!PrepForSetUniformByLocation(
5536 fake_location, "glUniform2fv", valid_float_vec2_base_info, 5536 fake_location, "glUniform2fv", valid_float_vec2_base_info,
5537 &real_location, &type, &count)) { 5537 &real_location, &type, &count)) {
5538 return; 5538 return;
5539 } 5539 }
5540 if (type == GL_BOOL_VEC2) { 5540 if (type == GL_BOOL_VEC2) {
5541 GLsizei num_values = count * 2; 5541 GLsizei num_values = count * 2;
5542 scoped_array<GLint> temp(new GLint[num_values]); 5542 scoped_ptr<GLint[]> temp(new GLint[num_values]);
5543 for (GLsizei ii = 0; ii < num_values; ++ii) { 5543 for (GLsizei ii = 0; ii < num_values; ++ii) {
5544 temp[ii] = static_cast<GLint>(value[ii] != 0.0f); 5544 temp[ii] = static_cast<GLint>(value[ii] != 0.0f);
5545 } 5545 }
5546 glUniform2iv(real_location, count, temp.get()); 5546 glUniform2iv(real_location, count, temp.get());
5547 } else { 5547 } else {
5548 glUniform2fv(real_location, count, value); 5548 glUniform2fv(real_location, count, value);
5549 } 5549 }
5550 } 5550 }
5551 5551
5552 void GLES2DecoderImpl::DoUniform3fv( 5552 void GLES2DecoderImpl::DoUniform3fv(
5553 GLint fake_location, GLsizei count, const GLfloat* value) { 5553 GLint fake_location, GLsizei count, const GLfloat* value) {
5554 GLenum type = 0; 5554 GLenum type = 0;
5555 GLint real_location = -1; 5555 GLint real_location = -1;
5556 if (!PrepForSetUniformByLocation( 5556 if (!PrepForSetUniformByLocation(
5557 fake_location, "glUniform3fv", valid_float_vec3_base_info, 5557 fake_location, "glUniform3fv", valid_float_vec3_base_info,
5558 &real_location, &type, &count)) { 5558 &real_location, &type, &count)) {
5559 return; 5559 return;
5560 } 5560 }
5561 if (type == GL_BOOL_VEC3) { 5561 if (type == GL_BOOL_VEC3) {
5562 GLsizei num_values = count * 3; 5562 GLsizei num_values = count * 3;
5563 scoped_array<GLint> temp(new GLint[num_values]); 5563 scoped_ptr<GLint[]> temp(new GLint[num_values]);
5564 for (GLsizei ii = 0; ii < num_values; ++ii) { 5564 for (GLsizei ii = 0; ii < num_values; ++ii) {
5565 temp[ii] = static_cast<GLint>(value[ii] != 0.0f); 5565 temp[ii] = static_cast<GLint>(value[ii] != 0.0f);
5566 } 5566 }
5567 glUniform3iv(real_location, count, temp.get()); 5567 glUniform3iv(real_location, count, temp.get());
5568 } else { 5568 } else {
5569 glUniform3fv(real_location, count, value); 5569 glUniform3fv(real_location, count, value);
5570 } 5570 }
5571 } 5571 }
5572 5572
5573 void GLES2DecoderImpl::DoUniform4fv( 5573 void GLES2DecoderImpl::DoUniform4fv(
5574 GLint fake_location, GLsizei count, const GLfloat* value) { 5574 GLint fake_location, GLsizei count, const GLfloat* value) {
5575 GLenum type = 0; 5575 GLenum type = 0;
5576 GLint real_location = -1; 5576 GLint real_location = -1;
5577 if (!PrepForSetUniformByLocation( 5577 if (!PrepForSetUniformByLocation(
5578 fake_location, "glUniform4fv", valid_float_vec4_base_info, 5578 fake_location, "glUniform4fv", valid_float_vec4_base_info,
5579 &real_location, &type, &count)) { 5579 &real_location, &type, &count)) {
5580 return; 5580 return;
5581 } 5581 }
5582 if (type == GL_BOOL_VEC4) { 5582 if (type == GL_BOOL_VEC4) {
5583 GLsizei num_values = count * 4; 5583 GLsizei num_values = count * 4;
5584 scoped_array<GLint> temp(new GLint[num_values]); 5584 scoped_ptr<GLint[]> temp(new GLint[num_values]);
5585 for (GLsizei ii = 0; ii < num_values; ++ii) { 5585 for (GLsizei ii = 0; ii < num_values; ++ii) {
5586 temp[ii] = static_cast<GLint>(value[ii] != 0.0f); 5586 temp[ii] = static_cast<GLint>(value[ii] != 0.0f);
5587 } 5587 }
5588 glUniform4iv(real_location, count, temp.get()); 5588 glUniform4iv(real_location, count, temp.get());
5589 } else { 5589 } else {
5590 glUniform4fv(real_location, count, value); 5590 glUniform4fv(real_location, count, value);
5591 } 5591 }
5592 } 5592 }
5593 5593
5594 void GLES2DecoderImpl::DoUniform2iv( 5594 void GLES2DecoderImpl::DoUniform2iv(
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
6153 if (num_vertices == 0) { 6153 if (num_vertices == 0) {
6154 LOCAL_SET_GL_ERROR( 6154 LOCAL_SET_GL_ERROR(
6155 GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); 6155 GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
6156 return false; 6156 return false;
6157 } 6157 }
6158 if (attrib_info && 6158 if (attrib_info &&
6159 attrib->CanAccess(max_accessed) && 6159 attrib->CanAccess(max_accessed) &&
6160 attrib->type() == GL_FIXED) { 6160 attrib->type() == GL_FIXED) {
6161 int num_elements = attrib->size() * kSizeOfFloat; 6161 int num_elements = attrib->size() * kSizeOfFloat;
6162 int size = num_elements * num_vertices; 6162 int size = num_elements * num_vertices;
6163 scoped_array<float> data(new float[size]); 6163 scoped_ptr<float[]> data(new float[size]);
6164 const int32* src = reinterpret_cast<const int32 *>( 6164 const int32* src = reinterpret_cast<const int32 *>(
6165 attrib->buffer()->GetRange(attrib->offset(), size)); 6165 attrib->buffer()->GetRange(attrib->offset(), size));
6166 const int32* end = src + num_elements; 6166 const int32* end = src + num_elements;
6167 float* dst = data.get(); 6167 float* dst = data.get();
6168 while (src != end) { 6168 while (src != end) {
6169 *dst++ = static_cast<float>(*src++) / 65536.0f; 6169 *dst++ = static_cast<float>(*src++) / 65536.0f;
6170 } 6170 }
6171 glBufferSubData(GL_ARRAY_BUFFER, offset, size, data.get()); 6171 glBufferSubData(GL_ARRAY_BUFFER, offset, size, data.get());
6172 glVertexAttribPointer( 6172 glVertexAttribPointer(
6173 attrib->index(), attrib->size(), GL_FLOAT, false, 0, 6173 attrib->index(), attrib->size(), GL_FLOAT, false, 0,
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
7527 if (!GLES2Util::ComputeImageDataSizes( 7527 if (!GLES2Util::ComputeImageDataSizes(
7528 width, tile_height, format, type, state_.unpack_alignment, &size, 7528 width, tile_height, format, type, state_.unpack_alignment, &size,
7529 NULL, NULL)) { 7529 NULL, NULL)) {
7530 return false; 7530 return false;
7531 } 7531 }
7532 } else { 7532 } else {
7533 tile_height = height; 7533 tile_height = height;
7534 } 7534 }
7535 7535
7536 // Assumes the size has already been checked. 7536 // Assumes the size has already been checked.
7537 scoped_array<char> zero(new char[size]); 7537 scoped_ptr<char[]> zero(new char[size]);
7538 memset(zero.get(), 0, size); 7538 memset(zero.get(), 0, size);
7539 glBindTexture(bind_target, service_id); 7539 glBindTexture(bind_target, service_id);
7540 7540
7541 GLint y = 0; 7541 GLint y = 0;
7542 while (y < height) { 7542 while (y < height) {
7543 GLint h = y + tile_height > height ? height - y : tile_height; 7543 GLint h = y + tile_height > height ? height - y : tile_height;
7544 if (is_texture_immutable || h != height) { 7544 if (is_texture_immutable || h != height) {
7545 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get()); 7545 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get());
7546 } else { 7546 } else {
7547 WrappedTexImage2D( 7547 WrappedTexImage2D(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
7751 return error::kNoError; 7751 return error::kNoError;
7752 } 7752 }
7753 7753
7754 if (texture->IsAttachedToFramebuffer()) { 7754 if (texture->IsAttachedToFramebuffer()) {
7755 clear_state_dirty_ = true; 7755 clear_state_dirty_ = true;
7756 // TODO(gman): If textures tracked which framebuffers they were attached to 7756 // TODO(gman): If textures tracked which framebuffers they were attached to
7757 // we could just mark those framebuffers as not complete. 7757 // we could just mark those framebuffers as not complete.
7758 framebuffer_manager()->IncFramebufferStateChangeCount(); 7758 framebuffer_manager()->IncFramebufferStateChangeCount();
7759 } 7759 }
7760 7760
7761 scoped_array<int8> zero; 7761 scoped_ptr<int8[]> zero;
7762 if (!data) { 7762 if (!data) {
7763 zero.reset(new int8[image_size]); 7763 zero.reset(new int8[image_size]);
7764 memset(zero.get(), 0, image_size); 7764 memset(zero.get(), 0, image_size);
7765 data = zero.get(); 7765 data = zero.get();
7766 } 7766 }
7767 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); 7767 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D");
7768 glCompressedTexImage2D( 7768 glCompressedTexImage2D(
7769 target, level, internal_format, width, height, border, image_size, data); 7769 target, level, internal_format, width, height, border, image_size, data);
7770 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D"); 7770 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D");
7771 if (error == GL_NO_ERROR) { 7771 if (error == GL_NO_ERROR) {
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
8381 copyHeight != height) { 8381 copyHeight != height) {
8382 // some part was clipped so clear the sub rect. 8382 // some part was clipped so clear the sub rect.
8383 uint32 pixels_size = 0; 8383 uint32 pixels_size = 0;
8384 if (!GLES2Util::ComputeImageDataSizes( 8384 if (!GLES2Util::ComputeImageDataSizes(
8385 width, height, format, type, state_.unpack_alignment, &pixels_size, 8385 width, height, format, type, state_.unpack_alignment, &pixels_size,
8386 NULL, NULL)) { 8386 NULL, NULL)) {
8387 LOCAL_SET_GL_ERROR( 8387 LOCAL_SET_GL_ERROR(
8388 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large"); 8388 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large");
8389 return; 8389 return;
8390 } 8390 }
8391 scoped_array<char> zero(new char[pixels_size]); 8391 scoped_ptr<char[]> zero(new char[pixels_size]);
8392 memset(zero.get(), 0, pixels_size); 8392 memset(zero.get(), 0, pixels_size);
8393 glTexSubImage2D( 8393 glTexSubImage2D(
8394 target, level, xoffset, yoffset, width, height, 8394 target, level, xoffset, yoffset, width, height,
8395 format, type, zero.get()); 8395 format, type, zero.get());
8396 } 8396 }
8397 8397
8398 if (copyHeight > 0 && copyWidth > 0) { 8398 if (copyHeight > 0 && copyWidth > 0) {
8399 GLint dx = copyX - x; 8399 GLint dx = copyX - x;
8400 GLint dy = copyY - y; 8400 GLint dy = copyY - y;
8401 GLint destX = xoffset + dx; 8401 GLint destX = xoffset + dx;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
8710 typedef cmds::GetUniformfv::Result Result; 8710 typedef cmds::GetUniformfv::Result Result;
8711 Result* result; 8711 Result* result;
8712 GLenum result_type; 8712 GLenum result_type;
8713 if (GetUniformSetup( 8713 if (GetUniformSetup(
8714 program, fake_location, c.params_shm_id, c.params_shm_offset, 8714 program, fake_location, c.params_shm_id, c.params_shm_offset,
8715 &error, &real_location, &service_id, 8715 &error, &real_location, &service_id,
8716 reinterpret_cast<void**>(&result), &result_type)) { 8716 reinterpret_cast<void**>(&result), &result_type)) {
8717 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 || 8717 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 ||
8718 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) { 8718 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) {
8719 GLsizei num_values = result->GetNumResults(); 8719 GLsizei num_values = result->GetNumResults();
8720 scoped_array<GLint> temp(new GLint[num_values]); 8720 scoped_ptr<GLint[]> temp(new GLint[num_values]);
8721 glGetUniformiv(service_id, real_location, temp.get()); 8721 glGetUniformiv(service_id, real_location, temp.get());
8722 GLfloat* dst = result->GetData(); 8722 GLfloat* dst = result->GetData();
8723 for (GLsizei ii = 0; ii < num_values; ++ii) { 8723 for (GLsizei ii = 0; ii < num_values; ++ii) {
8724 dst[ii] = (temp[ii] != 0); 8724 dst[ii] = (temp[ii] != 0);
8725 } 8725 }
8726 } else { 8726 } else {
8727 glGetUniformfv(service_id, real_location, result->GetData()); 8727 glGetUniformfv(service_id, real_location, result->GetData());
8728 } 8728 }
8729 } 8729 }
8730 return error; 8730 return error;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
9119 } 9119 }
9120 const GLenum* pnames = GetSharedMemoryAs<const GLenum*>( 9120 const GLenum* pnames = GetSharedMemoryAs<const GLenum*>(
9121 c.pnames_shm_id, c.pnames_shm_offset, pnames_size); 9121 c.pnames_shm_id, c.pnames_shm_offset, pnames_size);
9122 if (pnames == NULL) { 9122 if (pnames == NULL) {
9123 return error::kOutOfBounds; 9123 return error::kOutOfBounds;
9124 } 9124 }
9125 9125
9126 // We have to copy them since we use them twice so the client 9126 // We have to copy them since we use them twice so the client
9127 // can't change them between the time we validate them and the time we use 9127 // can't change them between the time we validate them and the time we use
9128 // them. 9128 // them.
9129 scoped_array<GLenum> enums(new GLenum[count]); 9129 scoped_ptr<GLenum[]> enums(new GLenum[count]);
9130 memcpy(enums.get(), pnames, pnames_size); 9130 memcpy(enums.get(), pnames, pnames_size);
9131 9131
9132 // Count up the space needed for the result. 9132 // Count up the space needed for the result.
9133 uint32 num_results = 0; 9133 uint32 num_results = 0;
9134 for (GLuint ii = 0; ii < count; ++ii) { 9134 for (GLuint ii = 0; ii < count; ++ii) {
9135 uint32 num = util_.GLGetNumValuesReturned(enums[ii]); 9135 uint32 num = util_.GLGetNumValuesReturned(enums[ii]);
9136 if (num == 0) { 9136 if (num == 0) {
9137 LOCAL_SET_GL_ERROR_INVALID_ENUM( 9137 LOCAL_SET_GL_ERROR_INVALID_ENUM(
9138 "glGetMulitpleCHROMIUM", enums[ii], "pname"); 9138 "glGetMulitpleCHROMIUM", enums[ii], "pname");
9139 return error::kNoError; 9139 return error::kNoError;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
9455 return false; 9455 return false;
9456 } 9456 }
9457 } 9457 }
9458 9458
9459 if (!features().native_vertex_array_object) { 9459 if (!features().native_vertex_array_object) {
9460 // Emulated VAO 9460 // Emulated VAO
9461 for (GLsizei ii = 0; ii < n; ++ii) { 9461 for (GLsizei ii = 0; ii < n; ++ii) {
9462 CreateVertexAttribManager(client_ids[ii], 0); 9462 CreateVertexAttribManager(client_ids[ii], 0);
9463 } 9463 }
9464 } else { 9464 } else {
9465 scoped_array<GLuint> service_ids(new GLuint[n]); 9465 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
9466 9466
9467 glGenVertexArraysOES(n, service_ids.get()); 9467 glGenVertexArraysOES(n, service_ids.get());
9468 for (GLsizei ii = 0; ii < n; ++ii) { 9468 for (GLsizei ii = 0; ii < n; ++ii) {
9469 CreateVertexAttribManager(client_ids[ii], service_ids[ii]); 9469 CreateVertexAttribManager(client_ids[ii], service_ids[ii]);
9470 } 9470 }
9471 } 9471 }
9472 9472
9473 return true; 9473 return true;
9474 } 9474 }
9475 9475
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
10525 return error::kNoError; 10525 return error::kNoError;
10526 } 10526 }
10527 10527
10528 // Include the auto-generated part of this file. We split this because it means 10528 // Include the auto-generated part of this file. We split this because it means
10529 // we can easily edit the non-auto generated parts right here in this file 10529 // we can easily edit the non-auto generated parts right here in this file
10530 // instead of having to edit some template or the code generator. 10530 // instead of having to edit some template or the code generator.
10531 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10531 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10532 10532
10533 } // namespace gles2 10533 } // namespace gles2
10534 } // namespace gpu 10534 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698