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

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

Issue 8625003: Revert 111040 - Reland 110355 - Use shared D3D9 texture to transport the compositor's backing buf... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | « content/content_common.gypi ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gfx/surface/accelerated_surface_win.h" 5 #include "ui/gfx/surface/accelerated_surface_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <list> 9 #include <list>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/tracked_objects.h" 20 #include "base/tracked_objects.h"
21 #include "base/win/wrapped_window_proc.h" 21 #include "base/win/wrapped_window_proc.h"
22 #include "ipc/ipc_message.h" 22 #include "ipc/ipc_message.h"
23 #include "ui/base/win/hwnd_util.h" 23 #include "ui/base/win/hwnd_util.h"
24 #include "ui/gfx/gl/gl_switches.h" 24 #include "ui/gfx/gl/gl_switches.h"
25 25
26 #pragma comment(lib, "d3d9.lib") 26 #pragma comment(lib, "d3d9.lib")
27 27
28 namespace { 28 namespace {
29 29
30 typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT sdk_version,
31 IDirect3D9Ex **d3d);
32
33 const int64 kPollQueryInterval = 1; 30 const int64 kPollQueryInterval = 1;
34 31
35 const wchar_t kD3D9ModuleName[] = L"d3d9.dll";
36 const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex";
37
38 class QuerySyncThread 32 class QuerySyncThread
39 : public base::Thread, 33 : public base::Thread,
40 public base::RefCounted<QuerySyncThread> { 34 public base::RefCounted<QuerySyncThread> {
41 public: 35 public:
42 explicit QuerySyncThread(const char* name); 36 explicit QuerySyncThread(const char* name);
43 virtual ~QuerySyncThread(); 37 virtual ~QuerySyncThread();
44 38
45 // Invoke the completion task when the query completes. 39 // Invoke the completion task when the query completes.
46 void AcknowledgeQuery(const base::win::ScopedComPtr<IDirect3DQuery9>& query, 40 void AcknowledgeQuery(const base::win::ScopedComPtr<IDirect3DQuery9>& query,
47 const base::Closure& completion_task); 41 const base::Closure& completion_task);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 Sleep(0); 323 Sleep(0);
330 } while (hr == S_FALSE); 324 } while (hr == S_FALSE);
331 } 325 }
332 } 326 }
333 327
334 void AcceleratedSurface::DoInitialize() { 328 void AcceleratedSurface::DoInitialize() {
335 TRACE_EVENT0("surface", "DoInitialize"); 329 TRACE_EVENT0("surface", "DoInitialize");
336 330
337 HRESULT hr; 331 HRESULT hr;
338 332
339 HMODULE module = GetModuleHandle(kD3D9ModuleName);
340 if (!module)
341 return;
342
343 Direct3DCreate9ExFunc create_func = reinterpret_cast<Direct3DCreate9ExFunc>(
344 GetProcAddress(module, kCreate3D9DeviceExName));
345 if (!create_func)
346 return;
347
348 base::win::ScopedComPtr<IDirect3D9Ex> d3d; 333 base::win::ScopedComPtr<IDirect3D9Ex> d3d;
349 hr = create_func(D3D_SDK_VERSION, d3d.Receive()); 334 hr = Direct3DCreate9Ex(D3D_SDK_VERSION, d3d.Receive());
350 if (FAILED(hr)) 335 if (FAILED(hr))
351 return; 336 return;
352 337
353 D3DPRESENT_PARAMETERS parameters = { 0 }; 338 D3DPRESENT_PARAMETERS parameters = { 0 };
354 parameters.BackBufferWidth = 1; 339 parameters.BackBufferWidth = 1;
355 parameters.BackBufferHeight = 1; 340 parameters.BackBufferHeight = 1;
356 parameters.BackBufferCount = 1; 341 parameters.BackBufferCount = 1;
357 parameters.BackBufferFormat = D3DFMT_A8R8G8B8; 342 parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
358 parameters.hDeviceWindow = window_; 343 parameters.hDeviceWindow = window_;
359 parameters.Windowed = TRUE; 344 parameters.Windowed = TRUE;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 completion_task); 496 completion_task);
512 } 497 }
513 498
514 { 499 {
515 TRACE_EVENT0("surface", "Present"); 500 TRACE_EVENT0("surface", "Present");
516 hr = device_->Present(&rect, &rect, NULL, NULL); 501 hr = device_->Present(&rect, &rect, NULL, NULL);
517 if (FAILED(hr)) 502 if (FAILED(hr))
518 return; 503 return;
519 } 504 }
520 } 505 }
OLDNEW
« no previous file with comments | « content/content_common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698