| 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 "ui/compositor/compositor.h" | 5 #include "ui/compositor/compositor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 settings.use_zero_copy = IsUIZeroCopyEnabled(); | 156 settings.use_zero_copy = IsUIZeroCopyEnabled(); |
| 157 | 157 |
| 158 if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures)) | 158 if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures)) |
| 159 settings.renderer_settings.preferred_tile_format = cc::RGBA_4444; | 159 settings.renderer_settings.preferred_tile_format = cc::RGBA_4444; |
| 160 | 160 |
| 161 settings.use_layer_lists = | 161 settings.use_layer_lists = |
| 162 command_line->HasSwitch(cc::switches::kUIEnableLayerLists); | 162 command_line->HasSwitch(cc::switches::kUIEnableLayerLists); |
| 163 | 163 |
| 164 settings.enable_color_correct_rendering = | 164 settings.enable_color_correct_rendering = |
| 165 command_line->HasSwitch(cc::switches::kEnableColorCorrectRendering) || | 165 command_line->HasSwitch(cc::switches::kEnableColorCorrectRendering) || |
| 166 command_line->HasSwitch(cc::switches::kEnableTrueColorRendering) || | 166 command_line->HasSwitch(cc::switches::kEnableTrueColorRendering); |
| 167 settings.renderer_settings.enable_color_correct_rendering = |
| 168 settings.enable_color_correct_rendering || |
| 167 command_line->HasSwitch(switches::kEnableHDROutput); | 169 command_line->HasSwitch(switches::kEnableHDROutput); |
| 168 settings.renderer_settings.enable_color_correct_rendering = | |
| 169 settings.enable_color_correct_rendering; | |
| 170 | 170 |
| 171 // UI compositor always uses partial raster if not using zero-copy. Zero copy | 171 // UI compositor always uses partial raster if not using zero-copy. Zero copy |
| 172 // doesn't currently support partial raster. | 172 // doesn't currently support partial raster. |
| 173 settings.use_partial_raster = !settings.use_zero_copy; | 173 settings.use_partial_raster = !settings.use_zero_copy; |
| 174 | 174 |
| 175 // Populate buffer_to_texture_target_map for all buffer usage/formats. | 175 // Populate buffer_to_texture_target_map for all buffer usage/formats. |
| 176 for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); | 176 for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); |
| 177 ++usage_idx) { | 177 ++usage_idx) { |
| 178 gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); | 178 gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); |
| 179 for (int format_idx = 0; | 179 for (int format_idx = 0; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 275 } |
| 276 | 276 |
| 277 void Compositor::SetCompositorFrameSink( | 277 void Compositor::SetCompositorFrameSink( |
| 278 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink) { | 278 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink) { |
| 279 compositor_frame_sink_requested_ = false; | 279 compositor_frame_sink_requested_ = false; |
| 280 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 280 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 281 // Display properties are reset when the output surface is lost, so update it | 281 // Display properties are reset when the output surface is lost, so update it |
| 282 // to match the Compositor's. | 282 // to match the Compositor's. |
| 283 if (context_factory_private_) { | 283 if (context_factory_private_) { |
| 284 context_factory_private_->SetDisplayVisible(this, host_->IsVisible()); | 284 context_factory_private_->SetDisplayVisible(this, host_->IsVisible()); |
| 285 context_factory_private_->SetDisplayColorSpace(this, color_space_); | 285 context_factory_private_->SetDisplayColorSpace(this, blending_color_space_, |
| 286 output_color_space_); |
| 286 } | 287 } |
| 287 } | 288 } |
| 288 | 289 |
| 289 void Compositor::ScheduleDraw() { | 290 void Compositor::ScheduleDraw() { |
| 290 host_->SetNeedsCommit(); | 291 host_->SetNeedsCommit(); |
| 291 } | 292 } |
| 292 | 293 |
| 293 void Compositor::SetRootLayer(Layer* root_layer) { | 294 void Compositor::SetRootLayer(Layer* root_layer) { |
| 294 if (root_layer_ == root_layer) | 295 if (root_layer_ == root_layer) |
| 295 return; | 296 return; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 348 } |
| 348 if (device_scale_factor_ != scale) { | 349 if (device_scale_factor_ != scale) { |
| 349 device_scale_factor_ = scale; | 350 device_scale_factor_ = scale; |
| 350 host_->SetDeviceScaleFactor(scale); | 351 host_->SetDeviceScaleFactor(scale); |
| 351 if (root_layer_) | 352 if (root_layer_) |
| 352 root_layer_->OnDeviceScaleFactorChanged(scale); | 353 root_layer_->OnDeviceScaleFactorChanged(scale); |
| 353 } | 354 } |
| 354 } | 355 } |
| 355 | 356 |
| 356 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { | 357 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { |
| 358 blending_color_space_ = color_space; |
| 359 output_color_space_ = color_space; |
| 357 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 360 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 358 switches::kEnableHDROutput)) { | 361 switches::kEnableHDROutput)) { |
| 359 color_space_ = gfx::ColorSpace::CreateSCRGBLinear(); | 362 blending_color_space_ = gfx::ColorSpace::CreateExtendedSRGB(); |
| 360 } else { | 363 output_color_space_ = gfx::ColorSpace::CreateSCRGBLinear(); |
| 361 color_space_ = color_space; | |
| 362 } | 364 } |
| 363 // TODO(Hubbe): Should maybe be color_space_, but currently that crashes skia. | 365 host_->SetDeviceColorSpace(blending_color_space_); |
| 364 host_->SetDeviceColorSpace(color_space); | |
| 365 // Color space is reset when the output surface is lost, so this must also be | 366 // Color space is reset when the output surface is lost, so this must also be |
| 366 // updated then. | 367 // updated then. |
| 367 // TODO(fsamuel): Get rid of this. | 368 // TODO(fsamuel): Get rid of this. |
| 368 if (context_factory_private_) | 369 if (context_factory_private_) { |
| 369 context_factory_private_->SetDisplayColorSpace(this, color_space_); | 370 context_factory_private_->SetDisplayColorSpace(this, blending_color_space_, |
| 371 output_color_space_); |
| 372 } |
| 370 } | 373 } |
| 371 | 374 |
| 372 void Compositor::SetBackgroundColor(SkColor color) { | 375 void Compositor::SetBackgroundColor(SkColor color) { |
| 373 host_->set_background_color(color); | 376 host_->set_background_color(color); |
| 374 ScheduleDraw(); | 377 ScheduleDraw(); |
| 375 } | 378 } |
| 376 | 379 |
| 377 void Compositor::SetVisible(bool visible) { | 380 void Compositor::SetVisible(bool visible) { |
| 378 host_->SetVisible(visible); | 381 host_->SetVisible(visible); |
| 379 // Visibility is reset when the output surface is lost, so this must also be | 382 // Visibility is reset when the output surface is lost, so this must also be |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 for (auto& observer : observer_list_) | 570 for (auto& observer : observer_list_) |
| 568 observer.OnCompositingLockStateChanged(this); | 571 observer.OnCompositingLockStateChanged(this); |
| 569 } | 572 } |
| 570 | 573 |
| 571 void Compositor::CancelCompositorLock() { | 574 void Compositor::CancelCompositorLock() { |
| 572 if (compositor_lock_) | 575 if (compositor_lock_) |
| 573 compositor_lock_->CancelLock(); | 576 compositor_lock_->CancelLock(); |
| 574 } | 577 } |
| 575 | 578 |
| 576 } // namespace ui | 579 } // namespace ui |
| OLD | NEW |