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

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

Issue 8622004: Reland 110355 - Use shared D3D9 texture to transport the compositor's backing buffer to the brows... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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
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
30 const int64 kPollQueryInterval = 1; 33 const int64 kPollQueryInterval = 1;
31 34
35 const wchar_t kD3D9ModuleName[] = L"d3d9.dll";
36 const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex";
37
32 class QuerySyncThread 38 class QuerySyncThread
33 : public base::Thread, 39 : public base::Thread,
34 public base::RefCounted<QuerySyncThread> { 40 public base::RefCounted<QuerySyncThread> {
35 public: 41 public:
36 explicit QuerySyncThread(const char* name); 42 explicit QuerySyncThread(const char* name);
37 virtual ~QuerySyncThread(); 43 virtual ~QuerySyncThread();
38 44
39 // Invoke the completion task when the query completes. 45 // Invoke the completion task when the query completes.
40 void AcknowledgeQuery(const base::win::ScopedComPtr<IDirect3DQuery9>& query, 46 void AcknowledgeQuery(const base::win::ScopedComPtr<IDirect3DQuery9>& query,
41 const base::Closure& completion_task); 47 const base::Closure& completion_task);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 Sleep(0); 329 Sleep(0);
324 } while (hr == S_FALSE); 330 } while (hr == S_FALSE);
325 } 331 }
326 } 332 }
327 333
328 void AcceleratedSurface::DoInitialize() { 334 void AcceleratedSurface::DoInitialize() {
329 TRACE_EVENT0("surface", "DoInitialize"); 335 TRACE_EVENT0("surface", "DoInitialize");
330 336
331 HRESULT hr; 337 HRESULT hr;
332 338
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
333 base::win::ScopedComPtr<IDirect3D9Ex> d3d; 348 base::win::ScopedComPtr<IDirect3D9Ex> d3d;
334 hr = Direct3DCreate9Ex(D3D_SDK_VERSION, d3d.Receive()); 349 hr = create_func(D3D_SDK_VERSION, d3d.Receive());
335 if (FAILED(hr)) 350 if (FAILED(hr))
336 return; 351 return;
337 352
338 D3DPRESENT_PARAMETERS parameters = { 0 }; 353 D3DPRESENT_PARAMETERS parameters = { 0 };
339 parameters.BackBufferWidth = 1; 354 parameters.BackBufferWidth = 1;
340 parameters.BackBufferHeight = 1; 355 parameters.BackBufferHeight = 1;
341 parameters.BackBufferCount = 1; 356 parameters.BackBufferCount = 1;
342 parameters.BackBufferFormat = D3DFMT_A8R8G8B8; 357 parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
343 parameters.hDeviceWindow = window_; 358 parameters.hDeviceWindow = window_;
344 parameters.Windowed = TRUE; 359 parameters.Windowed = TRUE;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 completion_task); 511 completion_task);
497 } 512 }
498 513
499 { 514 {
500 TRACE_EVENT0("surface", "Present"); 515 TRACE_EVENT0("surface", "Present");
501 hr = device_->Present(&rect, &rect, NULL, NULL); 516 hr = device_->Present(&rect, &rect, NULL, NULL);
502 if (FAILED(hr)) 517 if (FAILED(hr))
503 return; 518 return;
504 } 519 }
505 } 520 }
OLDNEW
« content/common/gpu/image_transport_surface.h ('K') | « content/content_common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698