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

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

Issue 12649002: Refactor GPU code. Buffer* info to Buffer* buffer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 return info; 958 return info;
959 } 959 }
960 960
961 // Creates a buffer info for the given buffer. 961 // Creates a buffer info for the given buffer.
962 void CreateBuffer(GLuint client_id, GLuint service_id) { 962 void CreateBuffer(GLuint client_id, GLuint service_id) {
963 return buffer_manager()->CreateBuffer(client_id, service_id); 963 return buffer_manager()->CreateBuffer(client_id, service_id);
964 } 964 }
965 965
966 // Gets the buffer info for the given buffer. 966 // Gets the buffer info for the given buffer.
967 Buffer* GetBuffer(GLuint client_id) { 967 Buffer* GetBuffer(GLuint client_id) {
968 Buffer* info = 968 Buffer* buffer = buffer_manager()->GetBuffer(client_id);
969 buffer_manager()->GetBuffer(client_id); 969 return buffer;
970 return info;
971 } 970 }
972 971
973 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used 972 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used
974 // on glDeleteBuffers so we can make sure the user does not try to render 973 // on glDeleteBuffers so we can make sure the user does not try to render
975 // with deleted buffers. 974 // with deleted buffers.
976 void RemoveBuffer(GLuint client_id); 975 void RemoveBuffer(GLuint client_id);
977 976
978 // Creates a framebuffer info for the given framebuffer. 977 // Creates a framebuffer info for the given framebuffer.
979 void CreateFramebuffer(GLuint client_id, GLuint service_id) { 978 void CreateFramebuffer(GLuint client_id, GLuint service_id) {
980 return framebuffer_manager()->CreateFramebuffer(client_id, service_id); 979 return framebuffer_manager()->CreateFramebuffer(client_id, service_id);
(...skipping 2564 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 if (texture_index >= state_.texture_units.size()) { 3544 if (texture_index >= state_.texture_units.size()) {
3546 SetGLErrorInvalidEnum( 3545 SetGLErrorInvalidEnum(
3547 "glActiveTexture", texture_unit, "texture_unit"); 3546 "glActiveTexture", texture_unit, "texture_unit");
3548 return; 3547 return;
3549 } 3548 }
3550 state_.active_texture_unit = texture_index; 3549 state_.active_texture_unit = texture_index;
3551 glActiveTexture(texture_unit); 3550 glActiveTexture(texture_unit);
3552 } 3551 }
3553 3552
3554 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { 3553 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) {
3555 Buffer* info = NULL; 3554 Buffer* buffer = NULL;
3556 GLuint service_id = 0; 3555 GLuint service_id = 0;
3557 if (client_id != 0) { 3556 if (client_id != 0) {
3558 info = GetBuffer(client_id); 3557 buffer = GetBuffer(client_id);
3559 if (!info) { 3558 if (!buffer) {
3560 if (!group_->bind_generates_resource()) { 3559 if (!group_->bind_generates_resource()) {
3561 LOG(ERROR) << "glBindBuffer: id not generated by glGenBuffers"; 3560 LOG(ERROR) << "glBindBuffer: id not generated by glGenBuffers";
3562 current_decoder_error_ = error::kGenericError; 3561 current_decoder_error_ = error::kGenericError;
3563 return; 3562 return;
3564 } 3563 }
3565 3564
3566 // It's a new id so make a buffer info for it. 3565 // It's a new id so make a buffer buffer for it.
3567 glGenBuffersARB(1, &service_id); 3566 glGenBuffersARB(1, &service_id);
3568 CreateBuffer(client_id, service_id); 3567 CreateBuffer(client_id, service_id);
3569 info = GetBuffer(client_id); 3568 buffer = GetBuffer(client_id);
3570 IdAllocatorInterface* id_allocator = 3569 IdAllocatorInterface* id_allocator =
3571 group_->GetIdAllocator(id_namespaces::kBuffers); 3570 group_->GetIdAllocator(id_namespaces::kBuffers);
3572 id_allocator->MarkAsUsed(client_id); 3571 id_allocator->MarkAsUsed(client_id);
3573 } 3572 }
3574 } 3573 }
3575 LogClientServiceForInfo(info, client_id, "glBindBuffer"); 3574 LogClientServiceForInfo(buffer, client_id, "glBindBuffer");
3576 if (info) { 3575 if (buffer) {
3577 if (!buffer_manager()->SetTarget(info, target)) { 3576 if (!buffer_manager()->SetTarget(buffer, target)) {
3578 SetGLError(GL_INVALID_OPERATION, 3577 SetGLError(GL_INVALID_OPERATION,
3579 "glBindBuffer", "buffer bound to more than 1 target"); 3578 "glBindBuffer", "buffer bound to more than 1 target");
3580 return; 3579 return;
3581 } 3580 }
3582 service_id = info->service_id(); 3581 service_id = buffer->service_id();
3583 } 3582 }
3584 switch (target) { 3583 switch (target) {
3585 case GL_ARRAY_BUFFER: 3584 case GL_ARRAY_BUFFER:
3586 state_.bound_array_buffer = info; 3585 state_.bound_array_buffer = buffer;
3587 break; 3586 break;
3588 case GL_ELEMENT_ARRAY_BUFFER: 3587 case GL_ELEMENT_ARRAY_BUFFER:
3589 state_.vertex_attrib_manager->SetElementArrayBuffer(info); 3588 state_.vertex_attrib_manager->SetElementArrayBuffer(buffer);
3590 break; 3589 break;
3591 default: 3590 default:
3592 NOTREACHED(); // Validation should prevent us getting here. 3591 NOTREACHED(); // Validation should prevent us getting here.
3593 break; 3592 break;
3594 } 3593 }
3595 glBindBuffer(target, service_id); 3594 glBindBuffer(target, service_id);
3596 } 3595 }
3597 3596
3598 bool GLES2DecoderImpl::BoundFramebufferHasColorAttachmentWithAlpha() { 3597 bool GLES2DecoderImpl::BoundFramebufferHasColorAttachmentWithAlpha() {
3599 return (GLES2Util::GetChannelsForFormat( 3598 return (GLES2Util::GetChannelsForFormat(
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5824 glVertexAttribDivisorANGLE(0, 0); 5823 glVertexAttribDivisorANGLE(0, 0);
5825 5824
5826 *simulated = true; 5825 *simulated = true;
5827 return true; 5826 return true;
5828 } 5827 }
5829 5828
5830 void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib) { 5829 void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib) {
5831 const VertexAttrib* info = 5830 const VertexAttrib* info =
5832 state_.vertex_attrib_manager->GetVertexAttrib(attrib); 5831 state_.vertex_attrib_manager->GetVertexAttrib(attrib);
5833 const void* ptr = reinterpret_cast<const void*>(info->offset()); 5832 const void* ptr = reinterpret_cast<const void*>(info->offset());
5834 Buffer* buffer_info = info->buffer(); 5833 Buffer* buffer = info->buffer();
5835 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); 5834 glBindBuffer(GL_ARRAY_BUFFER, buffer ? buffer->service_id() : 0);
5836 glVertexAttribPointer( 5835 glVertexAttribPointer(
5837 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(), 5836 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(),
5838 ptr); 5837 ptr);
5839 if (info->divisor()) 5838 if (info->divisor())
5840 glVertexAttribDivisorANGLE(attrib, info->divisor()); 5839 glVertexAttribDivisorANGLE(attrib, info->divisor());
5841 glBindBuffer( 5840 glBindBuffer(
5842 GL_ARRAY_BUFFER, 5841 GL_ARRAY_BUFFER,
5843 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); 5842 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0);
5844 5843
5845 // Never touch vertex attribute 0's state (in particular, never 5844 // Never touch vertex attribute 0's state (in particular, never
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
6200 static_cast<GLenum>(c.mode), 6199 static_cast<GLenum>(c.mode),
6201 static_cast<GLsizei>(c.count), 6200 static_cast<GLsizei>(c.count),
6202 static_cast<GLenum>(c.type), 6201 static_cast<GLenum>(c.type),
6203 static_cast<int32>(c.index_offset), 6202 static_cast<int32>(c.index_offset),
6204 static_cast<GLsizei>(c.primcount)); 6203 static_cast<GLsizei>(c.primcount));
6205 } 6204 }
6206 6205
6207 GLuint GLES2DecoderImpl::DoGetMaxValueInBufferCHROMIUM( 6206 GLuint GLES2DecoderImpl::DoGetMaxValueInBufferCHROMIUM(
6208 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { 6207 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
6209 GLuint max_vertex_accessed = 0; 6208 GLuint max_vertex_accessed = 0;
6210 Buffer* info = GetBuffer(buffer_id); 6209 Buffer* buffer = GetBuffer(buffer_id);
6211 if (!info) { 6210 if (!buffer) {
6212 // TODO(gman): Should this be a GL error or a command buffer error? 6211 // TODO(gman): Should this be a GL error or a command buffer error?
6213 SetGLError(GL_INVALID_VALUE, 6212 SetGLError(GL_INVALID_VALUE,
6214 "GetMaxValueInBufferCHROMIUM", "unknown buffer"); 6213 "GetMaxValueInBufferCHROMIUM", "unknown buffer");
6215 } else { 6214 } else {
6216 if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) { 6215 if (!buffer->GetMaxValueForRange(
6216 offset, count, type, &max_vertex_accessed)) {
6217 // TODO(gman): Should this be a GL error or a command buffer error? 6217 // TODO(gman): Should this be a GL error or a command buffer error?
6218 SetGLError( 6218 SetGLError(
6219 GL_INVALID_OPERATION, 6219 GL_INVALID_OPERATION,
6220 "GetMaxValueInBufferCHROMIUM", "range out of bounds for buffer"); 6220 "GetMaxValueInBufferCHROMIUM", "range out of bounds for buffer");
6221 } 6221 }
6222 } 6222 }
6223 return max_vertex_accessed; 6223 return max_vertex_accessed;
6224 } 6224 }
6225 6225
6226 // Calls glShaderSource for the various versions of the ShaderSource command. 6226 // Calls glShaderSource for the various versions of the ShaderSource command.
(...skipping 3928 matching lines...) Expand 10 before | Expand all | Expand 10 after
10155 return error::kNoError; 10155 return error::kNoError;
10156 } 10156 }
10157 10157
10158 // Include the auto-generated part of this file. We split this because it means 10158 // Include the auto-generated part of this file. We split this because it means
10159 // we can easily edit the non-auto generated parts right here in this file 10159 // we can easily edit the non-auto generated parts right here in this file
10160 // instead of having to edit some template or the code generator. 10160 // instead of having to edit some template or the code generator.
10161 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10161 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10162 10162
10163 } // namespace gles2 10163 } // namespace gles2
10164 } // namespace gpu 10164 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state.cc ('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