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

Side by Side Diff: core/win/d3d9/renderer_d3d9.cc

Issue 155276: Add ClientInfo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 25 matching lines...) Expand all
36 #include "core/win/d3d9/renderer_d3d9.h" 36 #include "core/win/d3d9/renderer_d3d9.h"
37 37
38 #include <vector> 38 #include <vector>
39 #include <d3dx9core.h> 39 #include <d3dx9core.h>
40 40
41 #include "core/cross/ierror_status.h" 41 #include "core/cross/ierror_status.h"
42 #include "core/cross/object_manager.h" 42 #include "core/cross/object_manager.h"
43 #include "core/cross/renderer_platform.h" 43 #include "core/cross/renderer_platform.h"
44 #include "core/cross/semantic_manager.h" 44 #include "core/cross/semantic_manager.h"
45 #include "core/cross/service_dependency.h" 45 #include "core/cross/service_dependency.h"
46 #include "core/cross/client_info.h"
46 #include "core/cross/shape.h" 47 #include "core/cross/shape.h"
47 #include "core/cross/features.h" 48 #include "core/cross/features.h"
48 #include "core/cross/types.h" 49 #include "core/cross/types.h"
49 #include "core/win/d3d9/buffer_d3d9.h" 50 #include "core/win/d3d9/buffer_d3d9.h"
50 #include "core/win/d3d9/d3d_entry_points.h" 51 #include "core/win/d3d9/d3d_entry_points.h"
51 #include "core/win/d3d9/draw_element_d3d9.h" 52 #include "core/win/d3d9/draw_element_d3d9.h"
52 #include "core/win/d3d9/effect_d3d9.h" 53 #include "core/win/d3d9/effect_d3d9.h"
53 #include "core/win/d3d9/param_cache_d3d9.h" 54 #include "core/win/d3d9/param_cache_d3d9.h"
54 #include "core/win/d3d9/primitive_d3d9.h" 55 #include "core/win/d3d9/primitive_d3d9.h"
55 #include "core/win/d3d9/render_surface_d3d9.h" 56 #include "core/win/d3d9/render_surface_d3d9.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // key is non-zero. 360 // key is non-zero.
360 bool IsForceSoftwareRendererEnabled() { 361 bool IsForceSoftwareRendererEnabled() {
361 HKEY key; 362 HKEY key;
362 if (FAILED(RegOpenKeyEx(HKEY_CURRENT_USER, 363 if (FAILED(RegOpenKeyEx(HKEY_CURRENT_USER,
363 TEXT("Software\\Google\\o3d"), 364 TEXT("Software\\Google\\o3d"),
364 0, 365 0,
365 KEY_READ, 366 KEY_READ,
366 &key))) { 367 &key))) {
367 return false; 368 return false;
368 } 369 }
369 370
370 bool enabled = false; 371 bool enabled = false;
371 DWORD type; 372 DWORD type;
372 DWORD value; 373 DWORD value;
373 DWORD size = sizeof(value); 374 DWORD size = sizeof(value);
374 if (SUCCEEDED(RegQueryValueEx(key, 375 if (SUCCEEDED(RegQueryValueEx(key,
375 TEXT("ForceSoftwareRenderer"), 376 TEXT("ForceSoftwareRenderer"),
376 NULL, 377 NULL,
377 &type, 378 &type,
378 reinterpret_cast<LPBYTE>(&value), 379 reinterpret_cast<LPBYTE>(&value),
379 &size))) { 380 &size))) {
(...skipping 11 matching lines...) Expand all
391 // multisampling modes and selects the most advanced one available to create 392 // multisampling modes and selects the most advanced one available to create
392 // a D3D Device with a back buffer containing depth and stencil buffers that 393 // a D3D Device with a back buffer containing depth and stencil buffers that
393 // match the current display device. 394 // match the current display device.
394 Renderer::InitStatus InitializeD3D9Context( 395 Renderer::InitStatus InitializeD3D9Context(
395 HWND window, 396 HWND window,
396 LPDIRECT3D9* d3d, 397 LPDIRECT3D9* d3d,
397 LPDIRECT3DDEVICE9* d3d_device, 398 LPDIRECT3DDEVICE9* d3d_device,
398 D3DPRESENT_PARAMETERS* d3d_present_parameters, 399 D3DPRESENT_PARAMETERS* d3d_present_parameters,
399 bool fullscreen, 400 bool fullscreen,
400 Features* features, 401 Features* features,
402 ServiceLocator* service_locator,
401 int* out_width, 403 int* out_width,
402 int* out_height) { 404 int* out_height) {
403 405
404 // Check registry to see if the developer has opted to force the software 406 // Check registry to see if the developer has opted to force the software
405 // renderer. 407 // renderer.
406 Renderer::InitStatus status_hardware; 408 Renderer::InitStatus status_hardware;
407 if (IsForceSoftwareRendererEnabled()) { 409 if (IsForceSoftwareRendererEnabled()) {
408 // Simulate GPU not up to spec. 410 // Simulate GPU not up to spec.
409 status_hardware = Renderer::GPU_NOT_UP_TO_SPEC; 411 status_hardware = Renderer::GPU_NOT_UP_TO_SPEC;
410 } else { 412 } else {
411 // Create a hardware device. 413 // Create a hardware device.
412 status_hardware = CreateDirect3D(Direct3DCreate9, d3d, features); 414 status_hardware = CreateDirect3D(Direct3DCreate9, d3d, features);
413 } 415 }
414 416
415 if (status_hardware != Renderer::SUCCESS) { 417 if (status_hardware != Renderer::SUCCESS) {
416 Renderer::InitStatus status_software = CreateDirect3D( 418 Renderer::InitStatus status_software = CreateDirect3D(
417 Direct3DCreate9Software, d3d, features); 419 Direct3DCreate9Software, d3d, features);
418 420
419 // We should not be requiring caps that are not supported by the software 421 // We should not be requiring caps that are not supported by the software
420 // renderer. 422 // renderer.
421 DCHECK(status_software != Renderer::GPU_NOT_UP_TO_SPEC); 423 DCHECK(status_software != Renderer::GPU_NOT_UP_TO_SPEC);
422 424
423 if (status_software != Renderer::SUCCESS) { 425 if (status_software != Renderer::SUCCESS) {
424 // Report the hardware error. An error with the software renderer should 426 // Report the hardware error. An error with the software renderer should
425 // only mean that it is not available, which is normal. 427 // only mean that it is not available, which is normal.
426 if (status_hardware == Renderer::INITIALIZATION_ERROR) { 428 if (status_hardware == Renderer::INITIALIZATION_ERROR) {
427 LOG(ERROR) << "Failed to create the initial D3D9 Interface"; 429 LOG(ERROR) << "Failed to create the initial D3D9 Interface";
428 } 430 }
429 return status_hardware; 431 return status_hardware;
430 } 432 }
431 433
432 SetupSoftwareRenderer(*d3d); 434 SetupSoftwareRenderer(*d3d);
435
436 ServiceDependency<ClientInfoManager> client_info_manager(service_locator);
apatrick 2009/07/09 18:22:00 GetService.
437 client_info_manager->SetSoftwareRenderer(true);
433 } 438 }
434 439
435 D3DDISPLAYMODE d3ddm; 440 D3DDISPLAYMODE d3ddm;
436 if (!HR((*d3d)->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) 441 if (!HR((*d3d)->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
437 return Renderer::GPU_NOT_UP_TO_SPEC; 442 return Renderer::GPU_NOT_UP_TO_SPEC;
438 443
439 // NOTE: make sure the backbuffer matches this format, as it is 444 // NOTE: make sure the backbuffer matches this format, as it is
440 // currently assumed to be 32-bit 8X8R8G8B 445 // currently assumed to be 32-bit 8X8R8G8B
441 446
442 ZeroMemory(d3d_present_parameters, sizeof(*d3d_present_parameters)); 447 ZeroMemory(d3d_present_parameters, sizeof(*d3d_present_parameters));
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 int height; 976 int height;
972 d3d_ = NULL; 977 d3d_ = NULL;
973 d3d_device_ = NULL; 978 d3d_device_ = NULL;
974 InitStatus init_status = InitializeD3D9Context( 979 InitStatus init_status = InitializeD3D9Context(
975 window, 980 window,
976 &d3d_, 981 &d3d_,
977 &d3d_device_, 982 &d3d_device_,
978 &d3d_present_parameters_, 983 &d3d_present_parameters_,
979 fullscreen_, 984 fullscreen_,
980 features(), 985 features(),
986 service_locator(),
981 &width, 987 &width,
982 &height); 988 &height);
983 if (init_status != SUCCESS) { 989 if (init_status != SUCCESS) {
984 DLOG(ERROR) << "Failed to initialize D3D9."; 990 DLOG(ERROR) << "Failed to initialize D3D9.";
985 return init_status; 991 return init_status;
986 } 992 }
987 993
988 D3DCAPS9 d3d_caps; 994 D3DCAPS9 d3d_caps;
989 if (!HR(d3d_->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3d_caps))) { 995 if (!HR(d3d_->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3d_caps))) {
990 DLOG(ERROR) << "Failed to get device capabilities."; 996 DLOG(ERROR) << "Failed to get device capabilities.";
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 static int swizzle_table[] = { 2, 1, 0, 3, }; 1785 static int swizzle_table[] = { 2, 1, 0, 3, };
1780 return swizzle_table; 1786 return swizzle_table;
1781 } 1787 }
1782 1788
1783 // This is a factory function for creating Renderer objects. Since 1789 // This is a factory function for creating Renderer objects. Since
1784 // we're implementing D3D9, we only ever return a D3D9 renderer. 1790 // we're implementing D3D9, we only ever return a D3D9 renderer.
1785 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) { 1791 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) {
1786 return RendererD3D9::CreateDefault(service_locator); 1792 return RendererD3D9::CreateDefault(service_locator);
1787 } 1793 }
1788 } // namespace o3d 1794 } // namespace o3d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698