Index: ui/surface/accelerated_surface_win.cc |
diff --git a/ui/surface/accelerated_surface_win.cc b/ui/surface/accelerated_surface_win.cc |
index f4e6c9cbee6c14a7adeb0304aebdc46efa372e9d..1dc36d3922df4a518f1a4178ce2d7ac6c4685222 100644 |
--- a/ui/surface/accelerated_surface_win.cc |
+++ b/ui/surface/accelerated_surface_win.cc |
@@ -37,6 +37,7 @@ const wchar_t kD3D9ModuleName[] = L"d3d9.dll"; |
const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex"; |
const char kGpuBlitDelay[] = "gpu-blit-delay"; |
+const char kUseOcclusionQuery[] = "use-occlusion-query"; |
struct Vertex { |
float x, y, z, w; |
@@ -120,6 +121,10 @@ UINT GetPresentationInterval() { |
return D3DPRESENT_INTERVAL_ONE; |
} |
+bool UsingOcclusionQuery() { |
+ return CommandLine::ForCurrentProcess()->HasSwitch(kUseOcclusionQuery); |
+} |
+ |
// Calculate the number necessary to transform |src_subrect| into |dst_size| |
// by repeating downsampling of the image of |src_subrect| by a factor no more |
// than 2. |
@@ -297,10 +302,18 @@ void PresentThread::ResetDevice() { |
if (FAILED(hr)) |
return; |
- hr = device_->CreateQuery(D3DQUERYTYPE_EVENT, query_.Receive()); |
- if (FAILED(hr)) { |
- device_ = NULL; |
- return; |
+ if (UsingOcclusionQuery()) { |
+ hr = device_->CreateQuery(D3DQUERYTYPE_OCCLUSION, query_.Receive()); |
+ if (FAILED(hr)) { |
+ device_ = NULL; |
+ return; |
+ } |
+ } else { |
+ hr = device_->CreateQuery(D3DQUERYTYPE_EVENT, query_.Receive()); |
+ if (FAILED(hr)) { |
+ device_ = NULL; |
+ return; |
+ } |
} |
base::win::ScopedComPtr<IDirect3DVertexShader9> vertex_shader; |
@@ -801,6 +814,10 @@ void AcceleratedPresenter::DoPresentAndAcknowledge( |
{ halfPixelX - 1, halfPixelY - 1, 0.5f, 1, 0, 0 } |
}; |
+ if (UsingOcclusionQuery()) { |
+ present_thread_->query()->Issue(D3DISSUE_BEGIN); |
+ } |
+ |
present_thread_->device()->BeginScene(); |
present_thread_->device()->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, |
arraysize(vertices), |