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

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 kGLImplementationMockGL case to gl_image_android.cc. 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 17 matching lines...) Expand all
646 // or regular back buffer). 652 // or regular back buffer).
647 gfx::Size GetBoundReadFrameBufferSize(); 653 gfx::Size GetBoundReadFrameBufferSize();
648 654
649 // Get the format of the currently bound frame buffer (either FBO or regular 655 // Get the format of the currently bound frame buffer (either FBO or regular
650 // back buffer) 656 // back buffer)
651 GLenum GetBoundReadFrameBufferInternalFormat(); 657 GLenum GetBoundReadFrameBufferInternalFormat();
652 GLenum GetBoundDrawFrameBufferInternalFormat(); 658 GLenum GetBoundDrawFrameBufferInternalFormat();
653 659
654 // Wrapper for CompressedTexImage2D commands. 660 // Wrapper for CompressedTexImage2D commands.
655 error::Error DoCompressedTexImage2D( 661 error::Error DoCompressedTexImage2D(
656 GLenum target, 662 GLenum target,
657 GLint level, 663 GLint level,
658 GLenum internal_format, 664 GLenum internal_format,
659 GLsizei width, 665 GLsizei width,
660 GLsizei height, 666 GLsizei height,
661 GLint border, 667 GLint border,
662 GLsizei image_size, 668 GLsizei image_size,
663 const void* data); 669 const void* data);
664 670
665 // Wrapper for CompressedTexSubImage2D. 671 // Wrapper for CompressedTexSubImage2D.
666 void DoCompressedTexSubImage2D( 672 void DoCompressedTexSubImage2D(
667 GLenum target, 673 GLenum target,
668 GLint level, 674 GLint level,
669 GLint xoffset, 675 GLint xoffset,
670 GLint yoffset, 676 GLint yoffset,
671 GLsizei width, 677 GLsizei width,
672 GLsizei height, 678 GLsizei height,
673 GLenum format, 679 GLenum format,
674 GLsizei imageSize, 680 GLsizei imageSize,
675 const void * data); 681 const void * data);
676 682
677 // Wrapper for CopyTexImage2D. 683 // Wrapper for CopyTexImage2D.
678 void DoCopyTexImage2D( 684 void DoCopyTexImage2D(
679 GLenum target, 685 GLenum target,
680 GLint level, 686 GLint level,
681 GLenum internal_format, 687 GLenum internal_format,
682 GLint x, 688 GLint x,
683 GLint y, 689 GLint y,
684 GLsizei width, 690 GLsizei width,
685 GLsizei height, 691 GLsizei height,
686 GLint border); 692 GLint border);
687 693
688 // Wrapper for CopyTexSubImage2D. 694 // Wrapper for CopyTexSubImage2D.
689 void DoCopyTexSubImage2D( 695 void DoCopyTexSubImage2D(
690 GLenum target, 696 GLenum target,
691 GLint level, 697 GLint level,
692 GLint xoffset, 698 GLint xoffset,
693 GLint yoffset, 699 GLint yoffset,
694 GLint x, 700 GLint x,
695 GLint y, 701 GLint y,
696 GLsizei width, 702 GLsizei width,
697 GLsizei height); 703 GLsizei height);
698 704
699 // Wrapper for TexImage2D commands. 705 // Wrapper for TexImage2D commands.
700 error::Error DoTexImage2D( 706 error::Error DoTexImage2D(
701 GLenum target, 707 GLenum target,
702 GLint level, 708 GLint level,
703 GLenum internal_format, 709 GLenum internal_format,
704 GLsizei width, 710 GLsizei width,
705 GLsizei height, 711 GLsizei height,
706 GLint border, 712 GLint border,
707 GLenum format, 713 GLenum format,
708 GLenum type, 714 GLenum type,
709 const void* pixels, 715 const void* pixels,
710 uint32 pixels_size); 716 uint32 pixels_size);
711 717
712 // Wrapper for TexSubImage2D. 718 // Wrapper for TexSubImage2D.
713 void DoTexSubImage2D( 719 void DoTexSubImage2D(
714 GLenum target, 720 GLenum target,
715 GLint level, 721 GLint level,
716 GLint xoffset, 722 GLint xoffset,
717 GLint yoffset, 723 GLint yoffset,
718 GLsizei width, 724 GLsizei width,
719 GLsizei height, 725 GLsizei height,
720 GLenum format, 726 GLenum format,
721 GLenum type, 727 GLenum type,
722 const void * data); 728 const void * data);
723 729
724 // Wrapper for TexImageIOSurface2DCHROMIUM. 730 // Wrapper for TexImageIOSurface2DCHROMIUM.
725 void DoTexImageIOSurface2DCHROMIUM( 731 void DoTexImageIOSurface2DCHROMIUM(
726 GLenum target, 732 GLenum target,
727 GLsizei width, 733 GLsizei width,
728 GLsizei height, 734 GLsizei height,
729 GLuint io_surface_id, 735 GLuint io_surface_id,
730 GLuint plane); 736 GLuint plane);
731 737
732 void DoCopyTextureCHROMIUM( 738 void DoCopyTextureCHROMIUM(
733 GLenum target, 739 GLenum target,
734 GLuint source_id, 740 GLuint source_id,
735 GLuint target_id, 741 GLuint target_id,
736 GLint level, 742 GLint level,
737 GLenum internal_format); 743 GLenum internal_format);
738 744
739 // Wrapper for TexStorage2DEXT. 745 // Wrapper for TexStorage2DEXT.
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,
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 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM");
9359 if (target != GL_TEXTURE_2D) {
9360 // This might be supported in the future.
9361 SetGLError(
9362 GL_INVALID_OPERATION,
9363 "glBindTexImage2DCHROMIUM", "requires TEXTURE_2D target");
9364 return;
9365 }
9366
9367 // Default target might be conceptually valid, but disallow it to avoid
9368 // accidents.
9369 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault(
9370 target);
9371 if (!info) {
9372 SetGLError(GL_INVALID_OPERATION,
9373 "glBindTexImage2DCHROMIUM", "no texture bound");
9374 return;
9375 }
9376
9377 gfx::GLImage* gl_image = 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 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM");
9402 if (target != GL_TEXTURE_2D) {
9403 // This might be supported in the future.
9404 SetGLError(
9405 GL_INVALID_OPERATION,
9406 "glReleaseTexImage2DCHROMIUM", "requires TEXTURE_2D target");
9407 return;
9408 }
9409
9410 // Default target might be conceptually valid, but disallow it to avoid
9411 // accidents.
9412 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault(
9413 target);
9414 if (!info) {
9415 SetGLError(GL_INVALID_OPERATION,
9416 "glReleaseTexImage2DCHROMIUM", "no texture bound");
9417 return;
9418 }
9419
9420 gfx::GLImage* gl_image = 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
« no previous file with comments | « gpu/command_buffer/service/context_group_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698