OLD | NEW |
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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 d3d_device_ = NULL; | 1021 d3d_device_ = NULL; |
1022 d3d_ = NULL; | 1022 d3d_ = NULL; |
1023 } | 1023 } |
1024 | 1024 |
1025 void RendererD3D9::PlatformSpecificClear(const Float4 &color, | 1025 void RendererD3D9::PlatformSpecificClear(const Float4 &color, |
1026 bool color_flag, | 1026 bool color_flag, |
1027 float depth, | 1027 float depth, |
1028 bool depth_flag, | 1028 bool depth_flag, |
1029 int stencil, | 1029 int stencil, |
1030 bool stencil_flag) { | 1030 bool stencil_flag) { |
1031 // is this safe to call inside BeginScene/EndScene? | |
1032 CComPtr<IDirect3DSurface9> current_surface; | |
1033 if (!HR(d3d_device()->GetRenderTarget(0, ¤t_surface))) | |
1034 return; | |
1035 | |
1036 CComPtr<IDirect3DSurface9> current_depth_surface; | |
1037 if (!HR(d3d_device()->GetDepthStencilSurface(¤t_depth_surface))) | |
1038 return; | |
1039 | |
1040 // Conditionally clear the properties of the back buffer based on the | 1031 // Conditionally clear the properties of the back buffer based on the |
1041 // argument flags, and the existence of currently bound buffers. | 1032 // argument flags, and the existence of currently bound buffers. |
1042 HR(d3d_device_->Clear( | 1033 if (!HR(d3d_device_->Clear( |
1043 0, | 1034 0, |
1044 NULL, | 1035 NULL, |
1045 ((color_flag && current_surface) ? D3DCLEAR_TARGET : 0) | | 1036 (color_flag ? D3DCLEAR_TARGET : 0) | |
1046 ((depth_flag && current_depth_surface) ? D3DCLEAR_ZBUFFER : 0) | | 1037 (depth_flag ? D3DCLEAR_ZBUFFER : 0) | |
1047 ((stencil_flag && current_depth_surface) ? D3DCLEAR_STENCIL : 0), | 1038 (stencil_flag ? D3DCLEAR_STENCIL : 0), |
1048 D3DCOLOR_COLORVALUE(color[0], | 1039 D3DCOLOR_COLORVALUE(color[0], |
1049 color[1], | 1040 color[1], |
1050 color[2], | 1041 color[2], |
1051 color[3]), | 1042 color[3]), |
1052 depth, | 1043 depth, |
1053 stencil)); | 1044 stencil))) { |
| 1045 DLOG(ERROR) << "Clear Failed."; |
| 1046 } |
1054 } | 1047 } |
1055 | 1048 |
1056 void RendererD3D9::SetViewportInPixels(int left, | 1049 void RendererD3D9::SetViewportInPixels(int left, |
1057 int top, | 1050 int top, |
1058 int width, | 1051 int width, |
1059 int height, | 1052 int height, |
1060 float min_z, | 1053 float min_z, |
1061 float max_z) { | 1054 float max_z) { |
1062 D3DVIEWPORT9 viewport; | 1055 D3DVIEWPORT9 viewport; |
1063 | 1056 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 | 1538 |
1546 void RendererD3D9::SetRenderSurfacesPlatformSpecific( | 1539 void RendererD3D9::SetRenderSurfacesPlatformSpecific( |
1547 const RenderSurface* surface, | 1540 const RenderSurface* surface, |
1548 const RenderDepthStencilSurface* surface_depth) { | 1541 const RenderDepthStencilSurface* surface_depth) { |
1549 const RenderSurfaceD3D9 *d3d_render_surface = | 1542 const RenderSurfaceD3D9 *d3d_render_surface = |
1550 down_cast<const RenderSurfaceD3D9*>(surface); | 1543 down_cast<const RenderSurfaceD3D9*>(surface); |
1551 const RenderDepthStencilSurfaceD3D9 *d3d_render_depth_surface = | 1544 const RenderDepthStencilSurfaceD3D9 *d3d_render_depth_surface = |
1552 down_cast<const RenderDepthStencilSurfaceD3D9*>(surface_depth); | 1545 down_cast<const RenderDepthStencilSurfaceD3D9*>(surface_depth); |
1553 | 1546 |
1554 IDirect3DSurface9 *d3d_surface = | 1547 IDirect3DSurface9 *d3d_surface = |
1555 d3d_render_surface ? d3d_render_surface->GetSurfaceHandle() : NULL; | 1548 d3d_render_surface ? d3d_render_surface->GetSurfaceHandle() : |
| 1549 back_buffer_surface_; |
1556 IDirect3DSurface9 *d3d_depth_surface = d3d_render_depth_surface ? | 1550 IDirect3DSurface9 *d3d_depth_surface = d3d_render_depth_surface ? |
1557 d3d_render_depth_surface->GetSurfaceHandle() : NULL; | 1551 d3d_render_depth_surface->GetSurfaceHandle() : back_buffer_depth_surface_; |
1558 | 1552 |
1559 // At least one of the surfaces must be non-null. | 1553 // At least one of the surfaces must be non-null. |
1560 DCHECK(d3d_surface || d3d_depth_surface); | 1554 DCHECK(d3d_surface || d3d_depth_surface); |
1561 | 1555 |
1562 HR(d3d_device()->SetRenderTarget(0, d3d_surface)); | 1556 HR(d3d_device()->SetRenderTarget(0, d3d_surface)); |
1563 HR(d3d_device()->SetDepthStencilSurface(d3d_depth_surface)); | 1557 HR(d3d_device()->SetDepthStencilSurface(d3d_depth_surface)); |
1564 } | 1558 } |
1565 | 1559 |
1566 void RendererD3D9::SetBackBufferPlatformSpecific() { | 1560 void RendererD3D9::SetBackBufferPlatformSpecific() { |
1567 HR(d3d_device()->SetRenderTarget(0, back_buffer_surface_)); | 1561 HR(d3d_device()->SetRenderTarget(0, back_buffer_surface_)); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 static int swizzle_table[] = { 2, 1, 0, 3, }; | 1649 static int swizzle_table[] = { 2, 1, 0, 3, }; |
1656 return swizzle_table; | 1650 return swizzle_table; |
1657 } | 1651 } |
1658 | 1652 |
1659 // This is a factory function for creating Renderer objects. Since | 1653 // This is a factory function for creating Renderer objects. Since |
1660 // we're implementing D3D9, we only ever return a D3D9 renderer. | 1654 // we're implementing D3D9, we only ever return a D3D9 renderer. |
1661 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) { | 1655 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) { |
1662 return RendererD3D9::CreateDefault(service_locator); | 1656 return RendererD3D9::CreateDefault(service_locator); |
1663 } | 1657 } |
1664 } // namespace o3d | 1658 } // namespace o3d |
OLD | NEW |