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

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

Issue 10836018: Add command-line option to have an extra delay before blitting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 <windows.h> 7 #include <windows.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 #include "ui/gl/gl_switches.h" 29 #include "ui/gl/gl_switches.h"
30 30
31 namespace { 31 namespace {
32 32
33 typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT sdk_version, 33 typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT sdk_version,
34 IDirect3D9Ex **d3d); 34 IDirect3D9Ex **d3d);
35 35
36 const wchar_t kD3D9ModuleName[] = L"d3d9.dll"; 36 const wchar_t kD3D9ModuleName[] = L"d3d9.dll";
37 const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex"; 37 const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex";
38 38
39 const char kGpuBlitDelay[] = "gpu-blit-delay";
40
39 struct Vertex { 41 struct Vertex {
40 float x, y, z, w; 42 float x, y, z, w;
41 float u, v; 43 float u, v;
42 }; 44 };
43 45
44 // See accelerated_surface_win.hlsl for source and compilation instructions. 46 // See accelerated_surface_win.hlsl for source and compilation instructions.
45 const BYTE g_vertexMain[] = { 47 const BYTE g_vertexMain[] = {
46 0, 2, 254, 255, 254, 255, 48 0, 2, 254, 255, 254, 255,
47 22, 0, 67, 84, 65, 66, 49 22, 0, 67, 84, 65, 66,
48 28, 0, 0, 0, 35, 0, 50 28, 0, 0, 0, 35, 0,
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 static base::TimeDelta GetSwapDelay() { 652 static base::TimeDelta GetSwapDelay() {
651 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 653 CommandLine* cmd_line = CommandLine::ForCurrentProcess();
652 int delay = 0; 654 int delay = 0;
653 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { 655 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) {
654 base::StringToInt(cmd_line->GetSwitchValueNative( 656 base::StringToInt(cmd_line->GetSwitchValueNative(
655 switches::kGpuSwapDelay).c_str(), &delay); 657 switches::kGpuSwapDelay).c_str(), &delay);
656 } 658 }
657 return base::TimeDelta::FromMilliseconds(delay); 659 return base::TimeDelta::FromMilliseconds(delay);
658 } 660 }
659 661
662 static base::TimeDelta GetBlitDelay() {
663 CommandLine* cmd_line = CommandLine::ForCurrentProcess();
664 int delay = 0;
665 if (cmd_line->HasSwitch(kGpuBlitDelay)) {
666 base::StringToInt(cmd_line->GetSwitchValueNative(
667 kGpuBlitDelay).c_str(), &delay);
668 }
669 return base::TimeDelta::FromMilliseconds(delay);
670 }
671
660 void AcceleratedPresenter::DoPresentAndAcknowledge( 672 void AcceleratedPresenter::DoPresentAndAcknowledge(
661 const gfx::Size& size, 673 const gfx::Size& size,
662 int64 surface_handle, 674 int64 surface_handle,
663 const base::Callback<void(bool)>& completion_task) { 675 const base::Callback<void(bool)>& completion_task) {
664 TRACE_EVENT1( 676 TRACE_EVENT1(
665 "gpu", "DoPresentAndAcknowledge", "surface_handle", surface_handle); 677 "gpu", "DoPresentAndAcknowledge", "surface_handle", surface_handle);
666 678
667 HRESULT hr; 679 HRESULT hr;
668 680
669 base::AutoLock locked(lock_); 681 base::AutoLock locked(lock_);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 D3DBACKBUFFER_TYPE_MONO, 763 D3DBACKBUFFER_TYPE_MONO,
752 dest_surface.Receive()); 764 dest_surface.Receive());
753 if (FAILED(hr)) 765 if (FAILED(hr))
754 return; 766 return;
755 767
756 RECT rect = { 768 RECT rect = {
757 0, 0, 769 0, 0,
758 size.width(), size.height() 770 size.width(), size.height()
759 }; 771 };
760 772
773 static const base::TimeDelta blit_delay = GetBlitDelay();
774 if (blit_delay.ToInternalValue())
775 base::PlatformThread::Sleep(blit_delay);
776
761 { 777 {
762 TRACE_EVENT0("gpu", "Copy"); 778 TRACE_EVENT0("gpu", "Copy");
763 779
764 // Use a simple pixel / vertex shader pair to render a quad that flips the 780 // Use a simple pixel / vertex shader pair to render a quad that flips the
765 // source texture on the vertical axis. 781 // source texture on the vertical axis.
766 IDirect3DSurface9 *default_render_target = NULL; 782 IDirect3DSurface9 *default_render_target = NULL;
767 present_thread_->device()->GetRenderTarget(0, &default_render_target); 783 present_thread_->device()->GetRenderTarget(0, &default_render_target);
768 784
769 present_thread_->device()->SetRenderTarget(0, dest_surface); 785 present_thread_->device()->SetRenderTarget(0, dest_surface);
770 present_thread_->device()->SetTexture(0, source_texture_); 786 present_thread_->device()->SetTexture(0, source_texture_);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 return presenter_->CopyTo(src_subrect, dst_size, buf); 879 return presenter_->CopyTo(src_subrect, dst_size, buf);
864 } 880 }
865 881
866 void AcceleratedSurface::Suspend() { 882 void AcceleratedSurface::Suspend() {
867 presenter_->Suspend(); 883 presenter_->Suspend();
868 } 884 }
869 885
870 void AcceleratedSurface::WasHidden() { 886 void AcceleratedSurface::WasHidden() {
871 presenter_->WasHidden(); 887 presenter_->WasHidden();
872 } 888 }
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