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 12092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12103 return error::kNoError; | 12103 return error::kNoError; |
12104 } | 12104 } |
12105 | 12105 |
12106 if (!dc_layer_shared_state_) { | 12106 if (!dc_layer_shared_state_) { |
12107 LOCAL_SET_GL_ERROR( | 12107 LOCAL_SET_GL_ERROR( |
12108 GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", | 12108 GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", |
12109 "glScheduleDCLayerSharedStateCHROMIUM has not been called"); | 12109 "glScheduleDCLayerSharedStateCHROMIUM has not been called"); |
12110 return error::kNoError; | 12110 return error::kNoError; |
12111 } | 12111 } |
12112 | 12112 |
12113 gl::GLImage* image = nullptr; | 12113 GLsizei num_textures = c.num_textures; |
12114 GLuint contents_texture_id = c.contents_texture_id; | 12114 if (num_textures < 0 || num_textures > 4) { |
12115 if (contents_texture_id) { | 12115 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", |
12116 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); | 12116 "number of textures greater than maximum of 4"); |
12117 if (!ref) { | 12117 return error::kNoError; |
12118 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", | |
12119 "unknown texture"); | |
12120 return error::kNoError; | |
12121 } | |
12122 Texture::ImageState image_state; | |
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 } | 12118 } |
12131 | 12119 |
12132 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, | 12120 size_t textures_size = num_textures * sizeof(GLuint); |
12133 8 * sizeof(GLfloat)); | 12121 |
12134 if (!mem) { | 12122 base::CheckedNumeric<uint32_t> data_size = textures_size; |
| 12123 const uint32_t kRectDataSize = 8 * sizeof(GLfloat); |
| 12124 data_size += kRectDataSize; |
| 12125 if (!data_size.IsValid()) |
| 12126 return error::kOutOfBounds; |
| 12127 const void* data = |
| 12128 GetAddressAndCheckSize(c.shm_id, c.shm_offset, data_size.ValueOrDie()); |
| 12129 if (!data) { |
12135 return error::kOutOfBounds; | 12130 return error::kOutOfBounds; |
12136 } | 12131 } |
| 12132 const GLfloat* mem = reinterpret_cast<const GLfloat*>(data); |
| 12133 |
12137 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]); | 12134 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]); | 12135 gfx::RectF bounds_rect(mem[4], mem[5], mem[6], mem[7]); |
12139 | 12136 |
| 12137 const volatile GLuint* texture_ids = reinterpret_cast<const volatile GLuint*>( |
| 12138 static_cast<const volatile char*>(data) + kRectDataSize); |
| 12139 |
| 12140 std::vector<scoped_refptr<gl::GLImage>> images; |
| 12141 for (int i = 0; i < num_textures; ++i) { |
| 12142 GLuint contents_texture_id = texture_ids[i]; |
| 12143 scoped_refptr<gl::GLImage> image; |
| 12144 if (contents_texture_id) { |
| 12145 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); |
| 12146 if (!ref) { |
| 12147 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", |
| 12148 "unknown texture"); |
| 12149 return error::kNoError; |
| 12150 } |
| 12151 Texture::ImageState image_state; |
| 12152 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, |
| 12153 &image_state); |
| 12154 if (!image) { |
| 12155 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", |
| 12156 "unsupported texture format"); |
| 12157 return error::kNoError; |
| 12158 } |
| 12159 } |
| 12160 images.push_back(image); |
| 12161 } |
| 12162 |
12140 ui::DCRendererLayerParams params = ui::DCRendererLayerParams( | 12163 ui::DCRendererLayerParams params = ui::DCRendererLayerParams( |
12141 dc_layer_shared_state_->is_clipped, dc_layer_shared_state_->clip_rect, | 12164 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, | 12165 dc_layer_shared_state_->z_order, dc_layer_shared_state_->transform, |
12143 contents_rect, gfx::ToEnclosingRect(bounds_rect), c.background_color, | 12166 images, contents_rect, gfx::ToEnclosingRect(bounds_rect), |
12144 c.edge_aa_mask, dc_layer_shared_state_->opacity, filter); | 12167 c.background_color, c.edge_aa_mask, dc_layer_shared_state_->opacity, |
| 12168 filter); |
12145 if (!surface_->ScheduleDCLayer(params)) { | 12169 if (!surface_->ScheduleDCLayer(params)) { |
12146 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", | 12170 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", |
12147 "failed to schedule DCLayer"); | 12171 "failed to schedule DCLayer"); |
12148 } | 12172 } |
12149 return error::kNoError; | 12173 return error::kNoError; |
12150 } | 12174 } |
12151 | 12175 |
12152 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( | 12176 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( |
12153 GLsizei count, | 12177 GLsizei count, |
12154 const volatile GLuint* textures) { | 12178 const volatile GLuint* textures) { |
(...skipping 7477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19632 } | 19656 } |
19633 | 19657 |
19634 // Include the auto-generated part of this file. We split this because it means | 19658 // 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 | 19659 // 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. | 19660 // instead of having to edit some template or the code generator. |
19637 #include "base/macros.h" | 19661 #include "base/macros.h" |
19638 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19662 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
19639 | 19663 |
19640 } // namespace gles2 | 19664 } // namespace gles2 |
19641 } // namespace gpu | 19665 } // namespace gpu |
OLD | NEW |