| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 // the current generation when our context becomes current, then we'll rebind | 2279 // the current generation when our context becomes current, then we'll rebind |
| 2280 // all the textures to stay up to date with Texture::service_id() changes. | 2280 // all the textures to stay up to date with Texture::service_id() changes. |
| 2281 uint32_t texture_manager_service_id_generation_; | 2281 uint32_t texture_manager_service_id_generation_; |
| 2282 | 2282 |
| 2283 bool force_shader_name_hashing_for_test; | 2283 bool force_shader_name_hashing_for_test; |
| 2284 | 2284 |
| 2285 GLfloat line_width_range_[2]; | 2285 GLfloat line_width_range_[2]; |
| 2286 | 2286 |
| 2287 SamplerState default_sampler_state_; | 2287 SamplerState default_sampler_state_; |
| 2288 | 2288 |
| 2289 struct CALayerSharedState{ |
| 2290 float opacity; |
| 2291 bool is_clipped; |
| 2292 gfx::Rect clip_rect; |
| 2293 int sorting_context_id; |
| 2294 gfx::Transform transform; |
| 2295 }; |
| 2296 |
| 2297 std::unique_ptr<CALayerSharedState> ca_layer_shared_state_; |
| 2298 |
| 2289 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 2299 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
| 2290 }; | 2300 }; |
| 2291 | 2301 |
| 2292 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { | 2302 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { |
| 2293 #define GLES2_CMD_OP(name) \ | 2303 #define GLES2_CMD_OP(name) \ |
| 2294 { \ | 2304 { \ |
| 2295 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ | 2305 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ |
| 2296 cmds::name::cmd_flags, \ | 2306 cmds::name::cmd_flags, \ |
| 2297 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ | 2307 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ |
| 2298 } \ | 2308 } \ |
| (...skipping 8427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10726 image, | 10736 image, |
| 10727 gfx::Rect(c.bounds_x, c.bounds_y, c.bounds_width, c.bounds_height), | 10737 gfx::Rect(c.bounds_x, c.bounds_y, c.bounds_width, c.bounds_height), |
| 10728 gfx::RectF(c.uv_x, c.uv_y, c.uv_width, c.uv_height))) { | 10738 gfx::RectF(c.uv_x, c.uv_y, c.uv_width, c.uv_height))) { |
| 10729 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 10739 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| 10730 "glScheduleOverlayPlaneCHROMIUM", | 10740 "glScheduleOverlayPlaneCHROMIUM", |
| 10731 "failed to schedule overlay"); | 10741 "failed to schedule overlay"); |
| 10732 } | 10742 } |
| 10733 return error::kNoError; | 10743 return error::kNoError; |
| 10734 } | 10744 } |
| 10735 | 10745 |
| 10746 error::Error GLES2DecoderImpl::HandleScheduleCALayerSharedStateCHROMIUM( |
| 10747 uint32_t immediate_data_size, |
| 10748 const void* cmd_data) { |
| 10749 const gles2::cmds::ScheduleCALayerSharedStateCHROMIUM& c = |
| 10750 *static_cast<const gles2::cmds::ScheduleCALayerSharedStateCHROMIUM*>( |
| 10751 cmd_data); |
| 10752 |
| 10753 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, |
| 10754 20 * sizeof(GLfloat)); |
| 10755 if (!mem) { |
| 10756 return error::kOutOfBounds; |
| 10757 } |
| 10758 gfx::RectF clip_rect(mem[0], mem[1], mem[2], mem[3]); |
| 10759 gfx::Transform transform(mem[4], mem[8], mem[12], mem[16], |
| 10760 mem[5], mem[9], mem[13], mem[17], |
| 10761 mem[6], mem[10], mem[14], mem[18], |
| 10762 mem[7], mem[11], mem[15], mem[19]); |
| 10763 ca_layer_shared_state_.reset(new CALayerSharedState); |
| 10764 ca_layer_shared_state_->opacity = c.opacity; |
| 10765 ca_layer_shared_state_->is_clipped = c.is_clipped ? true : false; |
| 10766 ca_layer_shared_state_->clip_rect = gfx::ToEnclosingRect(clip_rect); |
| 10767 ca_layer_shared_state_->sorting_context_id = c.sorting_context_id; |
| 10768 ca_layer_shared_state_->transform = transform; |
| 10769 return error::kNoError; |
| 10770 } |
| 10771 |
| 10772 error::Error GLES2DecoderImpl::HandleUnscheduleCALayerSharedStateCHROMIUM( |
| 10773 uint32_t immediate_data_size, |
| 10774 const void* cmd_data) { |
| 10775 ca_layer_shared_state_.reset(); |
| 10776 return error::kNoError; |
| 10777 } |
| 10778 |
| 10736 error::Error GLES2DecoderImpl::HandleScheduleCALayerCHROMIUM( | 10779 error::Error GLES2DecoderImpl::HandleScheduleCALayerCHROMIUM( |
| 10737 uint32_t immediate_data_size, | 10780 uint32_t immediate_data_size, |
| 10738 const void* cmd_data) { | 10781 const void* cmd_data) { |
| 10739 const gles2::cmds::ScheduleCALayerCHROMIUM& c = | 10782 const gles2::cmds::ScheduleCALayerCHROMIUM& c = |
| 10740 *static_cast<const gles2::cmds::ScheduleCALayerCHROMIUM*>(cmd_data); | 10783 *static_cast<const gles2::cmds::ScheduleCALayerCHROMIUM*>(cmd_data); |
| 10741 GLuint filter = c.filter; | 10784 GLuint filter = c.filter; |
| 10742 if (filter != GL_NEAREST && filter != GL_LINEAR) { | 10785 if (filter != GL_NEAREST && filter != GL_LINEAR) { |
| 10743 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 10786 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10744 "invalid filter"); | 10787 "invalid filter"); |
| 10745 return error::kNoError; | 10788 return error::kNoError; |
| 10746 } | 10789 } |
| 10747 | 10790 |
| 10791 if (!ca_layer_shared_state_) { |
| 10792 LOCAL_SET_GL_ERROR( |
| 10793 GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10794 "glScheduleCALayerSharedStateCHROMIUM has not been called"); |
| 10795 return error::kNoError; |
| 10796 } |
| 10797 |
| 10748 gl::GLImage* image = nullptr; | 10798 gl::GLImage* image = nullptr; |
| 10749 GLuint contents_texture_id = c.contents_texture_id; | 10799 GLuint contents_texture_id = c.contents_texture_id; |
| 10750 if (contents_texture_id) { | 10800 if (contents_texture_id) { |
| 10751 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); | 10801 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); |
| 10752 if (!ref) { | 10802 if (!ref) { |
| 10753 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 10803 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10754 "unknown texture"); | 10804 "unknown texture"); |
| 10755 return error::kNoError; | 10805 return error::kNoError; |
| 10756 } | 10806 } |
| 10757 Texture::ImageState image_state; | 10807 Texture::ImageState image_state; |
| 10758 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, | 10808 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, |
| 10759 &image_state); | 10809 &image_state); |
| 10760 if (!image) { | 10810 if (!image) { |
| 10761 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 10811 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10762 "unsupported texture format"); | 10812 "unsupported texture format"); |
| 10763 return error::kNoError; | 10813 return error::kNoError; |
| 10764 } | 10814 } |
| 10765 } | 10815 } |
| 10766 | 10816 |
| 10767 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, | 10817 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, |
| 10768 28 * sizeof(GLfloat)); | 10818 8 * sizeof(GLfloat)); |
| 10769 if (!mem) { | 10819 if (!mem) { |
| 10770 return error::kOutOfBounds; | 10820 return error::kOutOfBounds; |
| 10771 } | 10821 } |
| 10772 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]); | 10822 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]); |
| 10773 gfx::RectF bounds_rect(mem[4], mem[5], mem[6], mem[7]); | 10823 gfx::RectF bounds_rect(mem[4], mem[5], mem[6], mem[7]); |
| 10774 gfx::RectF clip_rect(mem[8], mem[9], mem[10], mem[11]); | |
| 10775 gfx::Transform transform(mem[12], mem[16], mem[20], mem[24], | |
| 10776 mem[13], mem[17], mem[21], mem[25], | |
| 10777 mem[14], mem[18], mem[22], mem[26], | |
| 10778 mem[15], mem[19], mem[23], mem[27]); | |
| 10779 | 10824 |
| 10780 ui::CARendererLayerParams params = ui::CARendererLayerParams( | 10825 ui::CARendererLayerParams params = ui::CARendererLayerParams( |
| 10781 c.is_clipped ? true : false, gfx::ToEnclosingRect(clip_rect), | 10826 ca_layer_shared_state_->is_clipped, ca_layer_shared_state_->clip_rect, |
| 10782 c.sorting_context_id, transform, image, contents_rect, | 10827 ca_layer_shared_state_->sorting_context_id, |
| 10828 ca_layer_shared_state_->transform, image, contents_rect, |
| 10783 gfx::ToEnclosingRect(bounds_rect), c.background_color, c.edge_aa_mask, | 10829 gfx::ToEnclosingRect(bounds_rect), c.background_color, c.edge_aa_mask, |
| 10784 c.opacity, filter); | 10830 ca_layer_shared_state_->opacity, filter); |
| 10785 if (!surface_->ScheduleCALayer(params)) { | 10831 if (!surface_->ScheduleCALayer(params)) { |
| 10786 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleCALayerCHROMIUM", | 10832 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleCALayerCHROMIUM", |
| 10787 "failed to schedule CALayer"); | 10833 "failed to schedule CALayer"); |
| 10788 } | 10834 } |
| 10789 return error::kNoError; | 10835 return error::kNoError; |
| 10790 } | 10836 } |
| 10791 | 10837 |
| 10792 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( | 10838 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( |
| 10793 GLsizei count, | 10839 GLsizei count, |
| 10794 const GLuint* textures) { | 10840 const GLuint* textures) { |
| (...skipping 6613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17408 } | 17454 } |
| 17409 | 17455 |
| 17410 // Include the auto-generated part of this file. We split this because it means | 17456 // Include the auto-generated part of this file. We split this because it means |
| 17411 // we can easily edit the non-auto generated parts right here in this file | 17457 // we can easily edit the non-auto generated parts right here in this file |
| 17412 // instead of having to edit some template or the code generator. | 17458 // instead of having to edit some template or the code generator. |
| 17413 #include "base/macros.h" | 17459 #include "base/macros.h" |
| 17414 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17460 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17415 | 17461 |
| 17416 } // namespace gles2 | 17462 } // namespace gles2 |
| 17417 } // namespace gpu | 17463 } // namespace gpu |
| OLD | NEW |