michael@0: #include "precompiled.h" michael@0: // michael@0: // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // Blit.cpp: Surface copy utility class. michael@0: michael@0: #include "libGLESv2/renderer/Blit.h" michael@0: michael@0: #include "libGLESv2/main.h" michael@0: #include "libGLESv2/renderer/renderer9_utils.h" michael@0: #include "libGLESv2/renderer/TextureStorage9.h" michael@0: #include "libGLESv2/renderer/RenderTarget9.h" michael@0: #include "libGLESv2/renderer/Renderer9.h" michael@0: #include "libGLESv2/Framebuffer.h" michael@0: #include "libGLESv2/Renderbuffer.h" michael@0: michael@0: namespace michael@0: { michael@0: #include "libGLESv2/renderer/shaders/compiled/standardvs.h" michael@0: #include "libGLESv2/renderer/shaders/compiled/flipyvs.h" michael@0: #include "libGLESv2/renderer/shaders/compiled/passthroughps.h" michael@0: #include "libGLESv2/renderer/shaders/compiled/luminanceps.h" michael@0: #include "libGLESv2/renderer/shaders/compiled/componentmaskps.h" michael@0: michael@0: const BYTE* const g_shaderCode[] = michael@0: { michael@0: g_vs20_standardvs, michael@0: g_vs20_flipyvs, michael@0: g_ps20_passthroughps, michael@0: g_ps20_luminanceps, michael@0: g_ps20_componentmaskps michael@0: }; michael@0: michael@0: const size_t g_shaderSize[] = michael@0: { michael@0: sizeof(g_vs20_standardvs), michael@0: sizeof(g_vs20_flipyvs), michael@0: sizeof(g_ps20_passthroughps), michael@0: sizeof(g_ps20_luminanceps), michael@0: sizeof(g_ps20_componentmaskps) michael@0: }; michael@0: } michael@0: michael@0: namespace rx michael@0: { michael@0: Blit::Blit(rx::Renderer9 *renderer) michael@0: : mRenderer(renderer), mQuadVertexBuffer(NULL), mQuadVertexDeclaration(NULL), mSavedStateBlock(NULL), mSavedRenderTarget(NULL), mSavedDepthStencil(NULL) michael@0: { michael@0: initGeometry(); michael@0: memset(mCompiledShaders, 0, sizeof(mCompiledShaders)); michael@0: } michael@0: michael@0: Blit::~Blit() michael@0: { michael@0: if (mSavedStateBlock) mSavedStateBlock->Release(); michael@0: if (mQuadVertexBuffer) mQuadVertexBuffer->Release(); michael@0: if (mQuadVertexDeclaration) mQuadVertexDeclaration->Release(); michael@0: michael@0: for (int i = 0; i < SHADER_COUNT; i++) michael@0: { michael@0: if (mCompiledShaders[i]) michael@0: { michael@0: mCompiledShaders[i]->Release(); michael@0: } michael@0: } michael@0: } michael@0: michael@0: void Blit::initGeometry() michael@0: { michael@0: static const float quad[] = michael@0: { michael@0: -1, -1, michael@0: -1, 1, michael@0: 1, -1, michael@0: 1, 1 michael@0: }; michael@0: michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: HRESULT result = device->CreateVertexBuffer(sizeof(quad), D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &mQuadVertexBuffer, NULL); michael@0: michael@0: if (FAILED(result)) michael@0: { michael@0: ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); michael@0: return gl::error(GL_OUT_OF_MEMORY); michael@0: } michael@0: michael@0: void *lockPtr = NULL; michael@0: result = mQuadVertexBuffer->Lock(0, 0, &lockPtr, 0); michael@0: michael@0: if (FAILED(result) || lockPtr == NULL) michael@0: { michael@0: ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); michael@0: return gl::error(GL_OUT_OF_MEMORY); michael@0: } michael@0: michael@0: memcpy(lockPtr, quad, sizeof(quad)); michael@0: mQuadVertexBuffer->Unlock(); michael@0: michael@0: static const D3DVERTEXELEMENT9 elements[] = michael@0: { michael@0: { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, michael@0: D3DDECL_END() michael@0: }; michael@0: michael@0: result = device->CreateVertexDeclaration(elements, &mQuadVertexDeclaration); michael@0: michael@0: if (FAILED(result)) michael@0: { michael@0: ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); michael@0: return gl::error(GL_OUT_OF_MEMORY); michael@0: } michael@0: } michael@0: michael@0: template michael@0: bool Blit::setShader(ShaderId source, const char *profile, michael@0: D3DShaderType *(rx::Renderer9::*createShader)(const DWORD *, size_t length), michael@0: HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*)) michael@0: { michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: D3DShaderType *shader; michael@0: michael@0: if (mCompiledShaders[source] != NULL) michael@0: { michael@0: shader = static_cast(mCompiledShaders[source]); michael@0: } michael@0: else michael@0: { michael@0: const BYTE* shaderCode = g_shaderCode[source]; michael@0: size_t shaderSize = g_shaderSize[source]; michael@0: michael@0: shader = (mRenderer->*createShader)(reinterpret_cast(shaderCode), shaderSize); michael@0: if (!shader) michael@0: { michael@0: ERR("Failed to create shader for blit operation"); michael@0: return false; michael@0: } michael@0: michael@0: mCompiledShaders[source] = shader; michael@0: } michael@0: michael@0: HRESULT hr = (device->*setShader)(shader); michael@0: michael@0: if (FAILED(hr)) michael@0: { michael@0: ERR("Failed to set shader for blit operation"); michael@0: return false; michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool Blit::setVertexShader(ShaderId shader) michael@0: { michael@0: return setShader(shader, "vs_2_0", &rx::Renderer9::createVertexShader, &IDirect3DDevice9::SetVertexShader); michael@0: } michael@0: michael@0: bool Blit::setPixelShader(ShaderId shader) michael@0: { michael@0: return setShader(shader, "ps_2_0", &rx::Renderer9::createPixelShader, &IDirect3DDevice9::SetPixelShader); michael@0: } michael@0: michael@0: RECT Blit::getSurfaceRect(IDirect3DSurface9 *surface) const michael@0: { michael@0: D3DSURFACE_DESC desc; michael@0: surface->GetDesc(&desc); michael@0: michael@0: RECT rect; michael@0: rect.left = 0; michael@0: rect.top = 0; michael@0: rect.right = desc.Width; michael@0: rect.bottom = desc.Height; michael@0: michael@0: return rect; michael@0: } michael@0: michael@0: bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) michael@0: { michael@0: IDirect3DTexture9 *texture = copySurfaceToTexture(source, getSurfaceRect(source)); michael@0: if (!texture) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: saveState(); michael@0: michael@0: device->SetTexture(0, texture); michael@0: device->SetRenderTarget(0, dest); michael@0: michael@0: setVertexShader(SHADER_VS_STANDARD); michael@0: setPixelShader(SHADER_PS_PASSTHROUGH); michael@0: michael@0: setCommonBlitState(); michael@0: device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); michael@0: device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); michael@0: michael@0: setViewport(getSurfaceRect(dest), 0, 0); michael@0: michael@0: render(); michael@0: michael@0: texture->Release(); michael@0: michael@0: restoreState(); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool Blit::copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level) michael@0: { michael@0: RenderTarget9 *renderTarget = NULL; michael@0: IDirect3DSurface9 *source = NULL; michael@0: gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0); michael@0: michael@0: if (colorbuffer) michael@0: { michael@0: renderTarget = RenderTarget9::makeRenderTarget9(colorbuffer->getRenderTarget()); michael@0: } michael@0: michael@0: if (renderTarget) michael@0: { michael@0: source = renderTarget->getSurface(); michael@0: } michael@0: michael@0: if (!source) michael@0: { michael@0: ERR("Failed to retrieve the render target."); michael@0: return gl::error(GL_OUT_OF_MEMORY, false); michael@0: } michael@0: michael@0: TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage->getStorageInstance()); michael@0: IDirect3DSurface9 *destSurface = storage9->getSurfaceLevel(level, true); michael@0: bool result = false; michael@0: michael@0: if (destSurface) michael@0: { michael@0: result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface); michael@0: destSurface->Release(); michael@0: } michael@0: michael@0: source->Release(); michael@0: return result; michael@0: } michael@0: michael@0: bool Blit::copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level) michael@0: { michael@0: RenderTarget9 *renderTarget = NULL; michael@0: IDirect3DSurface9 *source = NULL; michael@0: gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0); michael@0: michael@0: if (colorbuffer) michael@0: { michael@0: renderTarget = RenderTarget9::makeRenderTarget9(colorbuffer->getRenderTarget()); michael@0: } michael@0: michael@0: if (renderTarget) michael@0: { michael@0: source = renderTarget->getSurface(); michael@0: } michael@0: michael@0: if (!source) michael@0: { michael@0: ERR("Failed to retrieve the render target."); michael@0: return gl::error(GL_OUT_OF_MEMORY, false); michael@0: } michael@0: michael@0: TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage->getStorageInstance()); michael@0: IDirect3DSurface9 *destSurface = storage9->getCubeMapSurface(target, level, true); michael@0: bool result = false; michael@0: michael@0: if (destSurface) michael@0: { michael@0: result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface); michael@0: destSurface->Release(); michael@0: } michael@0: michael@0: source->Release(); michael@0: return result; michael@0: } michael@0: michael@0: bool Blit::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest) michael@0: { michael@0: if (!dest) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: D3DSURFACE_DESC sourceDesc; michael@0: D3DSURFACE_DESC destDesc; michael@0: source->GetDesc(&sourceDesc); michael@0: dest->GetDesc(&destDesc); michael@0: michael@0: if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET && michael@0: d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat)) // Can use StretchRect michael@0: { michael@0: RECT destRect = {xoffset, yoffset, xoffset + (sourceRect.right - sourceRect.left), yoffset + (sourceRect.bottom - sourceRect.top)}; michael@0: HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT); michael@0: michael@0: if (FAILED(result)) michael@0: { michael@0: ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); michael@0: return gl::error(GL_OUT_OF_MEMORY, false); michael@0: } michael@0: } michael@0: else michael@0: { michael@0: return formatConvert(source, sourceRect, destFormat, xoffset, yoffset, dest); michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: bool Blit::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest) michael@0: { michael@0: IDirect3DTexture9 *texture = copySurfaceToTexture(source, sourceRect); michael@0: if (!texture) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: saveState(); michael@0: michael@0: device->SetTexture(0, texture); michael@0: device->SetRenderTarget(0, dest); michael@0: michael@0: setViewport(sourceRect, xoffset, yoffset); michael@0: michael@0: setCommonBlitState(); michael@0: if (setFormatConvertShaders(destFormat)) michael@0: { michael@0: render(); michael@0: } michael@0: michael@0: texture->Release(); michael@0: michael@0: restoreState(); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool Blit::setFormatConvertShaders(GLenum destFormat) michael@0: { michael@0: bool okay = setVertexShader(SHADER_VS_STANDARD); michael@0: michael@0: switch (destFormat) michael@0: { michael@0: default: UNREACHABLE(); michael@0: case GL_RGBA: michael@0: case GL_BGRA_EXT: michael@0: case GL_RGB: michael@0: case GL_ALPHA: michael@0: okay = okay && setPixelShader(SHADER_PS_COMPONENTMASK); michael@0: break; michael@0: michael@0: case GL_LUMINANCE: michael@0: case GL_LUMINANCE_ALPHA: michael@0: okay = okay && setPixelShader(SHADER_PS_LUMINANCE); michael@0: break; michael@0: } michael@0: michael@0: if (!okay) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: enum { X = 0, Y = 1, Z = 2, W = 3 }; michael@0: michael@0: // The meaning of this constant depends on the shader that was selected. michael@0: // See the shader assembly code above for details. michael@0: float psConst0[4] = { 0, 0, 0, 0 }; michael@0: michael@0: switch (destFormat) michael@0: { michael@0: default: UNREACHABLE(); michael@0: case GL_RGBA: michael@0: case GL_BGRA_EXT: michael@0: psConst0[X] = 1; michael@0: psConst0[Z] = 1; michael@0: break; michael@0: michael@0: case GL_RGB: michael@0: psConst0[X] = 1; michael@0: psConst0[W] = 1; michael@0: break; michael@0: michael@0: case GL_ALPHA: michael@0: psConst0[Z] = 1; michael@0: break; michael@0: michael@0: case GL_LUMINANCE: michael@0: psConst0[Y] = 1; michael@0: break; michael@0: michael@0: case GL_LUMINANCE_ALPHA: michael@0: psConst0[X] = 1; michael@0: break; michael@0: } michael@0: michael@0: mRenderer->getDevice()->SetPixelShaderConstantF(0, psConst0, 1); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect) michael@0: { michael@0: if (!surface) michael@0: { michael@0: return NULL; michael@0: } michael@0: michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: D3DSURFACE_DESC sourceDesc; michael@0: surface->GetDesc(&sourceDesc); michael@0: michael@0: // Copy the render target into a texture michael@0: IDirect3DTexture9 *texture; michael@0: HRESULT result = device->CreateTexture(sourceRect.right - sourceRect.left, sourceRect.bottom - sourceRect.top, 1, D3DUSAGE_RENDERTARGET, sourceDesc.Format, D3DPOOL_DEFAULT, &texture, NULL); michael@0: michael@0: if (FAILED(result)) michael@0: { michael@0: ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); michael@0: return gl::error(GL_OUT_OF_MEMORY, (IDirect3DTexture9*)NULL); michael@0: } michael@0: michael@0: IDirect3DSurface9 *textureSurface; michael@0: result = texture->GetSurfaceLevel(0, &textureSurface); michael@0: michael@0: if (FAILED(result)) michael@0: { michael@0: ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); michael@0: texture->Release(); michael@0: return gl::error(GL_OUT_OF_MEMORY, (IDirect3DTexture9*)NULL); michael@0: } michael@0: michael@0: mRenderer->endScene(); michael@0: result = device->StretchRect(surface, &sourceRect, textureSurface, NULL, D3DTEXF_NONE); michael@0: michael@0: textureSurface->Release(); michael@0: michael@0: if (FAILED(result)) michael@0: { michael@0: ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); michael@0: texture->Release(); michael@0: return gl::error(GL_OUT_OF_MEMORY, (IDirect3DTexture9*)NULL); michael@0: } michael@0: michael@0: return texture; michael@0: } michael@0: michael@0: void Blit::setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset) michael@0: { michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: D3DVIEWPORT9 vp; michael@0: vp.X = xoffset; michael@0: vp.Y = yoffset; michael@0: vp.Width = sourceRect.right - sourceRect.left; michael@0: vp.Height = sourceRect.bottom - sourceRect.top; michael@0: vp.MinZ = 0.0f; michael@0: vp.MaxZ = 1.0f; michael@0: device->SetViewport(&vp); michael@0: michael@0: float halfPixelAdjust[4] = { -1.0f/vp.Width, 1.0f/vp.Height, 0, 0 }; michael@0: device->SetVertexShaderConstantF(0, halfPixelAdjust, 1); michael@0: } michael@0: michael@0: void Blit::setCommonBlitState() michael@0: { michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: device->SetDepthStencilSurface(NULL); michael@0: michael@0: device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); michael@0: device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); michael@0: device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); michael@0: device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); michael@0: device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); michael@0: device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED); michael@0: device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE); michael@0: device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); michael@0: michael@0: device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); michael@0: device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); michael@0: device->SetSamplerState(0, D3DSAMP_SRGBTEXTURE, FALSE); michael@0: device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); michael@0: device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); michael@0: michael@0: RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle michael@0: device->SetScissorRect(&scissorRect); michael@0: michael@0: for(int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) michael@0: { michael@0: device->SetStreamSourceFreq(i, 1); michael@0: } michael@0: } michael@0: michael@0: void Blit::render() michael@0: { michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: HRESULT hr = device->SetStreamSource(0, mQuadVertexBuffer, 0, 2 * sizeof(float)); michael@0: hr = device->SetVertexDeclaration(mQuadVertexDeclaration); michael@0: michael@0: mRenderer->startScene(); michael@0: hr = device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); michael@0: } michael@0: michael@0: void Blit::saveState() michael@0: { michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: HRESULT hr; michael@0: michael@0: device->GetDepthStencilSurface(&mSavedDepthStencil); michael@0: device->GetRenderTarget(0, &mSavedRenderTarget); michael@0: michael@0: if (mSavedStateBlock == NULL) michael@0: { michael@0: hr = device->BeginStateBlock(); michael@0: ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY); michael@0: michael@0: setCommonBlitState(); michael@0: michael@0: static const float dummyConst[4] = { 0, 0, 0, 0 }; michael@0: michael@0: device->SetVertexShader(NULL); michael@0: device->SetVertexShaderConstantF(0, dummyConst, 1); michael@0: device->SetPixelShader(NULL); michael@0: device->SetPixelShaderConstantF(0, dummyConst, 1); michael@0: michael@0: D3DVIEWPORT9 dummyVp; michael@0: dummyVp.X = 0; michael@0: dummyVp.Y = 0; michael@0: dummyVp.Width = 1; michael@0: dummyVp.Height = 1; michael@0: dummyVp.MinZ = 0; michael@0: dummyVp.MaxZ = 1; michael@0: michael@0: device->SetViewport(&dummyVp); michael@0: michael@0: device->SetTexture(0, NULL); michael@0: michael@0: device->SetStreamSource(0, mQuadVertexBuffer, 0, 0); michael@0: michael@0: device->SetVertexDeclaration(mQuadVertexDeclaration); michael@0: michael@0: hr = device->EndStateBlock(&mSavedStateBlock); michael@0: ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY); michael@0: } michael@0: michael@0: ASSERT(mSavedStateBlock != NULL); michael@0: michael@0: if (mSavedStateBlock != NULL) michael@0: { michael@0: hr = mSavedStateBlock->Capture(); michael@0: ASSERT(SUCCEEDED(hr)); michael@0: } michael@0: } michael@0: michael@0: void Blit::restoreState() michael@0: { michael@0: IDirect3DDevice9 *device = mRenderer->getDevice(); michael@0: michael@0: device->SetDepthStencilSurface(mSavedDepthStencil); michael@0: if (mSavedDepthStencil != NULL) michael@0: { michael@0: mSavedDepthStencil->Release(); michael@0: mSavedDepthStencil = NULL; michael@0: } michael@0: michael@0: device->SetRenderTarget(0, mSavedRenderTarget); michael@0: if (mSavedRenderTarget != NULL) michael@0: { michael@0: mSavedRenderTarget->Release(); michael@0: mSavedRenderTarget = NULL; michael@0: } michael@0: michael@0: ASSERT(mSavedStateBlock != NULL); michael@0: michael@0: if (mSavedStateBlock != NULL) michael@0: { michael@0: mSavedStateBlock->Apply(); michael@0: } michael@0: } michael@0: michael@0: }