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

Side by Side Diff: ui/surface/accelerated_surface_win.cc

Issue 11953054: Fix high-DPI on Windows to make use of DIP scaling in WebKit. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove experimental changes to resource handling. Created 7 years, 11 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
« ui/gfx/screen_win.cc ('K') | « ui/gfx/screen_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/surface/accelerated_surface_win.h" 5 #include "ui/surface/accelerated_surface_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <windows.h> 8 #include <windows.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/debug/trace_event.h" 15 #include "base/debug/trace_event.h"
16 #include "base/file_path.h" 16 #include "base/file_path.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop_proxy.h" 19 #include "base/message_loop_proxy.h"
20 #include "base/scoped_native_library.h" 20 #include "base/scoped_native_library.h"
21 #include "base/string_number_conversions.h" 21 #include "base/string_number_conversions.h"
22 #include "base/stringprintf.h" 22 #include "base/stringprintf.h"
23 #include "base/synchronization/waitable_event.h" 23 #include "base/synchronization/waitable_event.h"
24 #include "base/threading/thread.h" 24 #include "base/threading/thread.h"
25 #include "base/threading/thread_restrictions.h" 25 #include "base/threading/thread_restrictions.h"
26 #include "base/time.h" 26 #include "base/time.h"
27 #include "base/tracked_objects.h" 27 #include "base/tracked_objects.h"
28 #include "base/win/wrapped_window_proc.h" 28 #include "base/win/wrapped_window_proc.h"
29 #include "ui/base/win/dpi.h"
29 #include "ui/base/win/hwnd_util.h" 30 #include "ui/base/win/hwnd_util.h"
30 #include "ui/gfx/rect.h" 31 #include "ui/gfx/rect.h"
31 #include "ui/gl/gl_switches.h" 32 #include "ui/gl/gl_switches.h"
32 #include "ui/surface/accelerated_surface_transformer_win.h" 33 #include "ui/surface/accelerated_surface_transformer_win.h"
33 #include "ui/surface/d3d9_utils_win.h" 34 #include "ui/surface/d3d9_utils_win.h"
34 35
35 namespace d3d_utils = ui_surface_d3d9_utils; 36 namespace d3d_utils = ui_surface_d3d9_utils;
36 37
37 namespace { 38 namespace {
38 39
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // If invalidated, do nothing, the window is gone. 497 // If invalidated, do nothing, the window is gone.
497 if (!window_) { 498 if (!window_) {
498 TRACE_EVENT0("gpu", "EarlyOut_NoWindow"); 499 TRACE_EVENT0("gpu", "EarlyOut_NoWindow");
499 return; 500 return;
500 } 501 }
501 502
502 #if !defined(USE_AURA) 503 #if !defined(USE_AURA)
503 // If the window is a different size than the swap chain that is being 504 // If the window is a different size than the swap chain that is being
504 // presented then drop the frame. 505 // presented then drop the frame.
505 gfx::Size window_size = GetWindowSize(); 506 gfx::Size window_size = GetWindowSize();
506 if (hidden_ && size != window_size) { 507 #if defined(ENABLE_HIDPI)
508 // Check if the size mismatch is within allowable round off or truncation
509 // error.
510 gfx::Size dip_size = ui::win::ScreenToDIPSize(window_size);
511 gfx::Size pixel_size = ui::win::DIPToScreenSize(dip_size);
512 bool size_mismatch = abs(window_size.width() - size.width()) >
513 abs(window_size.width() - pixel_size.width()) ||
514 abs(window_size.height() - size.height()) >
515 abs(window_size.height() - pixel_size.height());
516 #else
517 bool size_mismatch = size != window_size;
518 #endif
519 if (hidden_ && size_mismatch) {
507 TRACE_EVENT2("gpu", "EarlyOut_WrongWindowSize", 520 TRACE_EVENT2("gpu", "EarlyOut_WrongWindowSize",
508 "backwidth", size.width(), "backheight", size.height()); 521 "backwidth", size.width(), "backheight", size.height());
509 TRACE_EVENT2("gpu", "EarlyOut_WrongWindowSize2", 522 TRACE_EVENT2("gpu", "EarlyOut_WrongWindowSize2",
510 "windowwidth", window_size.width(), 523 "windowwidth", window_size.width(),
511 "windowheight", window_size.height()); 524 "windowheight", window_size.height());
512 return; 525 return;
513 } 526 }
514 #endif 527 #endif
515 528
516 // Round up size so the swap chain is not continuously resized with the 529 // Round up size so the swap chain is not continuously resized with the
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 694 }
682 695
683 void AcceleratedPresenter::DoReleaseSurface() { 696 void AcceleratedPresenter::DoReleaseSurface() {
684 base::AutoLock locked(lock_); 697 base::AutoLock locked(lock_);
685 present_thread_->InitDevice(); 698 present_thread_->InitDevice();
686 source_texture_.Release(); 699 source_texture_.Release();
687 } 700 }
688 701
689 void AcceleratedPresenter::PresentWithGDI(HDC dc) { 702 void AcceleratedPresenter::PresentWithGDI(HDC dc) {
690 TRACE_EVENT0("gpu", "PresentWithGDI"); 703 TRACE_EVENT0("gpu", "PresentWithGDI");
691
pkotwicz 2013/01/23 19:39:23 Nit: Keep the extra line
kevers 2013/01/23 21:37:00 Done.
692 if (!present_thread_->device()) 704 if (!present_thread_->device())
693 return; 705 return;
694 706
695 if (!swap_chain_) 707 if (!swap_chain_)
696 return; 708 return;
697 709
698 base::win::ScopedComPtr<IDirect3DTexture9> system_texture; 710 base::win::ScopedComPtr<IDirect3DTexture9> system_texture;
699 { 711 {
700 TRACE_EVENT0("gpu", "CreateSystemTexture"); 712 TRACE_EVENT0("gpu", "CreateSystemTexture");
701 HRESULT hr = present_thread_->device()->CreateTexture( 713 HRESULT hr = present_thread_->device()->CreateTexture(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 presenter_->AsyncCopyTo(src_subrect, dst_size, buf, callback); 819 presenter_->AsyncCopyTo(src_subrect, dst_size, buf, callback);
808 } 820 }
809 821
810 void AcceleratedSurface::Suspend() { 822 void AcceleratedSurface::Suspend() {
811 presenter_->Suspend(); 823 presenter_->Suspend();
812 } 824 }
813 825
814 void AcceleratedSurface::WasHidden() { 826 void AcceleratedSurface::WasHidden() {
815 presenter_->WasHidden(); 827 presenter_->WasHidden();
816 } 828 }
OLDNEW
« ui/gfx/screen_win.cc ('K') | « ui/gfx/screen_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698