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

Side by Side Diff: gpu/ipc/service/direct_composition_surface_win.cc

Issue 2900893002: Update scaling of video layers on every swap. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | gpu/ipc/service/direct_composition_surface_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <deque> 10 #include <deque>
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 gfx::Size ceiled_input_size = gfx::ToCeiledSize(params.contents_rect.size()); 429 gfx::Size ceiled_input_size = gfx::ToCeiledSize(params.contents_rect.size());
430 gfx::Size swap_chain_size = bounds_rect.size(); 430 gfx::Size swap_chain_size = bounds_rect.size();
431 swap_chain_size.SetToMin(ceiled_input_size); 431 swap_chain_size.SetToMin(ceiled_input_size);
432 432
433 // YUY2 surfaces must have an even width. 433 // YUY2 surfaces must have an even width.
434 if (swap_chain_size.width() % 2 == 1) 434 if (swap_chain_size.width() % 2 == 1)
435 swap_chain_size.set_width(swap_chain_size.width() + 1); 435 swap_chain_size.set_width(swap_chain_size.width() + 1);
436 436
437 InitializeVideoProcessor(ceiled_input_size, swap_chain_size); 437 InitializeVideoProcessor(ceiled_input_size, swap_chain_size);
438 438
439 if (surface_->workarounds().disable_larger_than_screen_overlays) {
440 // Because of the rounding when converting between pixels and DIPs, a
441 // fullscreen video can become slightly larger than the monitor - e.g. on
442 // a 3000x2000 monitor with a scale factor of 1.75 a 1920x1079 video can
443 // become 3002x1689.
444 // On older Intel drivers, swapchains that are bigger than the monitor
445 // won't be put into overlays, which will hurt power usage a lot. On those
446 // systems, the scaling can be adjusted very slightly so that it's less
447 // than the monitor size. This should be close to imperceptible.
448 // TODO(jbauman): Remove when http://crbug.com/668278 is fixed.
449 const int kOversizeMargin = 3;
450
451 if ((bounds_rect.x() >= 0) &&
452 (bounds_rect.width() > g_overlay_monitor_size.width()) &&
453 (bounds_rect.width() <=
454 g_overlay_monitor_size.width() + kOversizeMargin)) {
455 bounds_rect.set_width(g_overlay_monitor_size.width());
456 }
457
458 if ((bounds_rect.y() >= 0) &&
459 (bounds_rect.height() > g_overlay_monitor_size.height()) &&
460 (bounds_rect.height() <=
461 g_overlay_monitor_size.height() + kOversizeMargin)) {
462 bounds_rect.set_height(g_overlay_monitor_size.height());
463 }
464 }
465
466 swap_chain_scale_x_ = bounds_rect.width() * 1.0f / swap_chain_size.width();
467 swap_chain_scale_y_ = bounds_rect.height() * 1.0f / swap_chain_size.height();
468
439 bool yuy2_swapchain = ShouldBeYUY2(); 469 bool yuy2_swapchain = ShouldBeYUY2();
440 bool first_present = false; 470 bool first_present = false;
441 if (!swap_chain_ || swap_chain_size_ != swap_chain_size || 471 if (!swap_chain_ || swap_chain_size_ != swap_chain_size ||
442 ((yuy2_swapchain != is_yuy2_swapchain_) && 472 ((yuy2_swapchain != is_yuy2_swapchain_) &&
443 !failed_to_create_yuy2_swapchain_)) { 473 !failed_to_create_yuy2_swapchain_)) {
444 first_present = true; 474 first_present = true;
445 swap_chain_size_ = swap_chain_size; 475 swap_chain_size_ = swap_chain_size;
446 swap_chain_.Reset(); 476 swap_chain_.Reset();
447 ReallocateSwapChain(yuy2_swapchain); 477 ReallocateSwapChain(yuy2_swapchain);
448 } else if (last_gl_image_ == image_dxgi) { 478 } else if (last_gl_image_ == image_dxgi) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 TRUE, &source_rect); 563 TRUE, &source_rect);
534 564
535 video_context_->VideoProcessorSetStreamAutoProcessingMode( 565 video_context_->VideoProcessorSetStreamAutoProcessingMode(
536 video_processor_.get(), 0, FALSE); 566 video_processor_.get(), 0, FALSE);
537 567
538 hr = video_context_->VideoProcessorBlt(video_processor_.get(), 568 hr = video_context_->VideoProcessorBlt(video_processor_.get(),
539 out_view_.get(), 0, 1, &stream); 569 out_view_.get(), 0, 1, &stream);
540 CHECK(SUCCEEDED(hr)); 570 CHECK(SUCCEEDED(hr));
541 } 571 }
542 572
543 if (surface_->workarounds().disable_larger_than_screen_overlays) {
544 // Because of the rounding when converting between pixels and DIPs, a
545 // fullscreen video can become slightly larger than the monitor - e.g. on
546 // a 3000x2000 monitor with a scale factor of 1.75 a 1920x1079 video can
547 // become 3002x1689.
548 // On older Intel drivers, swapchains that are bigger than the monitor
549 // won't be put into overlays, which will hurt power usage a lot. On those
550 // systems, the scaling can be adjusted very slightly so that it's less
551 // than the monitor size. This should be close to imperceptible.
552 // TODO(jbauman): Remove when http://crbug.com/668278 is fixed.
553 const int kOversizeMargin = 3;
554
555 if ((bounds_rect.x() >= 0) &&
556 (bounds_rect.width() > g_overlay_monitor_size.width()) &&
557 (bounds_rect.width() <=
558 g_overlay_monitor_size.width() + kOversizeMargin)) {
559 bounds_rect.set_width(g_overlay_monitor_size.width());
560 }
561
562 if ((bounds_rect.y() >= 0) &&
563 (bounds_rect.height() > g_overlay_monitor_size.height()) &&
564 (bounds_rect.height() <=
565 g_overlay_monitor_size.height() + kOversizeMargin)) {
566 bounds_rect.set_height(g_overlay_monitor_size.height());
567 }
568 }
569
570 swap_chain_scale_x_ = bounds_rect.width() * 1.0f / swap_chain_size.width();
571 swap_chain_scale_y_ = bounds_rect.height() * 1.0f / swap_chain_size.height();
572
573 if (first_present) { 573 if (first_present) {
574 swap_chain_->Present(0, 0); 574 swap_chain_->Present(0, 0);
575 575
576 // DirectComposition can display black for a swapchain between the first 576 // DirectComposition can display black for a swapchain between the first
577 // and second time it's presented to - maybe the first Present can get 577 // and second time it's presented to - maybe the first Present can get
578 // lost somehow and it shows the wrong buffer. In that case copy the 578 // lost somehow and it shows the wrong buffer. In that case copy the
579 // buffers so both have the correct contents, which seems to help. The 579 // buffers so both have the correct contents, which seems to help. The
580 // first Present() after this needs to have SyncInterval > 0, or else the 580 // first Present() after this needs to have SyncInterval > 0, or else the
581 // workaround doesn't help. 581 // workaround doesn't help.
582 base::win::ScopedComPtr<ID3D11Texture2D> dest_texture; 582 base::win::ScopedComPtr<ID3D11Texture2D> dest_texture;
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { 1231 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() {
1232 return child_window_.GetTaskRunnerForTesting(); 1232 return child_window_.GetTaskRunnerForTesting();
1233 } 1233 }
1234 1234
1235 base::win::ScopedComPtr<IDXGISwapChain1> 1235 base::win::ScopedComPtr<IDXGISwapChain1>
1236 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { 1236 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const {
1237 return layer_tree_->GetLayerSwapChainForTesting(index); 1237 return layer_tree_->GetLayerSwapChainForTesting(index);
1238 } 1238 }
1239 1239
1240 } // namespace gpu 1240 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/ipc/service/direct_composition_surface_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698