Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2852953003: Use real colorspace for DirectComposition overlays.
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12078 matching lines...) Expand 10 before | Expand all | Expand 10 after
12089 } 12089 }
12090 12090
12091 GLsizei num_textures = c.num_textures; 12091 GLsizei num_textures = c.num_textures;
12092 if (num_textures < 0 || num_textures > 4) { 12092 if (num_textures < 0 || num_textures > 4) {
12093 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", 12093 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM",
12094 "number of textures greater than maximum of 4"); 12094 "number of textures greater than maximum of 4");
12095 return error::kNoError; 12095 return error::kNoError;
12096 } 12096 }
12097 12097
12098 size_t textures_size = num_textures * sizeof(GLuint); 12098 size_t textures_size = num_textures * sizeof(GLuint);
12099 GLsizei color_space_size = c.color_space_size;
12099 12100
12100 base::CheckedNumeric<uint32_t> data_size = textures_size; 12101 base::CheckedNumeric<uint32_t> data_size = textures_size;
12101 const uint32_t kRectDataSize = 8 * sizeof(GLfloat); 12102 const uint32_t kRectDataSize = 8 * sizeof(GLfloat);
12102 data_size += kRectDataSize; 12103 data_size += kRectDataSize;
12104 data_size += color_space_size;
12103 if (!data_size.IsValid()) 12105 if (!data_size.IsValid())
12104 return error::kOutOfBounds; 12106 return error::kOutOfBounds;
12105 const void* data = 12107 const void* data =
12106 GetAddressAndCheckSize(c.shm_id, c.shm_offset, data_size.ValueOrDie()); 12108 GetAddressAndCheckSize(c.shm_id, c.shm_offset, data_size.ValueOrDie());
12107 if (!data) { 12109 if (!data) {
12108 return error::kOutOfBounds; 12110 return error::kOutOfBounds;
12109 } 12111 }
12110 const GLfloat* mem = reinterpret_cast<const GLfloat*>(data); 12112 const GLfloat* mem = reinterpret_cast<const GLfloat*>(data);
12111 12113
12112 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]); 12114 gfx::RectF contents_rect(mem[0], mem[1], mem[2], mem[3]);
(...skipping 18 matching lines...) Expand all
12131 &image_state); 12133 &image_state);
12132 if (!image) { 12134 if (!image) {
12133 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM", 12135 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleDCLayerCHROMIUM",
12134 "unsupported texture format"); 12136 "unsupported texture format");
12135 return error::kNoError; 12137 return error::kNoError;
12136 } 12138 }
12137 } 12139 }
12138 images.push_back(image); 12140 images.push_back(image);
12139 } 12141 }
12140 12142
12143 volatile const char* volatile_color_space_data =
12144 reinterpret_cast<volatile const char*>(data) + kRectDataSize +
12145 textures_size;
12146
12147 // Make a copy to reduce the risk of a time of check to time of use attack.
12148 std::vector<char> color_space_data(
12149 volatile_color_space_data, volatile_color_space_data + color_space_size);
12150 base::Pickle color_space_pickle(color_space_data.data(), color_space_size);
12151 base::PickleIterator iterator(color_space_pickle);
12152 gfx::ColorSpace color_space;
12153 if (!color_space.ReadFromPickle(&iterator))
12154 return error::kOutOfBounds;
12155
12141 ui::DCRendererLayerParams params = ui::DCRendererLayerParams( 12156 ui::DCRendererLayerParams params = ui::DCRendererLayerParams(
12142 dc_layer_shared_state_->is_clipped, dc_layer_shared_state_->clip_rect, 12157 dc_layer_shared_state_->is_clipped, dc_layer_shared_state_->clip_rect,
12143 dc_layer_shared_state_->z_order, dc_layer_shared_state_->transform, 12158 dc_layer_shared_state_->z_order, dc_layer_shared_state_->transform,
12144 images, contents_rect, gfx::ToEnclosingRect(bounds_rect), 12159 images, contents_rect, gfx::ToEnclosingRect(bounds_rect),
12145 c.background_color, c.edge_aa_mask, dc_layer_shared_state_->opacity, 12160 c.background_color, c.edge_aa_mask, dc_layer_shared_state_->opacity,
12146 filter); 12161 filter, color_space);
12147 if (!surface_->ScheduleDCLayer(params)) { 12162 if (!surface_->ScheduleDCLayer(params)) {
12148 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM", 12163 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleDCLayerCHROMIUM",
12149 "failed to schedule DCLayer"); 12164 "failed to schedule DCLayer");
12150 } 12165 }
12151 return error::kNoError; 12166 return error::kNoError;
12152 } 12167 }
12153 12168
12154 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM( 12169 void GLES2DecoderImpl::DoScheduleCALayerInUseQueryCHROMIUM(
12155 GLsizei count, 12170 GLsizei count,
12156 const volatile GLuint* textures) { 12171 const volatile GLuint* textures) {
(...skipping 7483 matching lines...) Expand 10 before | Expand all | Expand 10 after
19640 } 19655 }
19641 19656
19642 // 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
19643 // 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
19644 // instead of having to edit some template or the code generator. 19659 // instead of having to edit some template or the code generator.
19645 #include "base/macros.h" 19660 #include "base/macros.h"
19646 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19661 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19647 19662
19648 } // namespace gles2 19663 } // namespace gles2
19649 } // namespace gpu 19664 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698