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

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

Issue 2648893002: Remove remaining traces of CreateGpuMemoryBufferImageCHROMIUM (Closed)
Patch Set: Rebase, but don't pull in extra changes... Created 3 years, 10 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/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 3754 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 // Clears the bucket so if the command fails nothing will be in it. 3765 // Clears the bucket so if the command fails nothing will be in it.
3766 helper_->SetBucketSize(kResultBucketId, 0); 3766 helper_->SetBucketSize(kResultBucketId, 0);
3767 helper_->GetString(name, kResultBucketId); 3767 helper_->GetString(name, kResultBucketId);
3768 std::string str; 3768 std::string str;
3769 if (GetBucketAsString(kResultBucketId, &str)) { 3769 if (GetBucketAsString(kResultBucketId, &str)) {
3770 // Adds extensions implemented on client side only. 3770 // Adds extensions implemented on client side only.
3771 if (name == GL_EXTENSIONS) { 3771 if (name == GL_EXTENSIONS) {
3772 str += std::string(str.empty() ? "" : " ") + 3772 str += std::string(str.empty() ? "" : " ") +
3773 "GL_EXT_unpack_subimage " 3773 "GL_EXT_unpack_subimage "
3774 "GL_CHROMIUM_map_sub " 3774 "GL_CHROMIUM_map_sub "
3775 "GL_CHROMIUM_image " 3775 "GL_CHROMIUM_image";
3776 "GL_CHROMIUM_gpu_memory_buffer_image";
3777 if (capabilities_.future_sync_points) 3776 if (capabilities_.future_sync_points)
3778 str += " GL_CHROMIUM_future_sync_point"; 3777 str += " GL_CHROMIUM_future_sync_point";
3779 } 3778 }
3780 3779
3781 // Because of WebGL the extensions can change. We have to cache each unique 3780 // Because of WebGL the extensions can change. We have to cache each unique
3782 // result since we don't know when the client will stop referring to a 3781 // result since we don't know when the client will stop referring to a
3783 // previous one it queries. 3782 // previous one it queries.
3784 // TODO: Here we could save memory by defining RequestExtensions 3783 // TODO: Here we could save memory by defining RequestExtensions
3785 // invalidating the GL_EXTENSIONS string. http://crbug.com/586414 3784 // invalidating the GL_EXTENSIONS string. http://crbug.com/586414
3786 const std::string& cache = *gl_strings_.insert(str).first; 3785 const std::string& cache = *gl_strings_.insert(str).first;
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
6192 case GL_RGB_YCBCR_422_CHROMIUM: 6191 case GL_RGB_YCBCR_422_CHROMIUM:
6193 case GL_RGB_YCBCR_420V_CHROMIUM: 6192 case GL_RGB_YCBCR_420V_CHROMIUM:
6194 case GL_RGB_YCRCB_420_CHROMIUM: 6193 case GL_RGB_YCRCB_420_CHROMIUM:
6195 case GL_BGRA_EXT: 6194 case GL_BGRA_EXT:
6196 return true; 6195 return true;
6197 default: 6196 default:
6198 return false; 6197 return false;
6199 } 6198 }
6200 } 6199 }
6201 6200
6202 bool CreateGpuMemoryBufferValidInternalFormat(GLenum internalformat) {
6203 switch (internalformat) {
6204 case GL_RGB:
6205 case GL_RGBA:
6206 return true;
6207 default:
6208 return false;
6209 }
6210 }
6211
6212 bool ValidImageUsage(GLenum usage) {
6213 return usage == GL_READ_WRITE_CHROMIUM;
6214 }
6215
6216 } // namespace 6201 } // namespace
6217 6202
6218 GLuint GLES2Implementation::CreateImageCHROMIUMHelper(ClientBuffer buffer, 6203 GLuint GLES2Implementation::CreateImageCHROMIUMHelper(ClientBuffer buffer,
6219 GLsizei width, 6204 GLsizei width,
6220 GLsizei height, 6205 GLsizei height,
6221 GLenum internalformat) { 6206 GLenum internalformat) {
6222 if (width <= 0) { 6207 if (width <= 0) {
6223 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "width <= 0"); 6208 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "width <= 0");
6224 return 0; 6209 return 0;
6225 } 6210 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6270 } 6255 }
6271 6256
6272 void GLES2Implementation::DestroyImageCHROMIUM(GLuint image_id) { 6257 void GLES2Implementation::DestroyImageCHROMIUM(GLuint image_id) {
6273 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6258 GPU_CLIENT_SINGLE_THREAD_CHECK();
6274 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDestroyImageCHROMIUM(" 6259 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDestroyImageCHROMIUM("
6275 << image_id << ")"); 6260 << image_id << ")");
6276 DestroyImageCHROMIUMHelper(image_id); 6261 DestroyImageCHROMIUMHelper(image_id);
6277 CheckGLError(); 6262 CheckGLError();
6278 } 6263 }
6279 6264
6280 GLuint GLES2Implementation::CreateGpuMemoryBufferImageCHROMIUMHelper(
6281 GLsizei width,
6282 GLsizei height,
6283 GLenum internalformat,
6284 GLenum usage) {
6285 if (width <= 0) {
6286 SetGLError(
6287 GL_INVALID_VALUE, "glCreateGpuMemoryBufferImageCHROMIUM", "width <= 0");
6288 return 0;
6289 }
6290
6291 if (height <= 0) {
6292 SetGLError(GL_INVALID_VALUE,
6293 "glCreateGpuMemoryBufferImageCHROMIUM",
6294 "height <= 0");
6295 return 0;
6296 }
6297
6298 if (!CreateGpuMemoryBufferValidInternalFormat(internalformat)) {
6299 SetGLError(GL_INVALID_VALUE,
6300 "glCreateGpuMemoryBufferImageCHROMIUM",
6301 "invalid format");
6302 return 0;
6303 }
6304
6305 if (!ValidImageUsage(usage)) {
6306 SetGLError(GL_INVALID_VALUE,
6307 "glCreateGpuMemoryBufferImageCHROMIUM",
6308 "invalid usage");
6309 return 0;
6310 }
6311
6312 // Flush the command stream to ensure ordering in case the newly
6313 // returned image_id has recently been in use with a different buffer.
6314 helper_->CommandBufferHelper::Flush();
6315 int32_t image_id = gpu_control_->CreateGpuMemoryBufferImage(
6316 width, height, internalformat, usage);
6317 if (image_id < 0) {
6318 SetGLError(GL_OUT_OF_MEMORY,
6319 "glCreateGpuMemoryBufferImageCHROMIUM",
6320 "image_id < 0");
6321 return 0;
6322 }
6323 return image_id;
6324 }
6325
6326 GLuint GLES2Implementation::CreateGpuMemoryBufferImageCHROMIUM(
6327 GLsizei width,
6328 GLsizei height,
6329 GLenum internalformat,
6330 GLenum usage) {
6331 GPU_CLIENT_SINGLE_THREAD_CHECK();
6332 GPU_CLIENT_LOG("[" << GetLogPrefix()
6333 << "] glCreateGpuMemoryBufferImageCHROMIUM(" << width
6334 << ", " << height << ", "
6335 << GLES2Util::GetStringImageInternalFormat(internalformat)
6336 << ", " << GLES2Util::GetStringImageUsage(usage) << ")");
6337 GLuint image_id = CreateGpuMemoryBufferImageCHROMIUMHelper(
6338 width, height, internalformat, usage);
6339 CheckGLError();
6340 return image_id;
6341 }
6342
6343 bool GLES2Implementation::ValidateSize(const char* func, GLsizeiptr size) { 6265 bool GLES2Implementation::ValidateSize(const char* func, GLsizeiptr size) {
6344 if (size < 0) { 6266 if (size < 0) {
6345 SetGLError(GL_INVALID_VALUE, func, "size < 0"); 6267 SetGLError(GL_INVALID_VALUE, func, "size < 0");
6346 return false; 6268 return false;
6347 } 6269 }
6348 if (!base::IsValueInRangeForNumericType<int32_t>(size)) { 6270 if (!base::IsValueInRangeForNumericType<int32_t>(size)) {
6349 SetGLError(GL_INVALID_OPERATION, func, "size more than 32-bit"); 6271 SetGLError(GL_INVALID_OPERATION, func, "size more than 32-bit");
6350 return false; 6272 return false;
6351 } 6273 }
6352 return true; 6274 return true;
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
7101 CheckGLError(); 7023 CheckGLError();
7102 } 7024 }
7103 7025
7104 // Include the auto-generated part of this file. We split this because it means 7026 // Include the auto-generated part of this file. We split this because it means
7105 // we can easily edit the non-auto generated parts right here in this file 7027 // we can easily edit the non-auto generated parts right here in this file
7106 // instead of having to edit some template or the code generator. 7028 // instead of having to edit some template or the code generator.
7107 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 7029 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
7108 7030
7109 } // namespace gles2 7031 } // namespace gles2
7110 } // namespace gpu 7032 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698