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

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

Issue 169403005: command_buffer: Implement path rendering functions for CHROMIUM_path_rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nv-pr-02-texgen
Patch Set: rebase and cleanup ids Created 6 years, 2 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
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include <GLES2/gl2extchromium.h> 10 #include <GLES2/gl2extchromium.h>
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 320 }
321 321
322 GLES2CmdHelper* GLES2Implementation::helper() const { 322 GLES2CmdHelper* GLES2Implementation::helper() const {
323 return helper_; 323 return helper_;
324 } 324 }
325 325
326 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const { 326 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const {
327 return share_group_->GetIdHandler(namespace_id); 327 return share_group_->GetIdHandler(namespace_id);
328 } 328 }
329 329
330 RangeIdHandlerInterface* GLES2Implementation::GetRangeIdHandler(
331 int namespace_id) const {
332 return share_group_->GetRangeIdHandler(namespace_id);
333 }
334
330 IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const { 335 IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const {
331 if (namespace_id == id_namespaces::kQueries) 336 if (namespace_id == id_namespaces::kQueries)
332 return query_id_allocator_.get(); 337 return query_id_allocator_.get();
333 NOTREACHED(); 338 NOTREACHED();
334 return NULL; 339 return NULL;
335 } 340 }
336 341
337 void* GLES2Implementation::GetResultBuffer() { 342 void* GLES2Implementation::GetResultBuffer() {
338 return transfer_buffer_->GetResultBuffer(); 343 return transfer_buffer_->GetResultBuffer();
339 } 344 }
(...skipping 3762 matching lines...) Expand 10 before | Expand all | Expand 10 after
4102 SetGLError(GL_INVALID_VALUE, func, "offset < 0"); 4107 SetGLError(GL_INVALID_VALUE, func, "offset < 0");
4103 return false; 4108 return false;
4104 } 4109 }
4105 if (!FitInt32NonNegative<GLintptr>(offset)) { 4110 if (!FitInt32NonNegative<GLintptr>(offset)) {
4106 SetGLError(GL_INVALID_OPERATION, func, "offset more than 32-bit"); 4111 SetGLError(GL_INVALID_OPERATION, func, "offset more than 32-bit");
4107 return false; 4112 return false;
4108 } 4113 }
4109 return true; 4114 return true;
4110 } 4115 }
4111 4116
4117 GLuint GLES2Implementation::GenPathsCHROMIUM(GLsizei range) {
4118 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenPathsCHROMIUM(" << range
4119 << ")");
4120 GPU_CLIENT_SINGLE_THREAD_CHECK();
4121
4122 if (range < 0) {
4123 SetGLError(GL_INVALID_VALUE, "glGenPathsCHROMIUM", "range < 0");
4124 return 0;
4125 }
4126 if (!FitInt32NonNegative(range)) {
4127 SetGLError(
4128 GL_INVALID_VALUE, "glGenPathsCHROMIUM", "range more than 32-bit");
4129 return 0;
4130 }
4131
4132 if (range == 0) {
4133 return 0;
4134 }
4135
4136 GLuint first_client_id = 0;
4137 GetRangeIdHandler(id_namespaces::kPaths)
4138 ->MakeIdRange(this, range, &first_client_id);
4139
4140 if (first_client_id == 0) {
4141 // Ran out of id space. Is not specified to raise any gl errors.
4142 return 0;
4143 }
4144
4145 helper_->GenPathsCHROMIUM(first_client_id, range);
4146
4147 GPU_CLIENT_LOG_CODE_BLOCK({
4148 for (GLsizei i = 0; i < range; ++i) {
4149 GPU_CLIENT_LOG(" " << i << ": " << (first_client_id + i));
4150 }
4151 });
4152 CheckGLError();
4153 return first_client_id;
4154 }
4155
4156 void GLES2Implementation::DeletePathsCHROMIUM(GLuint first_client_id,
4157 GLsizei range) {
4158 GPU_CLIENT_SINGLE_THREAD_CHECK();
4159 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeletePathsCHROMIUM("
4160 << first_client_id << ", " << range << ")");
4161
4162 if (range < 0) {
4163 SetGLError(GL_INVALID_VALUE, "glDeletePathsCHROMIUM", "range < 0");
4164 return;
4165 }
4166
4167 if (!FitInt32NonNegative(range)) {
4168 SetGLError(
4169 GL_INVALID_VALUE, "glGenPathsCHROMIUM", "range more than 32-bit");
4170 return;
4171 }
4172
4173 if (range == 0) {
4174 return;
4175 }
4176
4177 GetRangeIdHandler(id_namespaces::kPaths)
4178 ->FreeIdRange(this,
4179 first_client_id,
4180 range,
4181 &GLES2Implementation::DeletePathsCHROMIUMStub);
4182 // Deleting non-existing paths does not produce errors in the extension.
4183 }
4184
4185 void GLES2Implementation::DeletePathsCHROMIUMStub(GLuint first_client_id,
4186 GLsizei range) {
4187 helper_->DeletePathsCHROMIUM(first_client_id, range);
4188 }
4189
4190 void GLES2Implementation::PathCommandsCHROMIUM(GLuint path,
4191 GLsizei num_commands,
4192 const GLubyte* commands,
4193 GLsizei num_coords,
4194 const GLfloat* coords) {
4195 GPU_CLIENT_SINGLE_THREAD_CHECK();
4196 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glPathCommandsCHROMIUM(" << path
4197 << ", " << num_commands << ", " << commands << ", "
4198 << num_coords << ", " << coords << ")");
4199 if (path == 0) {
4200 SetGLError(
4201 GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "invalid path object");
4202 return;
4203 }
4204 if (num_commands < 0) {
4205 SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "numCommands < 0");
4206 return;
4207 }
4208 if (num_commands != 0 && !commands) {
4209 SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "missing commands");
4210 return;
4211 }
4212
4213 if (num_coords < 0) {
4214 SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "numCoords < 0");
4215 return;
4216 }
4217 if (num_coords != 0 && !coords) {
4218 SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "missing coords");
4219 return;
4220 }
4221
4222 if (num_commands == 0 && num_coords == 0) {
4223 helper_->PathCommandsCHROMIUM(path, 0, 0, 0, 0, 0, 0);
4224 return;
4225 }
4226
4227 uint32 coords_size = sizeof(GLfloat) * num_coords;
4228
4229 ScopedTransferBufferPtr buffer(
4230 coords_size + num_commands, helper_, transfer_buffer_);
4231 if (!buffer.valid() || buffer.size() < coords_size + num_commands) {
4232 SetGLError(GL_INVALID_VALUE,
4233 "glPathCommandsCHROMIUM",
4234 "no room in transfer buffer for coords and commands");
4235 return;
4236 }
4237
4238 // Copy coords first because they need stricter alignment.
4239 unsigned char* coords_addr = static_cast<unsigned char*>(buffer.address());
4240 memcpy(coords_addr, coords, coords_size);
4241
4242 unsigned char* commands_addr =
4243 static_cast<unsigned char*>(buffer.address()) + coords_size;
4244 memcpy(commands_addr, commands, num_commands);
4245 helper_->PathCommandsCHROMIUM(path,
4246 num_commands,
4247 buffer.shm_id(),
4248 buffer.offset() + coords_size,
4249 num_coords,
4250 buffer.shm_id(),
4251 buffer.offset());
4252 CheckGLError();
4253 }
4254
4112 // Include the auto-generated part of this file. We split this because it means 4255 // Include the auto-generated part of this file. We split this because it means
4113 // we can easily edit the non-auto generated parts right here in this file 4256 // we can easily edit the non-auto generated parts right here in this file
4114 // instead of having to edit some template or the code generator. 4257 // instead of having to edit some template or the code generator.
4115 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 4258 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
4116 4259
4117 } // namespace gles2 4260 } // namespace gles2
4118 } // namespace gpu 4261 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698