summaryrefslogtreecommitdiffstats
path: root/ui/surface/d3d9_utils_win.cc
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 07:05:38 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 07:05:38 +0000
commit9e008aff45ca1883f033a734617b745bbb50a6a9 (patch)
tree6050a82fced1386198b4f8581a4194561791caf7 /ui/surface/d3d9_utils_win.cc
parente8b0118bc21107e0d3955b80542b0368e0e139f8 (diff)
downloadchromium_src-9e008aff45ca1883f033a734617b745bbb50a6a9.zip
chromium_src-9e008aff45ca1883f033a734617b745bbb50a6a9.tar.gz
chromium_src-9e008aff45ca1883f033a734617b745bbb50a6a9.tar.bz2
Revert 174338
The newly added tests failing on the tree: http://build.chromium.org/p/chromium.win/builders/Vista%20Tests%20%283%29/builds/25653 > [ui/surface] Separate image processing logic from presentation logic. > > The D3D image processing code from AcceleratedPresenter moves to its own class, "ui/surface/accelerated_surface_transformer_win.h". This split allows the image processing code to be tested independently of the present-scheduling system, and so we add unit tests doing exactly that. Utility functions (loading d3d, creating temp surfaces) doing things commonly required by test, transform, and present code -- these functions are moved to a third location, "ui/surface/d3d9_utils_win.h" > > The new unit tests -- which live in the ui_unittests binary -- make extensive use of pseudorandom image content, which I think is kind of neat. The tests use D3D HAL devices; I tried to use REF, but it didn't work, as StretchRect+LINEAR is not supported by refrast. So as a result we may have a GPU vendor dependency in these results. > > BUG=161537 > TEST=new ui_unittests > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=174028 > > Review URL: https://chromiumcodereview.appspot.com/11464017 TBR=nick@chromium.org Review URL: https://codereview.chromium.org/11667003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174345 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/surface/d3d9_utils_win.cc')
-rw-r--r--ui/surface/d3d9_utils_win.cc119
1 files changed, 0 insertions, 119 deletions
diff --git a/ui/surface/d3d9_utils_win.cc b/ui/surface/d3d9_utils_win.cc
deleted file mode 100644
index 85dc668..0000000
--- a/ui/surface/d3d9_utils_win.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/surface/d3d9_utils_win.h"
-
-#include "base/file_path.h"
-#include "base/scoped_native_library.h"
-#include "base/win/scoped_comptr.h"
-#include "ui/gfx/size.h"
-
-namespace {
-
-const wchar_t kD3D9ModuleName[] = L"d3d9.dll";
-const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex";
-typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT sdk_version,
- IDirect3D9Ex **d3d);
-} // namespace
-
-namespace ui_surface_d3d9_utils {
-
-bool LoadD3D9(base::ScopedNativeLibrary* storage) {
- storage->Reset(base::LoadNativeLibrary(FilePath(kD3D9ModuleName), NULL));
- return storage->is_valid();
-}
-
-bool CreateDevice(const base::ScopedNativeLibrary& d3d_module,
- D3DDEVTYPE device_type,
- uint32 presentation_interval,
- IDirect3DDevice9Ex** device) {
-
- Direct3DCreate9ExFunc create_func = reinterpret_cast<Direct3DCreate9ExFunc>(
- d3d_module.GetFunctionPointer(kCreate3D9DeviceExName));
- if (!create_func)
- return false;
-
- base::win::ScopedComPtr<IDirect3D9Ex> d3d;
- HRESULT hr = create_func(D3D_SDK_VERSION, d3d.Receive());
- if (FAILED(hr))
- return false;
-
- // Any old window will do to create the device. In practice the window to
- // present to is an argument to IDirect3DDevice9::Present.
- HWND window = GetShellWindow();
-
- D3DPRESENT_PARAMETERS parameters = { 0 };
- parameters.BackBufferWidth = 1;
- parameters.BackBufferHeight = 1;
- parameters.BackBufferCount = 1;
- parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
- parameters.hDeviceWindow = window;
- parameters.Windowed = TRUE;
- parameters.Flags = 0;
- parameters.PresentationInterval = presentation_interval;
- parameters.SwapEffect = D3DSWAPEFFECT_COPY;
-
- hr = d3d->CreateDeviceEx(
- D3DADAPTER_DEFAULT,
- device_type,
- window,
- D3DCREATE_FPU_PRESERVE | D3DCREATE_SOFTWARE_VERTEXPROCESSING |
- D3DCREATE_DISABLE_PSGP_THREADING | D3DCREATE_MULTITHREADED,
- &parameters,
- NULL,
- device);
- return SUCCEEDED(hr);
-}
-
-bool OpenSharedTexture(IDirect3DDevice9* device,
- int64 surface_handle,
- const gfx::Size& size,
- IDirect3DTexture9** opened_texture) {
- HANDLE handle = reinterpret_cast<HANDLE>(surface_handle);
- HRESULT hr = device->CreateTexture(size.width(),
- size.height(),
- 1,
- D3DUSAGE_RENDERTARGET,
- D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT,
- opened_texture,
- &handle);
- return SUCCEEDED(hr);
-}
-
-bool CreateTemporaryLockableSurface(IDirect3DDevice9* device,
- const gfx::Size& size,
- IDirect3DSurface9** surface) {
- HRESULT hr = device->CreateRenderTarget(
- size.width(),
- size.height(),
- D3DFMT_A8R8G8B8,
- D3DMULTISAMPLE_NONE,
- 0,
- TRUE,
- surface,
- NULL);
- return SUCCEEDED(hr);
-}
-
-bool CreateTemporaryRenderTargetTexture(IDirect3DDevice9* device,
- const gfx::Size& size,
- IDirect3DTexture9** texture,
- IDirect3DSurface9** render_target) {
- HRESULT hr = device->CreateTexture(
- size.width(),
- size.height(),
- 1, // Levels
- D3DUSAGE_RENDERTARGET,
- D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT,
- texture,
- NULL);
- if (!SUCCEEDED(hr))
- return false;
- hr = (*texture)->GetSurfaceLevel(0, render_target);
- return SUCCEEDED(hr);
-}
-
-} // namespace ui_surface_d3d9_utils