summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp')
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp73
1 files changed, 30 insertions, 43 deletions
diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp
index 95320f228..2ac8ee3a2 100755
--- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp
@@ -145,7 +145,13 @@ gl::Error Blit9::setShader(ShaderId source, const char *profile,
{
const BYTE* shaderCode = g_shaderCode[source];
size_t shaderSize = g_shaderSize[source];
- ANGLE_TRY((mRenderer->*createShader)(reinterpret_cast<const DWORD*>(shaderCode), shaderSize, &shader));
+
+ gl::Error error = (mRenderer->*createShader)(reinterpret_cast<const DWORD*>(shaderCode), shaderSize, &shader);
+ if (error.isError())
+ {
+ return error;
+ }
+
mCompiledShaders[source] = shader;
}
@@ -184,10 +190,18 @@ RECT Blit9::getSurfaceRect(IDirect3DSurface9 *surface) const
gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
{
- ANGLE_TRY(initialize());
+ gl::Error error = initialize();
+ if (error.isError())
+ {
+ return error;
+ }
IDirect3DTexture9 *texture = NULL;
- ANGLE_TRY(copySurfaceToTexture(source, getSurfaceRect(source), &texture));
+ error = copySurfaceToTexture(source, getSurfaceRect(source), &texture);
+ if (error.isError())
+ {
+ return error;
+ }
IDirect3DDevice9 *device = mRenderer->getDevice();
@@ -216,13 +230,21 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
- ANGLE_TRY(initialize());
+ gl::Error error = initialize();
+ if (error.isError())
+ {
+ return error;
+ }
const gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
ASSERT(colorbuffer);
RenderTarget9 *renderTarget9 = nullptr;
- ANGLE_TRY(colorbuffer->getRenderTarget(&renderTarget9));
+ error = colorbuffer->getRenderTarget(&renderTarget9);
+ if (error.isError())
+ {
+ return error;
+ }
ASSERT(renderTarget9);
IDirect3DSurface9 *source = renderTarget9->getSurface();
@@ -230,7 +252,7 @@ gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRe
IDirect3DSurface9 *destSurface = NULL;
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
- gl::Error error = storage9->getSurfaceLevel(GL_TEXTURE_2D, level, true, &destSurface);
+ error = storage9->getSurfaceLevel(GL_TEXTURE_2D, level, true, &destSurface);
if (error.isError())
{
SafeRelease(source);
@@ -492,12 +514,9 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &so
D3DSURFACE_DESC sourceDesc;
surface->GetDesc(&sourceDesc);
- const auto destWidth = sourceRect.right - sourceRect.left;
- const auto destHeight = sourceRect.bottom - sourceRect.top;
-
// Copy the render target into a texture
IDirect3DTexture9 *texture;
- HRESULT result = device->CreateTexture(destWidth, destHeight, 1, D3DUSAGE_RENDERTARGET, sourceDesc.Format, D3DPOOL_DEFAULT, &texture, NULL);
+ HRESULT result = device->CreateTexture(sourceRect.right - sourceRect.left, sourceRect.bottom - sourceRect.top, 1, D3DUSAGE_RENDERTARGET, sourceDesc.Format, D3DPOOL_DEFAULT, &texture, NULL);
if (FAILED(result))
{
@@ -516,40 +535,8 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &so
}
mRenderer->endScene();
+ result = device->StretchRect(surface, &sourceRect, textureSurface, NULL, D3DTEXF_NONE);
- if (sourceRect.left < sourceDesc.Width && sourceRect.right > 0 &&
- sourceRect.top < sourceDesc.Height && sourceRect.bottom > 0)
- {
- RECT validSourceRect = sourceRect;
- RECT validDestRect = {0, 0, destWidth, destHeight};
-
- if (sourceRect.left < 0) {
- validSourceRect.left += 0 - sourceRect.left;
- validDestRect.left += 0 - sourceRect.left;
- }
-
- if (sourceRect.right > sourceDesc.Width) {
- validSourceRect.right -= sourceRect.right - sourceDesc.Width;
- validDestRect.right -= sourceRect.right - sourceDesc.Width;
- }
-
- if (sourceRect.top < 0) {
- validSourceRect.top += 0 - sourceRect.top;
- validDestRect.top += 0 - sourceRect.top;
- }
-
- if (sourceRect.bottom > sourceDesc.Height) {
- validSourceRect.bottom -= sourceRect.bottom - sourceDesc.Height;
- validDestRect.bottom -= sourceRect.bottom - sourceDesc.Height;
- }
-
- ASSERT(validSourceRect.left < validSourceRect.right);
- ASSERT(validSourceRect.top < validSourceRect.bottom);
- ASSERT(validDestRect.left < validDestRect.right);
- ASSERT(validDestRect.top < validDestRect.bottom);
- result = device->StretchRect(surface, &validSourceRect, textureSurface,
- &validDestRect, D3DTEXF_NONE);
- }
SafeRelease(textureSurface);
if (FAILED(result))