Chromium Code Reviews| 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 | |
| 10736 error::Error GLES2DecoderImpl::HandleScheduleCALayerCHROMIUM( | 10772 error::Error GLES2DecoderImpl::HandleScheduleCALayerCHROMIUM( |
| 10737 uint32_t immediate_data_size, | 10773 uint32_t immediate_data_size, |
| 10738 const void* cmd_data) { | 10774 const void* cmd_data) { |
| 10739 const gles2::cmds::ScheduleCALayerCHROMIUM& c = | 10775 const gles2::cmds::ScheduleCALayerCHROMIUM& c = |
| 10740 *static_cast<const gles2::cmds::ScheduleCALayerCHROMIUM*>(cmd_data); | 10776 *static_cast<const gles2::cmds::ScheduleCALayerCHROMIUM*>(cmd_data); |
| 10741 GLuint filter = c.filter; | 10777 GLuint filter = c.filter; |
| 10742 if (filter != GL_NEAREST && filter != GL_LINEAR) { | 10778 if (filter != GL_NEAREST && filter != GL_LINEAR) { |
| 10743 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 10779 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10744 "invalid filter"); | 10780 "invalid filter"); |
| 10745 return error::kNoError; | 10781 return error::kNoError; |
| 10746 } | 10782 } |
| 10747 | 10783 |
| 10784 if (!ca_layer_shared_state_) { | |
| 10785 LOCAL_SET_GL_ERROR( | |
| 10786 GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | |
|
piman
2016/07/19 20:56:46
nit: commonly GL_INVALID_OPERATION is the error ra
erikchen
2016/07/19 21:40:21
Done.
| |
| 10787 "glScheduleCALayerSharedStateCHROMIUM has not been called"); | |
| 10788 return error::kNoError; | |
| 10789 } | |
| 10790 | |
| 10748 gl::GLImage* image = nullptr; | 10791 gl::GLImage* image = nullptr; |
| 10749 GLuint contents_texture_id = c.contents_texture_id; | 10792 GLuint contents_texture_id = c.contents_texture_id; |
| 10750 if (contents_texture_id) { | 10793 if (contents_texture_id) { |
| 10751 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); | 10794 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); |
| 10752 if (!ref) { | 10795 if (!ref) { |
| 10753 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 10796 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10754 "unknown texture"); | 10797 "unknown texture"); |
| 10755 return error::kNoError; | 10798 return error::kNoError; |
| 10756 } | 10799 } |
| 10757 Texture::ImageState image_state; | 10800 Texture::ImageState image_state; |
| 10758 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, | 10801 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, |
| 10759 &image_state); | 10802 &image_state); |
| 10760 if (!image) { | 10803 if (!image) { |
| 10761 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 10804 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10762 "unsupported texture format"); | 10805 "unsupported texture format"); |
| 10763 return error::kNoError; | 10806 return error::kNoError; |
| 10764 } | 10807 } |
| 10765 } | 10808 } |
| 10766 | 10809 |
| 10767 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, | 10810 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, |
| 10768 28 * sizeof(GLfloat)); | 10811 8 * sizeof(GLfloat)); |
| 10769 if (!mem) { | 10812 if (!mem) { |
| 10770 return error::kOutOfBounds; | 10813 return error::kOutOfBounds; |
| 10771 } | 10814 } |
| 10772 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]); | 10815 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]); | 10816 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 | 10817 |
| 10780 ui::CARendererLayerParams params = ui::CARendererLayerParams( | 10818 ui::CARendererLayerParams params = ui::CARendererLayerParams( |
| 10781 c.is_clipped ? true : false, gfx::ToEnclosingRect(clip_rect), | 10819 ca_layer_shared_state_->is_clipped, ca_layer_shared_state_->clip_rect, |
| 10782 c.sorting_context_id, transform, image, contents_rect, | 10820 ca_layer_shared_state_->sorting_context_id, |
| 10821 ca_layer_shared_state_->transform, image, contents_rect, | |
| 10783 gfx::ToEnclosingRect(bounds_rect), c.background_color, c.edge_aa_mask, | 10822 gfx::ToEnclosingRect(bounds_rect), c.background_color, c.edge_aa_mask, |
| 10784 c.opacity, filter); | 10823 ca_layer_shared_state_->opacity, filter); |
| 10785 if (!surface_->ScheduleCALayer(params)) { | 10824 if (!surface_->ScheduleCALayer(params)) { |
| 10786 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleCALayerCHROMIUM", | 10825 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleCALayerCHROMIUM", |
| 10787 "failed to schedule CALayer"); | 10826 "failed to schedule CALayer"); |
| 10788 } | 10827 } |
| 10789 return error::kNoError; | 10828 return error::kNoError; |
| 10790 } | 10829 } |
| 10791 | 10830 |
| 10792 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( | 10831 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( |
| 10793 GLsizei count, | 10832 GLsizei count, |
| 10794 const GLuint* textures) { | 10833 const GLuint* textures) { |
| (...skipping 2909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13704 | 13743 |
| 13705 bool is_tracing; | 13744 bool is_tracing; |
| 13706 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | 13745 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), |
| 13707 &is_tracing); | 13746 &is_tracing); |
| 13708 if (is_tracing) { | 13747 if (is_tracing) { |
| 13709 ScopedFrameBufferBinder binder(this, GetBackbufferServiceId()); | 13748 ScopedFrameBufferBinder binder(this, GetBackbufferServiceId()); |
| 13710 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( | 13749 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( |
| 13711 is_offscreen ? offscreen_size_ : surface_->GetSize()); | 13750 is_offscreen ? offscreen_size_ : surface_->GetSize()); |
| 13712 } | 13751 } |
| 13713 | 13752 |
| 13753 // The GL_CHROMIUM_schedule_ca_layer requires that SwapBuffers resets shared | |
| 13754 // state here. | |
| 13755 ca_layer_shared_state_.reset(); | |
|
piman
2016/07/19 20:56:46
nit: can you also add this to HandlePostSubBufferC
erikchen
2016/07/19 21:40:21
Done.
| |
| 13756 | |
| 13714 // If offscreen then don't actually SwapBuffers to the display. Just copy | 13757 // If offscreen then don't actually SwapBuffers to the display. Just copy |
| 13715 // the rendered frame to another frame buffer. | 13758 // the rendered frame to another frame buffer. |
| 13716 if (is_offscreen) { | 13759 if (is_offscreen) { |
| 13717 TRACE_EVENT2("gpu", "Offscreen", | 13760 TRACE_EVENT2("gpu", "Offscreen", |
| 13718 "width", offscreen_size_.width(), "height", offscreen_size_.height()); | 13761 "width", offscreen_size_.width(), "height", offscreen_size_.height()); |
| 13719 if (offscreen_size_ != offscreen_saved_color_texture_->size()) { | 13762 if (offscreen_size_ != offscreen_saved_color_texture_->size()) { |
| 13720 // Workaround for NVIDIA driver bug on OS X; crbug.com/89557, | 13763 // Workaround for NVIDIA driver bug on OS X; crbug.com/89557, |
| 13721 // crbug.com/94163. TODO(kbr): figure out reproduction so Apple will | 13764 // crbug.com/94163. TODO(kbr): figure out reproduction so Apple will |
| 13722 // fix this. | 13765 // fix this. |
| 13723 if (workarounds().needs_offscreen_buffer_workaround) { | 13766 if (workarounds().needs_offscreen_buffer_workaround) { |
| (...skipping 3684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17408 } | 17451 } |
| 17409 | 17452 |
| 17410 // Include the auto-generated part of this file. We split this because it means | 17453 // 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 | 17454 // 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. | 17455 // instead of having to edit some template or the code generator. |
| 17413 #include "base/macros.h" | 17456 #include "base/macros.h" |
| 17414 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17457 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17415 | 17458 |
| 17416 } // namespace gles2 | 17459 } // namespace gles2 |
| 17417 } // namespace gpu | 17460 } // namespace gpu |
| OLD | NEW |