Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ipc/service/direct_composition_surface_win.h" | 5 #include "gpu/ipc/service/direct_composition_surface_win.h" |
| 6 | 6 |
| 7 #include <d3d11_1.h> | 7 #include <d3d11_1.h> |
| 8 #include <dcomptypes.h> | 8 #include <dcomptypes.h> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/metrics/histogram_macros.h" | |
| 11 #include "base/optional.h" | 12 #include "base/optional.h" |
| 12 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "base/win/scoped_handle.h" | 15 #include "base/win/scoped_handle.h" |
| 15 #include "gpu/ipc/service/gpu_channel_manager.h" | 16 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 16 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 17 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 17 #include "gpu/ipc/service/switches.h" | 18 #include "gpu/ipc/service/switches.h" |
| 18 #include "ui/display/display_switches.h" | 19 #include "ui/display/display_switches.h" |
| 19 #include "ui/gfx/geometry/size_conversions.h" | 20 #include "ui/gfx/geometry/size_conversions.h" |
| 20 #include "ui/gfx/native_widget_types.h" | 21 #include "ui/gfx/native_widget_types.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 | 338 |
| 338 hr = video_context_->VideoProcessorBlt(video_processor_.get(), | 339 hr = video_context_->VideoProcessorBlt(video_processor_.get(), |
| 339 out_view_.get(), 0, 1, &stream); | 340 out_view_.get(), 0, 1, &stream); |
| 340 CHECK(SUCCEEDED(hr)); | 341 CHECK(SUCCEEDED(hr)); |
| 341 } | 342 } |
| 342 | 343 |
| 343 swap_chain_scale_x_ = bounds_rect.width() * 1.0f / swap_chain_size.width(); | 344 swap_chain_scale_x_ = bounds_rect.width() * 1.0f / swap_chain_size.width(); |
| 344 swap_chain_scale_y_ = bounds_rect.height() * 1.0f / swap_chain_size.height(); | 345 swap_chain_scale_y_ = bounds_rect.height() * 1.0f / swap_chain_size.height(); |
| 345 | 346 |
| 346 swap_chain_->Present(first_present ? 0 : 1, 0); | 347 swap_chain_->Present(first_present ? 0 : 1, 0); |
| 348 | |
| 349 base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; | |
| 350 if (SUCCEEDED(swap_chain_.QueryInterface(swap_chain_media.Receive()))) { | |
| 351 DXGI_FRAME_STATISTICS_MEDIA stats = {}; | |
| 352 if (SUCCEEDED(swap_chain_media->GetFrameStatisticsMedia(&stats))) { | |
| 353 UMA_HISTOGRAM_ENUMERATION( | |
| 354 "GPU.DirectComposition.CompositionMode", stats.CompositionMode, | |
| 355 DXGI_FRAME_PRESENTATION_MODE_COMPOSITION_FAILURE + 1); | |
|
Ilya Sherman
2017/03/29 05:16:42
This code looks fragile, in the sense that someone
| |
| 356 } | |
| 357 } | |
| 347 } | 358 } |
| 348 | 359 |
| 349 bool DCLayerTree::SwapChainPresenter::InitializeVideoProcessor( | 360 bool DCLayerTree::SwapChainPresenter::InitializeVideoProcessor( |
| 350 const gfx::Size& in_size, | 361 const gfx::Size& in_size, |
| 351 const gfx::Size& out_size) { | 362 const gfx::Size& out_size) { |
| 352 if (video_processor_ && SizeContains(processor_input_size_, in_size) && | 363 if (video_processor_ && SizeContains(processor_input_size_, in_size) && |
| 353 SizeContains(processor_output_size_, out_size)) | 364 SizeContains(processor_output_size_, out_size)) |
| 354 return false; | 365 return false; |
| 355 processor_input_size_ = in_size; | 366 processor_input_size_ = in_size; |
| 356 processor_output_size_ = out_size; | 367 processor_output_size_ = out_size; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 visual_info->clip_visual->SetClip(clip.get()); | 559 visual_info->clip_visual->SetClip(clip.get()); |
| 549 } else { | 560 } else { |
| 550 visual_info->clip_visual->SetClip(nullptr); | 561 visual_info->clip_visual->SetClip(nullptr); |
| 551 } | 562 } |
| 552 } | 563 } |
| 553 } | 564 } |
| 554 | 565 |
| 555 bool DCLayerTree::CommitAndClearPendingOverlays() { | 566 bool DCLayerTree::CommitAndClearPendingOverlays() { |
| 556 TRACE_EVENT1("gpu", "DCLayerTree::CommitAndClearPendingOverlays", "size", | 567 TRACE_EVENT1("gpu", "DCLayerTree::CommitAndClearPendingOverlays", "size", |
| 557 pending_overlays_.size()); | 568 pending_overlays_.size()); |
| 569 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.OverlaysUsed", | |
| 570 !pending_overlays_.empty()); | |
| 558 // Add an overlay with z-order 0 representing the main plane. | 571 // Add an overlay with z-order 0 representing the main plane. |
| 559 gfx::Size surface_size = surface_->GetSize(); | 572 gfx::Size surface_size = surface_->GetSize(); |
| 560 pending_overlays_.push_back(base::MakeUnique<ui::DCRendererLayerParams>( | 573 pending_overlays_.push_back(base::MakeUnique<ui::DCRendererLayerParams>( |
| 561 false, gfx::Rect(), 0, gfx::Transform(), nullptr, | 574 false, gfx::Rect(), 0, gfx::Transform(), nullptr, |
| 562 gfx::RectF(gfx::SizeF(surface_size)), gfx::Rect(surface_size), 0, 0, 1.0, | 575 gfx::RectF(gfx::SizeF(surface_size)), gfx::Rect(surface_size), 0, 0, 1.0, |
| 563 0)); | 576 0)); |
| 564 | 577 |
| 565 // TODO(jbauman): Reuse swapchains that are switched between overlays and | 578 // TODO(jbauman): Reuse swapchains that are switched between overlays and |
| 566 // underlays. | 579 // underlays. |
| 567 std::sort(pending_overlays_.begin(), pending_overlays_.end(), | 580 std::sort(pending_overlays_.begin(), pending_overlays_.end(), |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 gfx::Vector2d DirectCompositionSurfaceWin::GetDrawOffset() const { | 985 gfx::Vector2d DirectCompositionSurfaceWin::GetDrawOffset() const { |
| 973 return draw_offset_; | 986 return draw_offset_; |
| 974 } | 987 } |
| 975 | 988 |
| 976 scoped_refptr<base::TaskRunner> | 989 scoped_refptr<base::TaskRunner> |
| 977 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 990 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
| 978 return child_window_.GetTaskRunnerForTesting(); | 991 return child_window_.GetTaskRunnerForTesting(); |
| 979 } | 992 } |
| 980 | 993 |
| 981 } // namespace gpu | 994 } // namespace gpu |
| OLD | NEW |