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

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

Issue 10543125: gpu: Add support for GLX_EXT_texture_from_pixmap extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add image operation queue. Created 8 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 | 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 21 matching lines...) Expand all
32 #include "gpu/command_buffer/service/buffer_manager.h" 32 #include "gpu/command_buffer/service/buffer_manager.h"
33 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
34 #include "gpu/command_buffer/service/context_group.h" 34 #include "gpu/command_buffer/service/context_group.h"
35 #include "gpu/command_buffer/service/context_state.h" 35 #include "gpu/command_buffer/service/context_state.h"
36 #include "gpu/command_buffer/service/feature_info.h" 36 #include "gpu/command_buffer/service/feature_info.h"
37 #include "gpu/command_buffer/service/framebuffer_manager.h" 37 #include "gpu/command_buffer/service/framebuffer_manager.h"
38 #include "gpu/command_buffer/service/gl_utils.h" 38 #include "gpu/command_buffer/service/gl_utils.h"
39 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 39 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
40 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 40 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
41 #include "gpu/command_buffer/service/gpu_switches.h" 41 #include "gpu/command_buffer/service/gpu_switches.h"
42 #include "gpu/command_buffer/service/image_manager.h"
42 #include "gpu/command_buffer/service/mailbox_manager.h" 43 #include "gpu/command_buffer/service/mailbox_manager.h"
43 #include "gpu/command_buffer/service/memory_tracking.h" 44 #include "gpu/command_buffer/service/memory_tracking.h"
44 #include "gpu/command_buffer/service/program_manager.h" 45 #include "gpu/command_buffer/service/program_manager.h"
45 #include "gpu/command_buffer/service/query_manager.h" 46 #include "gpu/command_buffer/service/query_manager.h"
46 #include "gpu/command_buffer/service/renderbuffer_manager.h" 47 #include "gpu/command_buffer/service/renderbuffer_manager.h"
47 #include "gpu/command_buffer/service/shader_manager.h" 48 #include "gpu/command_buffer/service/shader_manager.h"
48 #include "gpu/command_buffer/service/shader_translator.h" 49 #include "gpu/command_buffer/service/shader_translator.h"
49 #include "gpu/command_buffer/service/shader_translator_cache.h" 50 #include "gpu/command_buffer/service/shader_translator_cache.h"
50 #include "gpu/command_buffer/service/stream_texture.h" 51 #include "gpu/command_buffer/service/stream_texture.h"
51 #include "gpu/command_buffer/service/stream_texture_manager.h" 52 #include "gpu/command_buffer/service/stream_texture_manager.h"
52 #include "gpu/command_buffer/service/texture_definition.h" 53 #include "gpu/command_buffer/service/texture_definition.h"
53 #include "gpu/command_buffer/service/texture_manager.h" 54 #include "gpu/command_buffer/service/texture_manager.h"
54 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 55 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
55 #include "gpu/command_buffer/service/vertex_array_manager.h" 56 #include "gpu/command_buffer/service/vertex_array_manager.h"
56 #include "ui/gl/gl_context.h" 57 #include "ui/gl/gl_context.h"
58 #include "ui/gl/gl_image.h"
57 #include "ui/gl/gl_implementation.h" 59 #include "ui/gl/gl_implementation.h"
58 #include "ui/gl/gl_surface.h" 60 #include "ui/gl/gl_surface.h"
59 #if defined(OS_MACOSX) 61 #if defined(OS_MACOSX)
60 #include "ui/surface/io_surface_support_mac.h" 62 #include "ui/surface/io_surface_support_mac.h"
61 #endif 63 #endif
62 64
63 #if !defined(GL_DEPTH24_STENCIL8) 65 #if !defined(GL_DEPTH24_STENCIL8)
64 #define GL_DEPTH24_STENCIL8 0x88F0 66 #define GL_DEPTH24_STENCIL8 0x88F0
65 #endif 67 #endif
66 68
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 611 }
610 612
611 TextureManager* texture_manager() { 613 TextureManager* texture_manager() {
612 return group_->texture_manager(); 614 return group_->texture_manager();
613 } 615 }
614 616
615 MailboxManager* mailbox_manager() { 617 MailboxManager* mailbox_manager() {
616 return group_->mailbox_manager(); 618 return group_->mailbox_manager();
617 } 619 }
618 620
621 ImageManager* image_manager() {
622 return group_->image_manager();
623 }
624
619 VertexArrayManager* vertex_array_manager() { 625 VertexArrayManager* vertex_array_manager() {
620 return vertex_array_manager_.get(); 626 return vertex_array_manager_.get();
621 } 627 }
622 628
623 bool IsOffscreenBufferMultisampled() const { 629 bool IsOffscreenBufferMultisampled() const {
624 return offscreen_target_samples_ > 1; 630 return offscreen_target_samples_ > 1;
625 } 631 }
626 632
627 // Creates a TextureInfo for the given texture. 633 // Creates a TextureInfo for the given texture.
628 TextureManager::TextureInfo* CreateTextureInfo( 634 TextureManager::TextureInfo* CreateTextureInfo(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 void DoTexStorage2DEXT( 746 void DoTexStorage2DEXT(
741 GLenum target, 747 GLenum target,
742 GLint levels, 748 GLint levels,
743 GLenum internal_format, 749 GLenum internal_format,
744 GLsizei width, 750 GLsizei width,
745 GLsizei height); 751 GLsizei height);
746 752
747 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 753 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
748 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); 754 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key);
749 755
756 void DoBindTexImage2DCHROMIUM(
757 GLenum target,
greggman 2012/10/17 18:32:16 style: indent 4
reveman 2012/10/17 21:22:55 Sure. We have 10 declarations with indent 2 above.
758 GLint image_id);
759 void DoReleaseTexImage2DCHROMIUM(
760 GLenum target,
761 GLint image_id);
762
750 // Creates a ProgramInfo for the given program. 763 // Creates a ProgramInfo for the given program.
751 ProgramManager::ProgramInfo* CreateProgramInfo( 764 ProgramManager::ProgramInfo* CreateProgramInfo(
752 GLuint client_id, GLuint service_id) { 765 GLuint client_id, GLuint service_id) {
753 return program_manager()->CreateProgramInfo(client_id, service_id); 766 return program_manager()->CreateProgramInfo(client_id, service_id);
754 } 767 }
755 768
756 // Gets the program info for the given program. Returns NULL if none exists. 769 // Gets the program info for the given program. Returns NULL if none exists.
757 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { 770 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) {
758 return program_manager()->GetProgramInfo(client_id); 771 return program_manager()->GetProgramInfo(client_id);
759 } 772 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 case GL_TEXTURE_RECTANGLE_ARB: 1274 case GL_TEXTURE_RECTANGLE_ARB:
1262 info = unit.bound_texture_rectangle_arb; 1275 info = unit.bound_texture_rectangle_arb;
1263 break; 1276 break;
1264 default: 1277 default:
1265 NOTREACHED(); 1278 NOTREACHED();
1266 return NULL; 1279 return NULL;
1267 } 1280 }
1268 return info; 1281 return info;
1269 } 1282 }
1270 1283
1284 TextureManager::TextureInfo* GetTextureInfoForTargetUnlessDefault(
1285 GLenum target) {
1286 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
1287 if (!info)
1288 return NULL;
1289 if (info == texture_manager()->GetDefaultTextureInfo(target))
1290 return NULL;
1291 return info;
1292 }
1293
1271 GLenum GetBindTargetForSamplerType(GLenum type) { 1294 GLenum GetBindTargetForSamplerType(GLenum type) {
1272 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || 1295 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ||
1273 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); 1296 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB);
1274 switch (type) { 1297 switch (type) {
1275 case GL_SAMPLER_2D: 1298 case GL_SAMPLER_2D:
1276 return GL_TEXTURE_2D; 1299 return GL_TEXTURE_2D;
1277 case GL_SAMPLER_CUBE: 1300 case GL_SAMPLER_CUBE:
1278 return GL_TEXTURE_CUBE_MAP; 1301 return GL_TEXTURE_CUBE_MAP;
1279 case GL_SAMPLER_EXTERNAL_OES: 1302 case GL_SAMPLER_EXTERNAL_OES:
1280 return GL_TEXTURE_EXTERNAL_OES; 1303 return GL_TEXTURE_EXTERNAL_OES;
(...skipping 7634 matching lines...) Expand 10 before | Expand all | Expand 10 after
8915 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we 8938 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we
8916 // could delete a lot of code. For now, perform strict validation so we 8939 // could delete a lot of code. For now, perform strict validation so we
8917 // know what's going on. 8940 // know what's going on.
8918 SetGLError( 8941 SetGLError(
8919 GL_INVALID_OPERATION, 8942 GL_INVALID_OPERATION,
8920 "glTexImageIOSurface2DCHROMIUM", 8943 "glTexImageIOSurface2DCHROMIUM",
8921 "requires TEXTURE_RECTANGLE_ARB target"); 8944 "requires TEXTURE_RECTANGLE_ARB target");
8922 return; 8945 return;
8923 } 8946 }
8924 8947
8925 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8948 // Default target might be conceptually valid, but disallow it to avoid
8949 // accidents.
8950 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault(
8951 target);
8926 if (!info) { 8952 if (!info) {
8927 SetGLError(GL_INVALID_OPERATION, 8953 SetGLError(GL_INVALID_OPERATION,
8928 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound"); 8954 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound");
8929 return; 8955 return;
8930 } 8956 }
8931 if (info == texture_manager()->GetDefaultTextureInfo(target)) {
8932 // Maybe this is conceptually valid, but disallow it to avoid accidents.
8933 SetGLError(GL_INVALID_OPERATION,
8934 "glTexImageIOSurface2DCHROMIUM", "can't bind default texture");
8935 return;
8936 }
8937 8957
8938 // Look up the new IOSurface. Note that because of asynchrony 8958 // Look up the new IOSurface. Note that because of asynchrony
8939 // between processes this might fail; during live resizing the 8959 // between processes this might fail; during live resizing the
8940 // plugin process might allocate and release an IOSurface before 8960 // plugin process might allocate and release an IOSurface before
8941 // this process gets a chance to look it up. Hold on to any old 8961 // this process gets a chance to look it up. Hold on to any old
8942 // IOSurface in this case. 8962 // IOSurface in this case.
8943 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id); 8963 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id);
8944 if (!surface) { 8964 if (!surface) {
8945 SetGLError( 8965 SetGLError(
8946 GL_INVALID_OPERATION, 8966 GL_INVALID_OPERATION,
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
9326 marker = ""; 9346 marker = "";
9327 } 9347 }
9328 debug_marker_manager_.PushGroup( 9348 debug_marker_manager_.PushGroup(
9329 length ? std::string(marker, length) : std::string(marker)); 9349 length ? std::string(marker, length) : std::string(marker));
9330 } 9350 }
9331 9351
9332 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { 9352 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) {
9333 debug_marker_manager_.PopGroup(); 9353 debug_marker_manager_.PopGroup();
9334 } 9354 }
9335 9355
9356 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM(
9357 GLenum target, GLint image_id) {
9358 if (target != GL_TEXTURE_2D) {
9359 // This might be supported in the future.
9360 SetGLError(
9361 GL_INVALID_OPERATION,
9362 "glBindTexImage2DCHROMIUM", "requires TEXTURE_2D target");
9363 return;
9364 }
9365
9366 // Default target might be conceptually valid, but disallow it to avoid
9367 // accidents.
9368 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault(
9369 target);
9370 if (!info) {
9371 SetGLError(GL_INVALID_OPERATION,
9372 "glBindTexImage2DCHROMIUM", "no texture bound");
9373 return;
9374 }
9375
9376 scoped_refptr<gfx::GLImage> gl_image =
9377 image_manager()->LookupImage(image_id);
9378 if (!gl_image) {
9379 SetGLError(GL_INVALID_OPERATION,
9380 "glBindTexImage2DCHROMIUM",
9381 "no image found with the given ID");
9382 return;
9383 }
9384
9385 if (!gl_image->BindTexImage()) {
9386 SetGLError(GL_INVALID_OPERATION,
9387 "glBindTexImage2DCHROMIUM",
9388 "fail to bind image with the given ID");
9389 return;
9390 }
9391
9392 gfx::Size size = gl_image->GetSize();
9393 texture_manager()->SetLevelInfo(
9394 info, target, 0, GL_RGBA, size.width(), size.height(), 1, 0,
9395 GL_RGBA, GL_UNSIGNED_BYTE, true);
9396 texture_manager()->SetLevelImage(info, target, 0, gl_image);
9397 }
9398
9399 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM(
9400 GLenum target, GLint image_id) {
9401 if (target != GL_TEXTURE_2D) {
9402 // This might be supported in the future.
9403 SetGLError(
9404 GL_INVALID_OPERATION,
9405 "glReleaseTexImage2DCHROMIUM", "requires TEXTURE_2D target");
9406 return;
9407 }
9408
9409 // Default target might be conceptually valid, but disallow it to avoid
9410 // accidents.
9411 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault(
9412 target);
9413 if (!info) {
9414 SetGLError(GL_INVALID_OPERATION,
9415 "glReleaseTexImage2DCHROMIUM", "no texture bound");
9416 return;
9417 }
9418
9419 scoped_refptr<gfx::GLImage> gl_image =
9420 image_manager()->LookupImage(image_id);
9421 if (!gl_image) {
9422 SetGLError(GL_INVALID_OPERATION,
9423 "glReleaseTexImage2DCHROMIUM",
9424 "no image found with the given ID");
9425 return;
9426 }
9427
9428 // Do nothing when image is not currently bound.
9429 if (info->GetLevelImage(target, 0) != gl_image)
9430 return;
9431
9432 gl_image->ReleaseTexImage();
9433
9434 texture_manager()->SetLevelInfo(
9435 info, target, 0, GL_RGBA, 0, 0, 1, 0,
9436 GL_RGBA, GL_UNSIGNED_BYTE, false);
9437 }
9336 9438
9337 // Include the auto-generated part of this file. We split this because it means 9439 // Include the auto-generated part of this file. We split this because it means
9338 // we can easily edit the non-auto generated parts right here in this file 9440 // we can easily edit the non-auto generated parts right here in this file
9339 // instead of having to edit some template or the code generator. 9441 // instead of having to edit some template or the code generator.
9340 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9442 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9341 9443
9342 } // namespace gles2 9444 } // namespace gles2
9343 } // namespace gpu 9445 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698