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_SPARSE_SLOWLY("GPU.DirectComposition.CompositionMode", |
| 354 stats.CompositionMode); |
| 355 } |
| 356 } |
347 } | 357 } |
348 | 358 |
349 bool DCLayerTree::SwapChainPresenter::InitializeVideoProcessor( | 359 bool DCLayerTree::SwapChainPresenter::InitializeVideoProcessor( |
350 const gfx::Size& in_size, | 360 const gfx::Size& in_size, |
351 const gfx::Size& out_size) { | 361 const gfx::Size& out_size) { |
352 if (video_processor_ && SizeContains(processor_input_size_, in_size) && | 362 if (video_processor_ && SizeContains(processor_input_size_, in_size) && |
353 SizeContains(processor_output_size_, out_size)) | 363 SizeContains(processor_output_size_, out_size)) |
354 return false; | 364 return false; |
355 processor_input_size_ = in_size; | 365 processor_input_size_ = in_size; |
356 processor_output_size_ = out_size; | 366 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()); | 558 visual_info->clip_visual->SetClip(clip.get()); |
549 } else { | 559 } else { |
550 visual_info->clip_visual->SetClip(nullptr); | 560 visual_info->clip_visual->SetClip(nullptr); |
551 } | 561 } |
552 } | 562 } |
553 } | 563 } |
554 | 564 |
555 bool DCLayerTree::CommitAndClearPendingOverlays() { | 565 bool DCLayerTree::CommitAndClearPendingOverlays() { |
556 TRACE_EVENT1("gpu", "DCLayerTree::CommitAndClearPendingOverlays", "size", | 566 TRACE_EVENT1("gpu", "DCLayerTree::CommitAndClearPendingOverlays", "size", |
557 pending_overlays_.size()); | 567 pending_overlays_.size()); |
| 568 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.OverlaysUsed", |
| 569 !pending_overlays_.empty()); |
558 // Add an overlay with z-order 0 representing the main plane. | 570 // Add an overlay with z-order 0 representing the main plane. |
559 gfx::Size surface_size = surface_->GetSize(); | 571 gfx::Size surface_size = surface_->GetSize(); |
560 pending_overlays_.push_back(base::MakeUnique<ui::DCRendererLayerParams>( | 572 pending_overlays_.push_back(base::MakeUnique<ui::DCRendererLayerParams>( |
561 false, gfx::Rect(), 0, gfx::Transform(), nullptr, | 573 false, gfx::Rect(), 0, gfx::Transform(), nullptr, |
562 gfx::RectF(gfx::SizeF(surface_size)), gfx::Rect(surface_size), 0, 0, 1.0, | 574 gfx::RectF(gfx::SizeF(surface_size)), gfx::Rect(surface_size), 0, 0, 1.0, |
563 0)); | 575 0)); |
564 | 576 |
565 // TODO(jbauman): Reuse swapchains that are switched between overlays and | 577 // TODO(jbauman): Reuse swapchains that are switched between overlays and |
566 // underlays. | 578 // underlays. |
567 std::sort(pending_overlays_.begin(), pending_overlays_.end(), | 579 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 { | 984 gfx::Vector2d DirectCompositionSurfaceWin::GetDrawOffset() const { |
973 return draw_offset_; | 985 return draw_offset_; |
974 } | 986 } |
975 | 987 |
976 scoped_refptr<base::TaskRunner> | 988 scoped_refptr<base::TaskRunner> |
977 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 989 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
978 return child_window_.GetTaskRunnerForTesting(); | 990 return child_window_.GetTaskRunnerForTesting(); |
979 } | 991 } |
980 | 992 |
981 } // namespace gpu | 993 } // namespace gpu |
OLD | NEW |