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 12 matching lines...) Expand all Loading... | |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
24 #include "base/memory/weak_ptr.h" | 24 #include "base/memory/weak_ptr.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #define GLES2_GPU_SERVICE 1 | 26 #define GLES2_GPU_SERVICE 1 |
27 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 27 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
29 #include "gpu/command_buffer/common/id_allocator.h" | 29 #include "gpu/command_buffer/common/id_allocator.h" |
30 #include "gpu/command_buffer/service/buffer_manager.h" | 30 #include "gpu/command_buffer/service/buffer_manager.h" |
31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
32 #include "gpu/command_buffer/service/context_group.h" | 32 #include "gpu/command_buffer/service/context_group.h" |
33 #include "gpu/command_buffer/service/display.h" | |
33 #include "gpu/command_buffer/service/feature_info.h" | 34 #include "gpu/command_buffer/service/feature_info.h" |
34 #include "gpu/command_buffer/service/framebuffer_manager.h" | 35 #include "gpu/command_buffer/service/framebuffer_manager.h" |
35 #include "gpu/command_buffer/service/gl_utils.h" | 36 #include "gpu/command_buffer/service/gl_utils.h" |
36 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 37 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
37 #include "gpu/command_buffer/service/gpu_switches.h" | 38 #include "gpu/command_buffer/service/gpu_switches.h" |
38 #include "gpu/command_buffer/service/program_manager.h" | 39 #include "gpu/command_buffer/service/program_manager.h" |
39 #include "gpu/command_buffer/service/query_manager.h" | 40 #include "gpu/command_buffer/service/query_manager.h" |
40 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 41 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
41 #include "gpu/command_buffer/service/shader_manager.h" | 42 #include "gpu/command_buffer/service/shader_manager.h" |
42 #include "gpu/command_buffer/service/shader_translator.h" | 43 #include "gpu/command_buffer/service/shader_translator.h" |
43 #include "gpu/command_buffer/service/stream_texture.h" | 44 #include "gpu/command_buffer/service/stream_texture.h" |
44 #include "gpu/command_buffer/service/stream_texture_manager.h" | 45 #include "gpu/command_buffer/service/stream_texture_manager.h" |
46 #include "gpu/command_buffer/service/texture_definition.h" | |
45 #include "gpu/command_buffer/service/texture_manager.h" | 47 #include "gpu/command_buffer/service/texture_manager.h" |
46 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 48 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
47 #include "ui/gfx/gl/gl_context.h" | 49 #include "ui/gfx/gl/gl_context.h" |
48 #include "ui/gfx/gl/gl_implementation.h" | 50 #include "ui/gfx/gl/gl_implementation.h" |
49 #include "ui/gfx/gl/gl_surface.h" | 51 #include "ui/gfx/gl/gl_surface.h" |
50 #if defined(OS_MACOSX) | 52 #if defined(OS_MACOSX) |
51 #include "ui/gfx/surface/io_surface_support_mac.h" | 53 #include "ui/gfx/surface/io_surface_support_mac.h" |
52 #endif | 54 #endif |
53 | 55 |
54 #if !defined(GL_DEPTH24_STENCIL8) | 56 #if !defined(GL_DEPTH24_STENCIL8) |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 uint32* service_texture_id); | 502 uint32* service_texture_id); |
501 | 503 |
502 // Restores the current state to the user's settings. | 504 // Restores the current state to the user's settings. |
503 void RestoreCurrentFramebufferBindings(); | 505 void RestoreCurrentFramebufferBindings(); |
504 void RestoreCurrentRenderbufferBindings(); | 506 void RestoreCurrentRenderbufferBindings(); |
505 void RestoreCurrentTexture2DBindings(); | 507 void RestoreCurrentTexture2DBindings(); |
506 | 508 |
507 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. | 509 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. |
508 void ApplyDirtyState(); | 510 void ApplyDirtyState(); |
509 | 511 |
512 // Reapply the texture parameters to the given texture. | |
513 void BindAndApplyTextureParameters(TextureManager::TextureInfo* info); | |
514 | |
510 // These check the state of the currently bound framebuffer or the | 515 // These check the state of the currently bound framebuffer or the |
511 // backbuffer if no framebuffer is bound. | 516 // backbuffer if no framebuffer is bound. |
512 bool BoundFramebufferHasColorAttachmentWithAlpha(); | 517 bool BoundFramebufferHasColorAttachmentWithAlpha(); |
513 bool BoundFramebufferHasDepthAttachment(); | 518 bool BoundFramebufferHasDepthAttachment(); |
514 bool BoundFramebufferHasStencilAttachment(); | 519 bool BoundFramebufferHasStencilAttachment(); |
515 | 520 |
516 virtual error::ContextLostReason GetContextLostReason(); | 521 virtual error::ContextLostReason GetContextLostReason(); |
517 | 522 |
518 private: | 523 private: |
519 friend class ScopedGLErrorSuppressor; | 524 friend class ScopedGLErrorSuppressor; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 GLuint plane); | 732 GLuint plane); |
728 | 733 |
729 // Wrapper for TexStorage2DEXT. | 734 // Wrapper for TexStorage2DEXT. |
730 void DoTexStorage2DEXT( | 735 void DoTexStorage2DEXT( |
731 GLenum target, | 736 GLenum target, |
732 GLint levels, | 737 GLint levels, |
733 GLenum internal_format, | 738 GLenum internal_format, |
734 GLsizei width, | 739 GLsizei width, |
735 GLsizei height); | 740 GLsizei height); |
736 | 741 |
742 // Wrapper for SwapTexturesCHROMIUM. | |
Ken Russell (switch to Gerrit)
2012/04/23 20:12:00
Comment out of date? And below?
| |
743 void DoProduceTextureCHROMIUM(GLenum target, const GLint* key); | |
744 | |
745 // Wrapper for TexKeyCHROMIUM. | |
746 void DoConsumeTextureCHROMIUM(GLenum target, const GLint* key); | |
747 | |
737 // Creates a ProgramInfo for the given program. | 748 // Creates a ProgramInfo for the given program. |
738 ProgramManager::ProgramInfo* CreateProgramInfo( | 749 ProgramManager::ProgramInfo* CreateProgramInfo( |
739 GLuint client_id, GLuint service_id) { | 750 GLuint client_id, GLuint service_id) { |
740 return program_manager()->CreateProgramInfo(client_id, service_id); | 751 return program_manager()->CreateProgramInfo(client_id, service_id); |
741 } | 752 } |
742 | 753 |
743 // Gets the program info for the given program. Returns NULL if none exists. | 754 // Gets the program info for the given program. Returns NULL if none exists. |
744 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { | 755 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { |
745 return program_manager()->GetProgramInfo(client_id); | 756 return program_manager()->GetProgramInfo(client_id); |
746 } | 757 } |
(...skipping 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3197 glDepthMask(mask_depth_ && have_depth); | 3208 glDepthMask(mask_depth_ && have_depth); |
3198 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); | 3209 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); |
3199 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 3210 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
3200 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); | 3211 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); |
3201 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); | 3212 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); |
3202 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); | 3213 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); |
3203 state_dirty_ = false; | 3214 state_dirty_ = false; |
3204 } | 3215 } |
3205 } | 3216 } |
3206 | 3217 |
3218 void GLES2DecoderImpl::BindAndApplyTextureParameters( | |
3219 TextureManager::TextureInfo* info) { | |
3220 glBindTexture(info->target(), info->service_id()); | |
3221 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); | |
3222 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); | |
3223 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); | |
3224 glTexParameteri(info->target(), GL_TEXTURE_WRAP_T, info->wrap_t()); | |
3225 } | |
3226 | |
3207 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { | 3227 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { |
3208 return (offscreen_target_frame_buffer_.get()) ? | 3228 return (offscreen_target_frame_buffer_.get()) ? |
3209 offscreen_target_frame_buffer_->id() : | 3229 offscreen_target_frame_buffer_->id() : |
3210 surface_->GetBackingFrameBufferObject(); | 3230 surface_->GetBackingFrameBufferObject(); |
3211 } | 3231 } |
3212 | 3232 |
3213 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 3233 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
3214 FramebufferManager::FramebufferInfo* info = NULL; | 3234 FramebufferManager::FramebufferInfo* info = NULL; |
3215 GLuint service_id = 0; | 3235 GLuint service_id = 0; |
3216 if (client_id != 0) { | 3236 if (client_id != 0) { |
(...skipping 5082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8299 texture_manager()->SetLevelInfo( | 8319 texture_manager()->SetLevelInfo( |
8300 info, target, 0, format, level_width, level_height, 1, 0, format, | 8320 info, target, 0, format, level_width, level_height, 1, 0, format, |
8301 type, false); | 8321 type, false); |
8302 level_width = std::max(1, level_width >> 1); | 8322 level_width = std::max(1, level_width >> 1); |
8303 level_height = std::max(1, level_height >> 1); | 8323 level_height = std::max(1, level_height >> 1); |
8304 } | 8324 } |
8305 info->SetImmutable(true); | 8325 info->SetImmutable(true); |
8306 } | 8326 } |
8307 } | 8327 } |
8308 | 8328 |
8329 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, | |
8330 const GLint* mailbox) { | |
8331 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | |
8332 if (!info) { | |
8333 SetGLError(GL_INVALID_OPERATION, | |
8334 "glProduceTextureCHROMIUM: unknown texture for target"); | |
8335 return; | |
8336 } | |
8337 | |
8338 TextureDefinition* definition = texture_manager()->Save(info); | |
8339 if (!definition) { | |
8340 SetGLError(GL_INVALID_OPERATION, | |
8341 "glProduceTextureCHROMIUM: invalid texture"); | |
8342 return; | |
8343 } | |
8344 | |
8345 group_->display()->ProduceTexture( | |
8346 target, | |
8347 *reinterpret_cast<const MailboxName*>(mailbox), | |
8348 definition, | |
8349 texture_manager()); | |
8350 | |
8351 BindAndApplyTextureParameters(info); | |
8352 } | |
8353 | |
8354 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, | |
8355 const GLint* mailbox) { | |
8356 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | |
8357 if (!info) { | |
8358 SetGLError(GL_INVALID_OPERATION, | |
8359 "glConsumeTextureCHROMIUM: unknown texture for target"); | |
8360 return; | |
8361 } | |
8362 | |
8363 scoped_ptr<TextureDefinition> definition(group_->display()->ConsumeTexture( | |
8364 target, | |
8365 *reinterpret_cast<const MailboxName*>(mailbox))); | |
8366 if (!definition.get()) { | |
8367 SetGLError(GL_INVALID_OPERATION, | |
8368 "glConsumeTextureCHROMIUM: empty mailbox"); | |
8369 return; | |
8370 } | |
8371 | |
8372 if (!texture_manager()->Restore(info, definition.release())) { | |
8373 SetGLError(GL_INVALID_OPERATION, | |
8374 "glConsumeTextureCHROMIUM: invalid texture"); | |
8375 return; | |
8376 } | |
8377 | |
8378 BindAndApplyTextureParameters(info); | |
8379 } | |
8380 | |
8309 // Include the auto-generated part of this file. We split this because it means | 8381 // Include the auto-generated part of this file. We split this because it means |
8310 // we can easily edit the non-auto generated parts right here in this file | 8382 // we can easily edit the non-auto generated parts right here in this file |
8311 // instead of having to edit some template or the code generator. | 8383 // instead of having to edit some template or the code generator. |
8312 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8384 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
8313 | 8385 |
8314 } // namespace gles2 | 8386 } // namespace gles2 |
8315 } // namespace gpu | 8387 } // namespace gpu |
OLD | NEW |