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> |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <cmath> | 13 #include <cmath> |
14 #include <list> | 14 #include <list> |
15 #include <map> | 15 #include <map> |
16 #include <memory> | 16 #include <memory> |
17 #include <queue> | 17 #include <queue> |
18 | 18 |
19 #include "base/callback.h" | 19 #include "base/callback.h" |
20 #include "base/callback_helpers.h" | 20 #include "base/callback_helpers.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/macros.h" |
22 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
23 #include "base/metrics/histogram_macros.h" | 24 #include "base/metrics/histogram_macros.h" |
24 #include "base/numerics/safe_math.h" | 25 #include "base/numerics/safe_math.h" |
25 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
26 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
27 #include "base/trace_event/trace_event.h" | 28 #include "base/trace_event/trace_event.h" |
28 #include "base/trace_event/trace_event_synthetic_delay.h" | 29 #include "base/trace_event/trace_event_synthetic_delay.h" |
29 #include "build/build_config.h" | 30 #include "build/build_config.h" |
30 #include "gpu/command_buffer/common/debug_marker_manager.h" | 31 #include "gpu/command_buffer/common/debug_marker_manager.h" |
31 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 32 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 | 1711 |
1711 // Wrapper for glOverlayPromotionHintCHROMIUIM | 1712 // Wrapper for glOverlayPromotionHintCHROMIUIM |
1712 void DoOverlayPromotionHintCHROMIUM(GLuint client_id, | 1713 void DoOverlayPromotionHintCHROMIUM(GLuint client_id, |
1713 GLboolean promotion_hint, | 1714 GLboolean promotion_hint, |
1714 GLint display_x, | 1715 GLint display_x, |
1715 GLint display_y); | 1716 GLint display_y); |
1716 | 1717 |
1717 // Wrapper for glSetDrawRectangleCHROMIUM | 1718 // Wrapper for glSetDrawRectangleCHROMIUM |
1718 void DoSetDrawRectangleCHROMIUM(GLint x, GLint y, GLint width, GLint height); | 1719 void DoSetDrawRectangleCHROMIUM(GLint x, GLint y, GLint width, GLint height); |
1719 | 1720 |
| 1721 void DoSetDCLayerTextureCHROMIUM(GLuint index, GLuint texture_id); |
1720 void DoSetEnableDCLayersCHROMIUM(GLboolean enable); | 1722 void DoSetEnableDCLayersCHROMIUM(GLboolean enable); |
1721 | 1723 |
1722 // Wrapper for glReadBuffer | 1724 // Wrapper for glReadBuffer |
1723 void DoReadBuffer(GLenum src); | 1725 void DoReadBuffer(GLenum src); |
1724 | 1726 |
1725 // Wrapper for glRenderbufferStorage. | 1727 // Wrapper for glRenderbufferStorage. |
1726 void DoRenderbufferStorage( | 1728 void DoRenderbufferStorage( |
1727 GLenum target, GLenum internalformat, GLsizei width, GLsizei height); | 1729 GLenum target, GLenum internalformat, GLsizei width, GLsizei height); |
1728 | 1730 |
1729 // Handler for glRenderbufferStorageMultisampleCHROMIUM. | 1731 // Handler for glRenderbufferStorageMultisampleCHROMIUM. |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 struct DCLayerSharedState { | 2491 struct DCLayerSharedState { |
2490 float opacity; | 2492 float opacity; |
2491 bool is_clipped; | 2493 bool is_clipped; |
2492 gfx::Rect clip_rect; | 2494 gfx::Rect clip_rect; |
2493 int z_order; | 2495 int z_order; |
2494 gfx::Transform transform; | 2496 gfx::Transform transform; |
2495 }; | 2497 }; |
2496 | 2498 |
2497 std::unique_ptr<DCLayerSharedState> dc_layer_shared_state_; | 2499 std::unique_ptr<DCLayerSharedState> dc_layer_shared_state_; |
2498 | 2500 |
| 2501 // Allow up to 4 planes - Y, U, V, A. Some may be missing, depending on the |
| 2502 // texture format. |
| 2503 uint32_t dc_layer_textures_[4] = {}; |
| 2504 |
2499 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 2505 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
2500 }; | 2506 }; |
2501 | 2507 |
2502 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { | 2508 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { |
2503 #define GLES2_CMD_OP(name) \ | 2509 #define GLES2_CMD_OP(name) \ |
2504 { \ | 2510 { \ |
2505 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ | 2511 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ |
2506 cmds::name::cmd_flags, \ | 2512 cmds::name::cmd_flags, \ |
2507 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ | 2513 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ |
2508 } \ | 2514 } \ |
(...skipping 6273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8782 return; | 8788 return; |
8783 } | 8789 } |
8784 gfx::Rect rect(x, y, width, height); | 8790 gfx::Rect rect(x, y, width, height); |
8785 if (!surface_->SetDrawRectangle(rect)) { | 8791 if (!surface_->SetDrawRectangle(rect)) { |
8786 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSetDrawRectangleCHROMIUM", | 8792 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSetDrawRectangleCHROMIUM", |
8787 "failed on surface"); | 8793 "failed on surface"); |
8788 } | 8794 } |
8789 OnFboChanged(); | 8795 OnFboChanged(); |
8790 } | 8796 } |
8791 | 8797 |
| 8798 void GLES2DecoderImpl::DoSetDCLayerTextureCHROMIUM(GLuint index, |
| 8799 GLuint texture_id) { |
| 8800 if (index >= arraysize(dc_layer_textures_)) { |
| 8801 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSetDCLayerTextureCHROMIUM", |
| 8802 "texture index too large"); |
| 8803 return; |
| 8804 } |
| 8805 dc_layer_textures_[index] = texture_id; |
| 8806 } |
| 8807 |
8792 void GLES2DecoderImpl::DoSetEnableDCLayersCHROMIUM(GLboolean enable) { | 8808 void GLES2DecoderImpl::DoSetEnableDCLayersCHROMIUM(GLboolean enable) { |
8793 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); | 8809 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); |
8794 if (framebuffer) { | 8810 if (framebuffer) { |
8795 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSetEnableDCLayersCHROMIUM", | 8811 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSetEnableDCLayersCHROMIUM", |
8796 "framebuffer must not be bound"); | 8812 "framebuffer must not be bound"); |
8797 return; | 8813 return; |
8798 } | 8814 } |
8799 if (!supports_dc_layers_) { | 8815 if (!supports_dc_layers_) { |
8800 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSetEnableDCLayersCHROMIUM", | 8816 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSetEnableDCLayersCHROMIUM", |
8801 "surface doesn't support SetDrawRectangle"); | 8817 "surface doesn't support SetDrawRectangle"); |
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12103 return error::kNoError; | 12119 return error::kNoError; |
12104 } | 12120 } |
12105 | 12121 |
12106 if (!dc_layer_shared_state_) { | 12122 if (!dc_layer_shared_state_) { |
12107 LOCAL_SET_GL_ERROR( | 12123 LOCAL_SET_GL_ERROR( |
12108 GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", | 12124 GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", |
12109 "glScheduleDCLayerSharedStateCHROMIUM has not been called"); | 12125 "glScheduleDCLayerSharedStateCHROMIUM has not been called"); |
12110 return error::kNoError; | 12126 return error::kNoError; |
12111 } | 12127 } |
12112 | 12128 |
12113 gl::GLImage* image = nullptr; | 12129 std::vector<scoped_refptr<gl::GLImage>> images; |
12114 GLuint contents_texture_id = c.contents_texture_id; | 12130 |
12115 if (contents_texture_id) { | 12131 for (int contents_texture_id : dc_layer_textures_) { |
12116 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); | 12132 scoped_refptr<gl::GLImage> image; |
12117 if (!ref) { | 12133 if (contents_texture_id) { |
12118 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", | 12134 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); |
12119 "unknown texture"); | 12135 if (!ref) { |
12120 return error::kNoError; | 12136 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", |
| 12137 "unknown texture"); |
| 12138 return error::kNoError; |
| 12139 } |
| 12140 Texture::ImageState image_state; |
| 12141 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, |
| 12142 &image_state); |
| 12143 if (!image) { |
| 12144 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", |
| 12145 "unsupported texture format"); |
| 12146 return error::kNoError; |
| 12147 } |
12121 } | 12148 } |
12122 Texture::ImageState image_state; | 12149 images.push_back(image); |
12123 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, | |
12124 &image_state); | |
12125 if (!image) { | |
12126 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", | |
12127 "unsupported texture format"); | |
12128 return error::kNoError; | |
12129 } | |
12130 } | 12150 } |
12131 | 12151 |
| 12152 memset(dc_layer_textures_, 0, sizeof dc_layer_textures_); |
| 12153 |
12132 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, | 12154 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, |
12133 8 * sizeof(GLfloat)); | 12155 8 * sizeof(GLfloat)); |
12134 if (!mem) { | 12156 if (!mem) { |
12135 return error::kOutOfBounds; | 12157 return error::kOutOfBounds; |
12136 } | 12158 } |
12137 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]); | 12159 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]); |
12138 gfx::RectF bounds_rect(mem[4], mem[5], mem[6], mem[7]); | 12160 gfx::RectF bounds_rect(mem[4], mem[5], mem[6], mem[7]); |
12139 | 12161 |
12140 ui::DCRendererLayerParams params = ui::DCRendererLayerParams( | 12162 ui::DCRendererLayerParams params = ui::DCRendererLayerParams( |
12141 dc_layer_shared_state_->is_clipped, dc_layer_shared_state_->clip_rect, | 12163 dc_layer_shared_state_->is_clipped, dc_layer_shared_state_->clip_rect, |
12142 dc_layer_shared_state_->z_order, dc_layer_shared_state_->transform, image, | 12164 dc_layer_shared_state_->z_order, dc_layer_shared_state_->transform, |
12143 contents_rect, gfx::ToEnclosingRect(bounds_rect), c.background_color, | 12165 images, contents_rect, gfx::ToEnclosingRect(bounds_rect), |
12144 c.edge_aa_mask, dc_layer_shared_state_->opacity, filter); | 12166 c.background_color, c.edge_aa_mask, dc_layer_shared_state_->opacity, |
| 12167 filter); |
12145 if (!surface_->ScheduleDCLayer(params)) { | 12168 if (!surface_->ScheduleDCLayer(params)) { |
12146 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", | 12169 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", |
12147 "failed to schedule DCLayer"); | 12170 "failed to schedule DCLayer"); |
12148 } | 12171 } |
12149 return error::kNoError; | 12172 return error::kNoError; |
12150 } | 12173 } |
12151 | 12174 |
12152 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( | 12175 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( |
12153 GLsizei count, | 12176 GLsizei count, |
12154 const volatile GLuint* textures) { | 12177 const volatile GLuint* textures) { |
(...skipping 7477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19632 } | 19655 } |
19633 | 19656 |
19634 // Include the auto-generated part of this file. We split this because it means | 19657 // Include the auto-generated part of this file. We split this because it means |
19635 // we can easily edit the non-auto generated parts right here in this file | 19658 // we can easily edit the non-auto generated parts right here in this file |
19636 // instead of having to edit some template or the code generator. | 19659 // instead of having to edit some template or the code generator. |
19637 #include "base/macros.h" | 19660 #include "base/macros.h" |
19638 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19661 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
19639 | 19662 |
19640 } // namespace gles2 | 19663 } // namespace gles2 |
19641 } // namespace gpu | 19664 } // namespace gpu |
OLD | NEW |