OLD | NEW |
---|---|
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 20 matching lines...) Expand all Loading... | |
31 #include "gpu/command_buffer/common/id_allocator.h" | 31 #include "gpu/command_buffer/common/id_allocator.h" |
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/feature_info.h" | 35 #include "gpu/command_buffer/service/feature_info.h" |
36 #include "gpu/command_buffer/service/framebuffer_manager.h" | 36 #include "gpu/command_buffer/service/framebuffer_manager.h" |
37 #include "gpu/command_buffer/service/gl_utils.h" | 37 #include "gpu/command_buffer/service/gl_utils.h" |
38 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 38 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
39 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 39 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
40 #include "gpu/command_buffer/service/gpu_switches.h" | 40 #include "gpu/command_buffer/service/gpu_switches.h" |
41 #include "gpu/command_buffer/service/image_manager.h" | |
41 #include "gpu/command_buffer/service/mailbox_manager.h" | 42 #include "gpu/command_buffer/service/mailbox_manager.h" |
42 #include "gpu/command_buffer/service/memory_tracking.h" | 43 #include "gpu/command_buffer/service/memory_tracking.h" |
43 #include "gpu/command_buffer/service/program_manager.h" | 44 #include "gpu/command_buffer/service/program_manager.h" |
44 #include "gpu/command_buffer/service/query_manager.h" | 45 #include "gpu/command_buffer/service/query_manager.h" |
45 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 46 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
46 #include "gpu/command_buffer/service/shader_manager.h" | 47 #include "gpu/command_buffer/service/shader_manager.h" |
47 #include "gpu/command_buffer/service/shader_translator.h" | 48 #include "gpu/command_buffer/service/shader_translator.h" |
48 #include "gpu/command_buffer/service/shader_translator_cache.h" | 49 #include "gpu/command_buffer/service/shader_translator_cache.h" |
49 #include "gpu/command_buffer/service/stream_texture.h" | 50 #include "gpu/command_buffer/service/stream_texture.h" |
50 #include "gpu/command_buffer/service/stream_texture_manager.h" | 51 #include "gpu/command_buffer/service/stream_texture_manager.h" |
51 #include "gpu/command_buffer/service/texture_definition.h" | 52 #include "gpu/command_buffer/service/texture_definition.h" |
52 #include "gpu/command_buffer/service/texture_manager.h" | 53 #include "gpu/command_buffer/service/texture_manager.h" |
53 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 54 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
54 #include "gpu/command_buffer/service/vertex_array_manager.h" | 55 #include "gpu/command_buffer/service/vertex_array_manager.h" |
55 #include "ui/gl/gl_context.h" | 56 #include "ui/gl/gl_context.h" |
57 #include "ui/gl/gl_image.h" | |
56 #include "ui/gl/gl_implementation.h" | 58 #include "ui/gl/gl_implementation.h" |
57 #include "ui/gl/gl_surface.h" | 59 #include "ui/gl/gl_surface.h" |
58 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
59 #include "ui/surface/io_surface_support_mac.h" | 61 #include "ui/surface/io_surface_support_mac.h" |
60 #endif | 62 #endif |
61 | 63 |
62 #if !defined(GL_DEPTH24_STENCIL8) | 64 #if !defined(GL_DEPTH24_STENCIL8) |
63 #define GL_DEPTH24_STENCIL8 0x88F0 | 65 #define GL_DEPTH24_STENCIL8 0x88F0 |
64 #endif | 66 #endif |
65 | 67 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 } | 663 } |
662 | 664 |
663 TextureManager* texture_manager() { | 665 TextureManager* texture_manager() { |
664 return group_->texture_manager(); | 666 return group_->texture_manager(); |
665 } | 667 } |
666 | 668 |
667 MailboxManager* mailbox_manager() { | 669 MailboxManager* mailbox_manager() { |
668 return group_->mailbox_manager(); | 670 return group_->mailbox_manager(); |
669 } | 671 } |
670 | 672 |
673 ImageManager* image_manager() { | |
674 return group_->image_manager(); | |
675 } | |
676 | |
671 VertexArrayManager* vertex_array_manager() { | 677 VertexArrayManager* vertex_array_manager() { |
672 return vertex_array_manager_.get(); | 678 return vertex_array_manager_.get(); |
673 } | 679 } |
674 | 680 |
675 bool IsOffscreenBufferMultisampled() const { | 681 bool IsOffscreenBufferMultisampled() const { |
676 return offscreen_target_samples_ > 1; | 682 return offscreen_target_samples_ > 1; |
677 } | 683 } |
678 | 684 |
679 // Creates a TextureInfo for the given texture. | 685 // Creates a TextureInfo for the given texture. |
680 TextureManager::TextureInfo* CreateTextureInfo( | 686 TextureManager::TextureInfo* CreateTextureInfo( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 void DoTexStorage2DEXT( | 798 void DoTexStorage2DEXT( |
793 GLenum target, | 799 GLenum target, |
794 GLint levels, | 800 GLint levels, |
795 GLenum internal_format, | 801 GLenum internal_format, |
796 GLsizei width, | 802 GLsizei width, |
797 GLsizei height); | 803 GLsizei height); |
798 | 804 |
799 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 805 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
800 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); | 806 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
801 | 807 |
808 void DoBindTexImage2DCHROMIUM( | |
809 GLenum target, | |
810 GLint image_id); | |
811 void DoReleaseTexImage2DCHROMIUM( | |
812 GLenum target, | |
813 GLint image_id); | |
814 | |
802 // Creates a ProgramInfo for the given program. | 815 // Creates a ProgramInfo for the given program. |
803 ProgramManager::ProgramInfo* CreateProgramInfo( | 816 ProgramManager::ProgramInfo* CreateProgramInfo( |
804 GLuint client_id, GLuint service_id) { | 817 GLuint client_id, GLuint service_id) { |
805 return program_manager()->CreateProgramInfo(client_id, service_id); | 818 return program_manager()->CreateProgramInfo(client_id, service_id); |
806 } | 819 } |
807 | 820 |
808 // Gets the program info for the given program. Returns NULL if none exists. | 821 // Gets the program info for the given program. Returns NULL if none exists. |
809 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { | 822 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { |
810 return program_manager()->GetProgramInfo(client_id); | 823 return program_manager()->GetProgramInfo(client_id); |
811 } | 824 } |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1312 case GL_TEXTURE_RECTANGLE_ARB: | 1325 case GL_TEXTURE_RECTANGLE_ARB: |
1313 info = unit.bound_texture_rectangle_arb; | 1326 info = unit.bound_texture_rectangle_arb; |
1314 break; | 1327 break; |
1315 default: | 1328 default: |
1316 NOTREACHED(); | 1329 NOTREACHED(); |
1317 return NULL; | 1330 return NULL; |
1318 } | 1331 } |
1319 return info; | 1332 return info; |
1320 } | 1333 } |
1321 | 1334 |
1335 TextureManager::TextureInfo* GetTextureInfoForTargetUnlessDefault( | |
1336 GLenum target) { | |
1337 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | |
1338 if (!info) | |
1339 return NULL; | |
1340 if (info == texture_manager()->GetDefaultTextureInfo(target)) | |
1341 return NULL; | |
1342 return info; | |
1343 } | |
1344 | |
1322 GLenum GetBindTargetForSamplerType(GLenum type) { | 1345 GLenum GetBindTargetForSamplerType(GLenum type) { |
1323 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | 1346 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
1324 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); | 1347 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); |
1325 switch (type) { | 1348 switch (type) { |
1326 case GL_SAMPLER_2D: | 1349 case GL_SAMPLER_2D: |
1327 return GL_TEXTURE_2D; | 1350 return GL_TEXTURE_2D; |
1328 case GL_SAMPLER_CUBE: | 1351 case GL_SAMPLER_CUBE: |
1329 return GL_TEXTURE_CUBE_MAP; | 1352 return GL_TEXTURE_CUBE_MAP; |
1330 case GL_SAMPLER_EXTERNAL_OES: | 1353 case GL_SAMPLER_EXTERNAL_OES: |
1331 return GL_TEXTURE_EXTERNAL_OES; | 1354 return GL_TEXTURE_EXTERNAL_OES; |
(...skipping 7685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9017 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we | 9040 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we |
9018 // could delete a lot of code. For now, perform strict validation so we | 9041 // could delete a lot of code. For now, perform strict validation so we |
9019 // know what's going on. | 9042 // know what's going on. |
9020 SetGLError( | 9043 SetGLError( |
9021 GL_INVALID_OPERATION, | 9044 GL_INVALID_OPERATION, |
9022 "glTexImageIOSurface2DCHROMIUM", | 9045 "glTexImageIOSurface2DCHROMIUM", |
9023 "requires TEXTURE_RECTANGLE_ARB target"); | 9046 "requires TEXTURE_RECTANGLE_ARB target"); |
9024 return; | 9047 return; |
9025 } | 9048 } |
9026 | 9049 |
9027 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 9050 // Default target might be conceptually valid, but disallow it to avoid |
9051 // accidents. | |
9052 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( | |
9053 target); | |
9028 if (!info) { | 9054 if (!info) { |
9029 SetGLError(GL_INVALID_OPERATION, | 9055 SetGLError(GL_INVALID_OPERATION, |
9030 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound"); | 9056 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound"); |
9031 return; | 9057 return; |
9032 } | 9058 } |
9033 if (info == texture_manager()->GetDefaultTextureInfo(target)) { | |
9034 // Maybe this is conceptually valid, but disallow it to avoid accidents. | |
9035 SetGLError(GL_INVALID_OPERATION, | |
9036 "glTexImageIOSurface2DCHROMIUM", "can't bind default texture"); | |
9037 return; | |
9038 } | |
9039 | 9059 |
9040 // Look up the new IOSurface. Note that because of asynchrony | 9060 // Look up the new IOSurface. Note that because of asynchrony |
9041 // between processes this might fail; during live resizing the | 9061 // between processes this might fail; during live resizing the |
9042 // plugin process might allocate and release an IOSurface before | 9062 // plugin process might allocate and release an IOSurface before |
9043 // this process gets a chance to look it up. Hold on to any old | 9063 // this process gets a chance to look it up. Hold on to any old |
9044 // IOSurface in this case. | 9064 // IOSurface in this case. |
9045 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id); | 9065 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id); |
9046 if (!surface) { | 9066 if (!surface) { |
9047 SetGLError( | 9067 SetGLError( |
9048 GL_INVALID_OPERATION, | 9068 GL_INVALID_OPERATION, |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9426 marker = ""; | 9446 marker = ""; |
9427 } | 9447 } |
9428 debug_marker_manager_.PushGroup( | 9448 debug_marker_manager_.PushGroup( |
9429 length ? std::string(marker, length) : std::string(marker)); | 9449 length ? std::string(marker, length) : std::string(marker)); |
9430 } | 9450 } |
9431 | 9451 |
9432 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { | 9452 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { |
9433 debug_marker_manager_.PopGroup(); | 9453 debug_marker_manager_.PopGroup(); |
9434 } | 9454 } |
9435 | 9455 |
9456 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( | |
9457 GLenum target, GLint image_id) { | |
9458 if (target != GL_TEXTURE_2D) { | |
9459 // This might be supported in the future. | |
9460 SetGLError( | |
9461 GL_INVALID_OPERATION, | |
9462 "glBindTexImage2DCHROMIUM", "requires TEXTURE_2D target"); | |
9463 return; | |
9464 } | |
9465 | |
9466 // Default target might be conceptually valid, but disallow it to avoid | |
9467 // accidents. | |
9468 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( | |
9469 target); | |
9470 if (!info) { | |
9471 SetGLError(GL_INVALID_OPERATION, | |
9472 "glBindTexImage2DCHROMIUM", "no texture bound"); | |
9473 return; | |
9474 } | |
9475 | |
9476 scoped_refptr<gfx::GLImage> gl_image = | |
9477 image_manager()->LookupImage(image_id); | |
9478 if (!gl_image) { | |
9479 SetGLError(GL_INVALID_OPERATION, | |
9480 "glBindTexImage2DCHROMIUM", | |
9481 "no image found with the given ID"); | |
9482 return; | |
9483 } | |
9484 | |
9485 if (!gl_image->BindTexImage()) { | |
9486 SetGLError(GL_INVALID_OPERATION, | |
9487 "glBindTexImage2DCHROMIUM", | |
9488 "fail to bind image with the given ID"); | |
9489 return; | |
9490 } | |
9491 | |
9492 gfx::Size size = gl_image->GetSize(); | |
9493 texture_manager()->SetLevelInfo( | |
9494 info, target, 0, GL_RGBA, size.width(), size.height(), 1, 0, | |
9495 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true); | |
piman
2012/10/12 22:05:11
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV ?
Technically
reveman
2012/10/13 05:25:53
I don't think it has an effect but I changed to GL
| |
9496 texture_manager()->SetLevelImage(info, target, 0, gl_image); | |
9497 } | |
9498 | |
9499 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( | |
9500 GLenum target, GLint image_id) { | |
9501 if (target != GL_TEXTURE_2D) { | |
9502 // This might be supported in the future. | |
9503 SetGLError( | |
9504 GL_INVALID_OPERATION, | |
9505 "glReleaseTexImage2DCHROMIUM", "requires TEXTURE_2D target"); | |
9506 return; | |
9507 } | |
9508 | |
9509 // Default target might be conceptually valid, but disallow it to avoid | |
9510 // accidents. | |
9511 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( | |
9512 target); | |
9513 if (!info) { | |
9514 SetGLError(GL_INVALID_OPERATION, | |
9515 "glReleaseTexImage2DCHROMIUM", "no texture bound"); | |
9516 return; | |
9517 } | |
9518 | |
9519 scoped_refptr<gfx::GLImage> gl_image = | |
9520 image_manager()->LookupImage(image_id); | |
9521 if (!gl_image) { | |
9522 SetGLError(GL_INVALID_OPERATION, | |
9523 "glReleaseTexImage2DCHROMIUM", | |
9524 "no image found with the given ID"); | |
9525 return; | |
9526 } | |
9527 | |
9528 // Do nothing when image is not currently bound. | |
9529 if (info->GetLevelImage(target, 0) != gl_image) | |
9530 return; | |
9531 | |
9532 gl_image->ReleaseTexImage(); | |
9533 | |
9534 texture_manager()->SetLevelInfo( | |
9535 info, target, 0, GL_RGBA, 0, 0, 1, 0, | |
9536 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, false); | |
9537 } | |
9436 | 9538 |
9437 // Include the auto-generated part of this file. We split this because it means | 9539 // Include the auto-generated part of this file. We split this because it means |
9438 // we can easily edit the non-auto generated parts right here in this file | 9540 // we can easily edit the non-auto generated parts right here in this file |
9439 // instead of having to edit some template or the code generator. | 9541 // instead of having to edit some template or the code generator. |
9440 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9542 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9441 | 9543 |
9442 } // namespace gles2 | 9544 } // namespace gles2 |
9443 } // namespace gpu | 9545 } // namespace gpu |
OLD | NEW |