summaryrefslogtreecommitdiffstats
path: root/o3d/command_buffer
diff options
context:
space:
mode:
authorrlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:02:28 +0000
committerrlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:02:28 +0000
commit910a39ca11c5cfa20cb03e408586b63d3ac321d8 (patch)
treebcfbfe7891ca14063d6a5c1bd2de466bea1b5681 /o3d/command_buffer
parent1bdffff7418eec3f0cac4385078484628a9ed35e (diff)
downloadchromium_src-910a39ca11c5cfa20cb03e408586b63d3ac321d8.zip
chromium_src-910a39ca11c5cfa20cb03e408586b63d3ac321d8.tar.gz
chromium_src-910a39ca11c5cfa20cb03e408586b63d3ac321d8.tar.bz2
Review URL: http://codereview.chromium.org/176026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/command_buffer')
-rw-r--r--o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc86
-rw-r--r--o3d/command_buffer/service/win/d3d9/render_surface_d3d9.h91
2 files changed, 129 insertions, 48 deletions
diff --git a/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc b/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc
index 7be89d4..987eceb 100644
--- a/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc
+++ b/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc
@@ -33,6 +33,7 @@
// This file implements the D3D9 versions of the render surface resources,
// as well as the related GAPID3D9 function implementations.
+#include "command_buffer/service/win/d3d9/render_surface_d3d9.h"
#include "command_buffer/service/win/d3d9/gapi_d3d9.h"
#include "command_buffer/service/win/d3d9/texture_d3d9.h"
@@ -45,44 +46,63 @@ RenderSurfaceD3D9::RenderSurfaceD3D9(int width,
int mip_level,
int side,
TextureD3D9 *texture,
- IDirect3DSurface9* direct3d_surface)
- : width_(width), height_(height), mip_level_(mip_level), texture_(texture),
- direct3d_surface_(direct3d_surface) {
+ IDirect3DSurface9 *direct3d_surface)
+ : width_(width),
+ height_(height),
+ mip_level_(mip_level),
+ texture_(texture),
+ direct3d_surface_(direct3d_surface) {
+ DCHECK_GT(width, 0);
+ DCHECK_GT(height, 0);
+ DCHECK_GT(mip_level, -1);
+ DCHECK(texture);
}
RenderSurfaceD3D9* RenderSurfaceD3D9::Create(GAPID3D9 *gapi,
- int width,
- int height,
- int mip_level,
- int side,
- TextureD3D9 *texture) {
+ int width,
+ int height,
+ int mip_level,
+ int side,
+ TextureD3D9 *texture) {
+ DCHECK(gapi);
DCHECK_GT(width, 0);
DCHECK_GT(height, 0);
+ DCHECK_GT(mip_level, -1);
+ DCHECK(texture);
CComPtr<IDirect3DSurface9> direct3d_surface_handle;
bool success =
- texture->CreateRenderSurface(width, height, mip_level, side,
- &direct3d_surface_handle);
+ texture->CreateRenderSurface(width, height, mip_level, side,
+ &direct3d_surface_handle);
if (!success || direct3d_surface_handle == NULL) {
// If the surface was not created properly, delete and return nothing.
return NULL;
}
- RenderSurfaceD3D9* render_surface =
- new RenderSurfaceD3D9(width, height, mip_level, side, texture,
- direct3d_surface_handle);
+ RenderSurfaceD3D9 *render_surface =
+ new RenderSurfaceD3D9(width,
+ height,
+ mip_level,
+ side,
+ texture,
+ direct3d_surface_handle);
return render_surface;
}
RenderDepthStencilSurfaceD3D9::RenderDepthStencilSurfaceD3D9(
int width,
int height,
- IDirect3DSurface9* direct3d_surface)
- : width_(width), height_(height), direct3d_surface_(direct3d_surface) {
+ IDirect3DSurface9 *direct3d_surface)
+ : width_(width),
+ height_(height),
+ direct3d_surface_(direct3d_surface) {
+ DCHECK_GT(width, 0);
+ DCHECK_GT(height, 0);
}
RenderDepthStencilSurfaceD3D9* RenderDepthStencilSurfaceD3D9::Create(
GAPID3D9 *gapi,
int width,
int height) {
+ DCHECK(gapi);
DCHECK_GT(width, 0);
DCHECK_GT(height, 0);
@@ -90,20 +110,22 @@ RenderDepthStencilSurfaceD3D9* RenderDepthStencilSurfaceD3D9::Create(
gapi->d3d_device()->CreateDepthStencilSurface(
width,
height,
- D3DFMT_D24S8,
- D3DMULTISAMPLE_NONE,
- 0,
- FALSE,
+ D3DFMT_D24S8, // d3d format
+ D3DMULTISAMPLE_NONE, // multisampling type
+ 0, // multisample quality level
+ FALSE, // z-buffer discarding disabled
&direct3d_surface,
- NULL);
+ NULL); // This parameter is required to be NULL.
if (direct3d_surface == NULL) {
return NULL;
}
- RenderDepthStencilSurfaceD3D9* depth_stencil =
+ RenderDepthStencilSurfaceD3D9 *depth_stencil =
new RenderDepthStencilSurfaceD3D9(width, height, direct3d_surface);
return depth_stencil;
}
+// GAPI Interface functions ---------------------------------------------------
+
// Copies the data from a texture resource.
BufferSyncInterface::ParseError GAPID3D9::CreateRenderSurface(
ResourceID id,
@@ -120,7 +142,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateRenderSurface(
if (!texture->render_surfaces_enabled()) {
return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
} else {
- RenderSurfaceD3D9* render_surface = RenderSurfaceD3D9::Create(this,
+ RenderSurfaceD3D9 *render_surface = RenderSurfaceD3D9::Create(this,
width,
height,
mip_level,
@@ -139,8 +161,8 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyRenderSurface(ResourceID id) {
return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
}
return render_surfaces_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::PARSE_NO_ERROR :
+ BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
}
BufferSyncInterface::ParseError GAPID3D9::CreateDepthSurface(
@@ -151,7 +173,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateDepthSurface(
// This will delete the current surface which would be bad.
return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
}
- RenderDepthStencilSurfaceD3D9* depth_surface =
+ RenderDepthStencilSurfaceD3D9 *depth_surface =
RenderDepthStencilSurfaceD3D9::Create(this, width, height);
if (depth_surface == NULL) {
return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
@@ -165,26 +187,26 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyDepthSurface(ResourceID id) {
return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
}
return depth_surfaces_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::PARSE_NO_ERROR :
+ BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
}
BufferSyncInterface::ParseError GAPID3D9::SetRenderSurface(
ResourceID render_surface_id,
ResourceID depth_stencil_id) {
RenderSurfaceD3D9 *d3d_render_surface =
- render_surfaces_.Get(render_surface_id);
+ render_surfaces_.Get(render_surface_id);
RenderDepthStencilSurfaceD3D9 *d3d_render_depth_surface =
- depth_surfaces_.Get(depth_stencil_id);
+ depth_surfaces_.Get(depth_stencil_id);
if (d3d_render_surface == NULL && d3d_render_depth_surface == NULL) {
return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
}
IDirect3DSurface9 *d3d_surface =
- d3d_render_surface ? d3d_render_surface->GetSurfaceHandle() : NULL;
+ d3d_render_surface ? d3d_render_surface->direct3d_surface() : NULL;
IDirect3DSurface9 *d3d_depth_surface = d3d_render_depth_surface ?
- d3d_render_depth_surface->GetSurfaceHandle() : NULL;
+ d3d_render_depth_surface->direct3d_surface() : NULL;
// Get the device and set the render target and the depth stencil surface.
IDirect3DDevice9 *device = this->d3d_device();
@@ -199,7 +221,7 @@ BufferSyncInterface::ParseError GAPID3D9::SetRenderSurface(
void GAPID3D9::SetBackSurfaces() {
// Get the device and set the render target and the depth stencil surface.
IDirect3DDevice9 *device = this->d3d_device();
- HR(d3d_device()->SetRenderTarget(0, back_buffer_surface_));
+ HR(d3d_device()->SetRenderTarget(0, back_buffer_surface_));
HR(d3d_device()->SetDepthStencilSurface(back_buffer_depth_surface_));
}
diff --git a/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.h b/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.h
index e9d8614..428c718 100644
--- a/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.h
+++ b/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.h
@@ -37,61 +37,120 @@
// render surface-related resource classes.
#include <d3d9.h>
+#include "base/scoped_ptr.h"
#include "command_buffer/common/cross/gapi_interface.h"
-#include "command_buffer/service/win/d3d9/d3d9_utils.h"
#include "command_buffer/service/cross/resource.h"
+#include "command_buffer/service/win/d3d9/d3d9_utils.h"
+#include "command_buffer/service/win/d3d9/texture_d3d9.h"
namespace o3d {
namespace command_buffer {
class GAPID3D9;
+// The RenderSurfaceD3D class represents a render surface resource in the d3d
+// backend of the command buffer server.
class RenderSurfaceD3D9 : public RenderSurface {
public:
+
+ // Creates a render surface resource based on D3D.
+ // Parameters:
+ // width - width of the surface to be created. Must match width of texture
+ // at mip_level.
+ // height - height of the surface to be created. Must match width of
+ // texture at mip_level.
+ // mip_level - mip level of the texture to which the render surface maps.
+ // side - side of a cube if texture is a cube texture. Does not apply to
+ // texture 2d's.
+ // texture - the texture to which this render surface maps. Not owned by
+ // the RenderSurfaceD3D9.
+ // direct3d_surface - a surface to be used as this render surface's
+ // rendering surface. The new RenderSurfaceD3D9 will own the
+ // direct3d_surface.
RenderSurfaceD3D9(int width,
int height,
int mip_level,
int side,
- TextureD3D9 *texture,
- IDirect3DSurface9* direct3d_surface);
+ TextureD3D9 *texture,
+ IDirect3DSurface9 *direct3d_surface);
+
+ // Destructor for the render surface.
virtual ~RenderSurfaceD3D9() {}
+ // Performs the setup necessary to create a render surface resource based on
+ // D3D and returns a new one if possibe.
+ // Parameters:
+ // gapi - the gapi interface to D3D.
+ // width - width of the surface to be created. Must match width of texture
+ // at mip_level.
+ // height - height of the surface to be created. Must match width of
+ // texture at mip_level.
+ // mip_level - mip level of the texture to which the render surface maps.
+ // side - side of a cube if texture is a cube texture. Does not apply to
+ // texture 2d's.
+ // texture - the texture to which this render surface maps.
+ // Returns:
+ // a new RenderSurfaceD3D9 or NULL on failure
static RenderSurfaceD3D9* Create(GAPID3D9 *gapi,
int width,
int height,
int mip_level,
int side,
TextureD3D9 *texture);
- IDirect3DSurface9* GetSurfaceHandle() const {
+
+ // Returns a reference to the actual direct3d surface that is rendered to.
+ IDirect3DSurface9* direct3d_surface() const {
return direct3d_surface_;
}
private:
CComPtr<IDirect3DSurface9> direct3d_surface_;
- unsigned int width_;
- unsigned int height_;
- unsigned int mip_level_;
- TextureD3D9* texture_;
+ int width_;
+ int height_;
+ int mip_level_;
+ TextureD3D9 *texture_;
DISALLOW_COPY_AND_ASSIGN(RenderSurfaceD3D9);
};
+// The RenderDepthStencilSurfaceD3D class represents a depth stencil surface
+// resource in the d3d backend of the command buffer server.
class RenderDepthStencilSurfaceD3D9 : public RenderDepthStencilSurface {
public:
+
+ // Creates a depth stencil surface resource based on D3D.
+ // Parameters:
+ // width - width of the surface to be created.
+ // height - height of the surface to be created.
+ // direct3d_surface - a surface to be used as this depth stencil surface's
+ // rendering rendering surface. The new RenderDepthStencilSurfaceD3D9
+ // will own the direct3d_surface.
RenderDepthStencilSurfaceD3D9(int width,
int height,
- IDirect3DSurface9* direct3d_surface);
+ IDirect3DSurface9 *direct3d_surface);
+
+ // Destructor for the depth stencil surface.
virtual ~RenderDepthStencilSurfaceD3D9() {}
- static RenderDepthStencilSurfaceD3D9* Create(
- GAPID3D9 *gapi,
- int width,
- int height);
- IDirect3DSurface9* GetSurfaceHandle() const {
+
+ // Performs the setup necessary to create a depth stencil surface resource
+ // based on D3D and returns a new one if possibe.
+ // Parameters:
+ // gapi - the gapi interface to D3D.
+ // width - width of the surface to be created.
+ // height - height of the surface to be created.
+ // Returns:
+ // a new RenderDepthStencilSurfaceD3D9 or NULL on failure.
+ static RenderDepthStencilSurfaceD3D9* Create(GAPID3D9 *gapi,
+ int width,
+ int height);
+
+ // Returns a reference to the actual direct3d surface that is rendered to.
+ IDirect3DSurface9* direct3d_surface() const {
return direct3d_surface_;
}
private:
CComPtr<IDirect3DSurface9> direct3d_surface_;
- unsigned int width_;
- unsigned int height_;
+ int width_;
+ int height_;
DISALLOW_COPY_AND_ASSIGN(RenderDepthStencilSurfaceD3D9);
};