diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 22:07:44 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 22:07:44 +0000 |
commit | c3bf65f5b6c64414996c80cbec80ade3bb6a68f3 (patch) | |
tree | eb12013ef1924927c7eda0b323c440fb8d10de0f /o3d/core/cross/renderer.h | |
parent | 06e8a9d9635872338d5ac9956e24590e2ddcfb9e (diff) | |
download | chromium_src-c3bf65f5b6c64414996c80cbec80ade3bb6a68f3.zip chromium_src-c3bf65f5b6c64414996c80cbec80ade3bb6a68f3.tar.gz chromium_src-c3bf65f5b6c64414996c80cbec80ade3bb6a68f3.tar.bz2 |
Make O3D always clear the backbuffer one way or
another.
The issue is that given that we are using DISCARD
on D3D and on GL we are only drawing to the visible
portion of the O3D area, the state of the backbuffer
is undefined. This change should make it consistent
across platforms.
Review URL: http://codereview.chromium.org/201013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25522 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core/cross/renderer.h')
-rw-r--r-- | o3d/core/cross/renderer.h | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/o3d/core/cross/renderer.h b/o3d/core/cross/renderer.h index 3328e4d..20c6086 100644 --- a/o3d/core/cross/renderer.h +++ b/o3d/core/cross/renderer.h @@ -296,8 +296,11 @@ class Renderer { // surface: RenderSurface to bind to the color buffer. // depth_surface: RenderDepthStencilSurface to bind to the depth/stencil // buffer. + // is_back_buffer: True if the render surface being set should be considered + // the backbuffer. void SetRenderSurfaces(const RenderSurface* surface, - const RenderDepthStencilSurface* depth_surface); + const RenderDepthStencilSurface* depth_surface, + bool is_back_buffer); // Gets the current render surfaces. // Parameters: @@ -305,8 +308,11 @@ class Renderer { // buffer. // depth_surface: pointer to variable to hold RenderDepthStencilSurface to // bind to the depth/stencil buffer. + // is_back_buffer: pointer to variable to hold whether or not the surface + // returned is the back buffer. void GetRenderSurfaces(const RenderSurface** surface, - const RenderDepthStencilSurface** depth_surface); + const RenderDepthStencilSurface** depth_surface, + bool* is_back_buffer); // Creates a StreamBank, returning a platform specific implementation class. virtual StreamBank::Ref CreateStreamBank() = 0; @@ -518,6 +524,14 @@ class Renderer { rendering_ = rendering; } + // Used only by the ColorWriteEnable state handlers. Should not be used + // elsewhere. + // Sets the write mask. This must be called by platform specific renderers + // when the color write mask is changed. + void SetWriteMask(int mask) { + write_mask_ = mask & 0xF; + } + protected: typedef vector_map<String, StateHandler*> StateHandlerMap; typedef std::vector<ParamVector> ParamVectorArray; @@ -618,6 +632,7 @@ class Renderer { // The current render surfaces. NULL = no surface. const RenderSurface* current_render_surface_; const RenderDepthStencilSurface* current_depth_surface_; + bool current_render_surface_is_back_buffer_; Sampler::Ref error_sampler_; // sampler used when one is missing. Texture::Ref error_texture_; // texture used when one is missing. @@ -638,6 +653,10 @@ class Renderer { // State object holding the default state settings. State::Ref default_state_; + // A State object holding the settings required to be able to clear the + // back buffer. + State::Ref clear_back_buffer_state_; + // Lost Resources Callbacks. LostResourcesCallbackManager lost_resources_callback_manager_; @@ -654,6 +673,22 @@ class Renderer { } private: + // Adds the default states to their respective stacks. + void AddDefaultStates(); + + // Removes the default states from their respective stacks. + void RemoveDefaultStates(); + + // Clears the backbuffer. + void ClearBackBuffer(); + + // Clears the backbuffer if it has not been cleared. + void ClearBackBufferIfNotCleared() { + if (!back_buffer_cleared_ && current_render_surface_is_back_buffer_) { + ClearBackBuffer(); + } + } + ServiceLocator* service_locator_; ServiceImplementation<Renderer> service_; ServiceDependency<Features> features_; @@ -664,6 +699,9 @@ class Renderer { // Current depth range. Float2 depth_range_; + // Current write mask. + int write_mask_; + int render_frame_count_; // count of times we've rendered frame. int transforms_processed_; // count of transforms processed this frame. int transforms_culled_; // count of transforms culled this frame. @@ -702,11 +740,8 @@ class Renderer { // Whether or not the underlying API supports non-power-of-two textures. bool supports_npot_; - // Adds the default states to their respective stacks. - void AddDefaultStates(); - - // Removes the default states from their respective stacks. - void RemoveDefaultStates(); + // Whether the backbuffer has been cleared this frame. + bool back_buffer_cleared_; DISALLOW_COPY_AND_ASSIGN(Renderer); }; |