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

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

Issue 10871080: Add tracing to early-outs of accelerated surface presents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 HRESULT hr; 682 HRESULT hr;
683 683
684 base::AutoLock locked(lock_); 684 base::AutoLock locked(lock_);
685 685
686 // Initialize the device lazily since calling Direct3D can crash bots. 686 // Initialize the device lazily since calling Direct3D can crash bots.
687 present_thread_->InitDevice(); 687 present_thread_->InitDevice();
688 688
689 if (!present_thread_->device()) { 689 if (!present_thread_->device()) {
690 if (!completion_task.is_null()) 690 if (!completion_task.is_null())
691 completion_task.Run(false, base::TimeTicks(), base::TimeDelta()); 691 completion_task.Run(false, base::TimeTicks(), base::TimeDelta());
692 TRACE_EVENT0("gpu", "EarlyOut_NoDevice");
692 return; 693 return;
693 } 694 }
694 695
695 // Ensure the task is always run and while the lock is taken. 696 // Ensure the task is always run and while the lock is taken.
696 base::ScopedClosureRunner scoped_completion_runner( 697 base::ScopedClosureRunner scoped_completion_runner(
697 base::Bind(completion_task, true, base::TimeTicks(), base::TimeDelta())); 698 base::Bind(completion_task, true, base::TimeTicks(), base::TimeDelta()));
698 699
699 // If invalidated, do nothing, the window is gone. 700 // If invalidated, do nothing, the window is gone.
700 if (!window_) 701 if (!window_) {
702 TRACE_EVENT0("gpu", "EarlyOut_NoWindow");
701 return; 703 return;
704 }
702 705
703 // If the window is a different size than the swap chain that is being 706 // If the window is a different size than the swap chain that is being
704 // presented then drop the frame. 707 // presented then drop the frame.
705 RECT window_rect; 708 RECT window_rect;
706 GetClientRect(window_, &window_rect); 709 GetClientRect(window_, &window_rect);
707 if (hidden_ && (window_rect.right != size.width() || 710 if (hidden_ && (window_rect.right != size.width() ||
708 window_rect.bottom != size.height())) { 711 window_rect.bottom != size.height())) {
712 TRACE_EVENT2("gpu", "EarlyOut_WrongWindowSize",
713 "backwidth", size.width(), "backheight", size.height());
714 TRACE_EVENT2("gpu", "EarlyOut_WrongWindowSize2",
715 "windowwidth", window_rect.right,
716 "windowheight", window_rect.bottom);
709 return; 717 return;
710 } 718 }
711 719
712 // Round up size so the swap chain is not continuously resized with the 720 // Round up size so the swap chain is not continuously resized with the
713 // surface, which could lead to memory fragmentation. 721 // surface, which could lead to memory fragmentation.
714 const int kRound = 64; 722 const int kRound = 64;
715 gfx::Size quantized_size( 723 gfx::Size quantized_size(
716 std::max(1, (size.width() + kRound - 1) / kRound * kRound), 724 std::max(1, (size.width() + kRound - 1) / kRound * kRound),
717 std::max(1, (size.height() + kRound - 1) / kRound * kRound)); 725 std::max(1, (size.height() + kRound - 1) / kRound * kRound));
718 726
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 D3DFMT_A8R8G8B8, 759 D3DFMT_A8R8G8B8,
752 D3DPOOL_DEFAULT, 760 D3DPOOL_DEFAULT,
753 source_texture_.Receive(), 761 source_texture_.Receive(),
754 &handle); 762 &handle);
755 if (FAILED(hr)) 763 if (FAILED(hr))
756 return; 764 return;
757 } 765 }
758 766
759 base::win::ScopedComPtr<IDirect3DSurface9> source_surface; 767 base::win::ScopedComPtr<IDirect3DSurface9> source_surface;
760 hr = source_texture_->GetSurfaceLevel(0, source_surface.Receive()); 768 hr = source_texture_->GetSurfaceLevel(0, source_surface.Receive());
761 if (FAILED(hr)) 769 if (FAILED(hr)) {
770 TRACE_EVENT0("gpu", "EarlyOut_NoSurfaceLevel");
762 return; 771 return;
772 }
763 773
764 base::win::ScopedComPtr<IDirect3DSurface9> dest_surface; 774 base::win::ScopedComPtr<IDirect3DSurface9> dest_surface;
765 hr = swap_chain_->GetBackBuffer(0, 775 hr = swap_chain_->GetBackBuffer(0,
766 D3DBACKBUFFER_TYPE_MONO, 776 D3DBACKBUFFER_TYPE_MONO,
767 dest_surface.Receive()); 777 dest_surface.Receive());
768 if (FAILED(hr)) 778 if (FAILED(hr)) {
779 TRACE_EVENT0("gpu", "EarlyOut_NoBackbuffer");
769 return; 780 return;
781 }
770 782
771 RECT rect = { 783 RECT rect = {
772 0, 0, 784 0, 0,
773 size.width(), size.height() 785 size.width(), size.height()
774 }; 786 };
775 787
776 { 788 {
777 TRACE_EVENT0("gpu", "Copy"); 789 TRACE_EVENT0("gpu", "Copy");
778 790
779 // Use a simple pixel / vertex shader pair to render a quad that flips the 791 // Use a simple pixel / vertex shader pair to render a quad that flips the
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return presenter_->CopyTo(src_subrect, dst_size, buf); 935 return presenter_->CopyTo(src_subrect, dst_size, buf);
924 } 936 }
925 937
926 void AcceleratedSurface::Suspend() { 938 void AcceleratedSurface::Suspend() {
927 presenter_->Suspend(); 939 presenter_->Suspend();
928 } 940 }
929 941
930 void AcceleratedSurface::WasHidden() { 942 void AcceleratedSurface::WasHidden() {
931 presenter_->WasHidden(); 943 presenter_->WasHidden();
932 } 944 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698