Commit 268b6bcd by Geoff Lang

Clean up copyimage.h

Change-Id: Ie4b81bb37dbbe6a9584dfc6a6c92670a9b73cda5 Reviewed-on: https://chromium-review.googlesource.com/207374Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 70d457d8
...@@ -207,6 +207,7 @@ ...@@ -207,6 +207,7 @@
<None Include="..\..\src\libGLESv2\libGLESv2.def"/> <None Include="..\..\src\libGLESv2\libGLESv2.def"/>
<None Include="..\..\src\libGLESv2\renderer\loadimage.inl"/> <None Include="..\..\src\libGLESv2\renderer\loadimage.inl"/>
<None Include="..\..\src\libGLESv2\renderer\copyvertex.inl"/> <None Include="..\..\src\libGLESv2\renderer\copyvertex.inl"/>
<None Include="..\..\src\libGLESv2\renderer\copyimage.inl"/>
<None Include="..\..\src\libGLESv2\renderer\generatemip.inl"/> <None Include="..\..\src\libGLESv2\renderer\generatemip.inl"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -318,6 +318,9 @@ ...@@ -318,6 +318,9 @@
<ClInclude Include="..\..\src\libGLESv2\renderer\QueryImpl.h"> <ClInclude Include="..\..\src\libGLESv2\renderer\QueryImpl.h">
<Filter>src\libGLESv2\renderer</Filter> <Filter>src\libGLESv2\renderer</Filter>
</ClInclude> </ClInclude>
<None Include="..\..\src\libGLESv2\renderer\copyimage.inl">
<Filter>src\libGLESv2\renderer</Filter>
</None>
<ClInclude Include="..\..\src\libGLESv2\renderer\IndexRangeCache.h"> <ClInclude Include="..\..\src\libGLESv2\renderer\IndexRangeCache.h">
<Filter>src\libGLESv2\renderer</Filter> <Filter>src\libGLESv2\renderer</Filter>
</ClInclude> </ClInclude>
......
...@@ -117,6 +117,7 @@ ...@@ -117,6 +117,7 @@
'libGLESv2/renderer/VertexArrayImpl.h', 'libGLESv2/renderer/VertexArrayImpl.h',
'libGLESv2/renderer/copyimage.cpp', 'libGLESv2/renderer/copyimage.cpp',
'libGLESv2/renderer/copyimage.h', 'libGLESv2/renderer/copyimage.h',
'libGLESv2/renderer/copyimage.inl',
'libGLESv2/renderer/copyvertex.h', 'libGLESv2/renderer/copyvertex.h',
'libGLESv2/renderer/copyvertex.inl', 'libGLESv2/renderer/copyvertex.inl',
'libGLESv2/renderer/generatemip.h', 'libGLESv2/renderer/generatemip.h',
......
...@@ -1693,7 +1693,8 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, ...@@ -1693,7 +1693,8 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
const InternalFormat &sizedFormatInfo = GetInternalFormatInfo(sizedInternalFormat); const InternalFormat &sizedFormatInfo = GetInternalFormatInfo(sizedInternalFormat);
GLuint outputPitch = sizedFormatInfo.computeRowPitch(type, width, mState.getPackAlignment()); GLuint outputPitch = sizedFormatInfo.computeRowPitch(type, width, mState.getPackAlignment());
mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.getPackState(), pixels); mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.getPackState(),
reinterpret_cast<uint8_t*>(pixels));
} }
void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances) void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances)
......
...@@ -27,9 +27,9 @@ typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth, ...@@ -27,9 +27,9 @@ typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth,
typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth, typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
typedef void (*ColorReadFunction)(const void *source, void *dest); typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorWriteFunction)(const void *source, void *dest); typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorCopyFunction)(const void *source, void *dest); typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output); typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "libGLESv2/angletypes.h" #include "libGLESv2/angletypes.h"
#include "libGLESv2/Caps.h" #include "libGLESv2/Caps.h"
#include <cstdint>
#if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL) #if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
// WARNING: D3DCOMPILE_OPTIMIZATION_LEVEL3 may lead to a DX9 shader compiler hang. // WARNING: D3DCOMPILE_OPTIMIZATION_LEVEL3 may lead to a DX9 shader compiler hang.
// It should only be used selectively to work around specific bugs. // It should only be used selectively to work around specific bugs.
...@@ -188,7 +190,7 @@ class Renderer ...@@ -188,7 +190,7 @@ class Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0; const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0;
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels) = 0; GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0;
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0; virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0;
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
namespace rx namespace rx
{ {
void CopyBGRAUByteToRGBAUByte(const void *source, void *dest) void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest)
{ {
unsigned int argb = *(unsigned int*)source; uint32_t argb = *reinterpret_cast<const uint32_t*>(source);
*(unsigned int*)dest = (argb & 0xFF00FF00) | // Keep alpha and green *reinterpret_cast<uint32_t*>(dest) = (argb & 0xFF00FF00) | // Keep alpha and green
(argb & 0x00FF0000) >> 16 | // Move red to blue (argb & 0x00FF0000) >> 16 | // Move red to blue
(argb & 0x000000FF) << 16; // Move blue to red (argb & 0x000000FF) << 16; // Move blue to red
} }
} }
// //
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -16,27 +16,18 @@ namespace rx ...@@ -16,27 +16,18 @@ namespace rx
{ {
template <typename sourceType, typename colorDataType> template <typename sourceType, typename colorDataType>
void ReadColor(const void *source, void *dest) void ReadColor(const uint8_t *source, uint8_t *dest);
{
sourceType::readColor(reinterpret_cast<gl::Color<colorDataType>*>(dest), reinterpret_cast<const sourceType*>(source));
}
template <typename destType, typename colorDataType> template <typename destType, typename colorDataType>
void WriteColor(const void *source, void *dest) void WriteColor(const uint8_t *source, uint8_t *dest);
{
destType::writeColor(reinterpret_cast<destType*>(dest), reinterpret_cast<const gl::Color<colorDataType>*>(source));
}
template <typename sourceType, typename destType, typename colorDataType> template <typename sourceType, typename destType, typename colorDataType>
void CopyPixel(const void *source, void *dest) void CopyPixel(const uint8_t *source, uint8_t *dest);
{
colorType temp;
ReadColor<sourceType, colorDataType>(source, &temp);
WriteColor<destType, colorDataType>(&temp, dest);
}
void CopyBGRAUByteToRGBAUByte(const void *source, void *dest); void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest);
} }
#include "copyimage.inl"
#endif // LIBGLESV2_RENDERER_COPYIMAGE_H_ #endif // LIBGLESV2_RENDERER_COPYIMAGE_H_
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// copyimage.inl: Defines image copying functions
namespace rx
{
template <typename sourceType, typename colorDataType>
inline void ReadColor(const uint8_t *source, uint8_t *dest)
{
sourceType::readColor(reinterpret_cast<gl::Color<colorDataType>*>(dest), reinterpret_cast<const sourceType*>(source));
}
template <typename destType, typename colorDataType>
inline void WriteColor(const uint8_t *source, uint8_t *dest)
{
destType::writeColor(reinterpret_cast<destType*>(dest), reinterpret_cast<const gl::Color<colorDataType>*>(source));
}
template <typename sourceType, typename destType, typename colorDataType>
inline void CopyPixel(const uint8_t *source, uint8_t *dest)
{
colorType temp;
ReadColor<sourceType, colorDataType>(source, &temp);
WriteColor<destType, colorDataType>(&temp, dest);
}
}
...@@ -296,7 +296,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y ...@@ -296,7 +296,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y
// determine the offset coordinate into the destination buffer // determine the offset coordinate into the destination buffer
GLsizei rowOffset = gl::GetInternalFormatInfo(mActualFormat).pixelBytes * xoffset; GLsizei rowOffset = gl::GetInternalFormatInfo(mActualFormat).pixelBytes * xoffset;
void *dataOffset = static_cast<unsigned char*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch; uint8_t *dataOffset = static_cast<uint8_t*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch;
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
......
...@@ -2637,7 +2637,7 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read ...@@ -2637,7 +2637,7 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read
} }
void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
{ {
ID3D11Texture2D *colorBufferTexture = NULL; ID3D11Texture2D *colorBufferTexture = NULL;
unsigned int subresourceIndex = 0; unsigned int subresourceIndex = 0;
...@@ -2724,7 +2724,7 @@ TextureImpl *Renderer11::createTexture(GLenum target) ...@@ -2724,7 +2724,7 @@ TextureImpl *Renderer11::createTexture(GLenum target)
} }
void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format, void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void *pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
{ {
ASSERT(area.width >= 0); ASSERT(area.width >= 0);
ASSERT(area.height >= 0); ASSERT(area.height >= 0);
...@@ -2824,7 +2824,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -2824,7 +2824,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
SafeRelease(stagingTex); SafeRelease(stagingTex);
} }
void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, void *pixelsOut) void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut)
{ {
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
readTexture->GetDesc(&textureDesc); readTexture->GetDesc(&textureDesc);
...@@ -2834,16 +2834,16 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams ...@@ -2834,16 +2834,16 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams
UNUSED_ASSERTION_VARIABLE(hr); UNUSED_ASSERTION_VARIABLE(hr);
ASSERT(SUCCEEDED(hr)); ASSERT(SUCCEEDED(hr));
unsigned char *source; uint8_t *source;
int inputPitch; int inputPitch;
if (params.pack.reverseRowOrder) if (params.pack.reverseRowOrder)
{ {
source = static_cast<unsigned char*>(mapping.pData) + mapping.RowPitch * (params.area.height - 1); source = static_cast<uint8_t*>(mapping.pData) + mapping.RowPitch * (params.area.height - 1);
inputPitch = -static_cast<int>(mapping.RowPitch); inputPitch = -static_cast<int>(mapping.RowPitch);
} }
else else
{ {
source = static_cast<unsigned char*>(mapping.pData); source = static_cast<uint8_t*>(mapping.pData);
inputPitch = static_cast<int>(mapping.RowPitch); inputPitch = static_cast<int>(mapping.RowPitch);
} }
...@@ -2851,7 +2851,7 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams ...@@ -2851,7 +2851,7 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams
const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(dxgiFormatInfo.internalFormat); const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(dxgiFormatInfo.internalFormat);
if (sourceFormatInfo.format == params.format && sourceFormatInfo.type == params.type) if (sourceFormatInfo.format == params.format && sourceFormatInfo.type == params.type)
{ {
unsigned char *dest = static_cast<unsigned char*>(pixelsOut) + params.offset; uint8_t *dest = pixelsOut + params.offset;
for (int y = 0; y < params.area.height; y++) for (int y = 0; y < params.area.height; y++)
{ {
memcpy(dest + y * params.outputPitch, source + y * inputPitch, params.area.width * sourceFormatInfo.pixelBytes); memcpy(dest + y * params.outputPitch, source + y * inputPitch, params.area.width * sourceFormatInfo.pixelBytes);
...@@ -2872,8 +2872,8 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams ...@@ -2872,8 +2872,8 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams
{ {
for (int x = 0; x < params.area.width; x++) for (int x = 0; x < params.area.width; x++)
{ {
void *dest = static_cast<unsigned char*>(pixelsOut) + params.offset + y * params.outputPitch + x * destFormatInfo.pixelBytes; uint8_t *dest = pixelsOut + params.offset + y * params.outputPitch + x * destFormatInfo.pixelBytes;
void *src = static_cast<unsigned char*>(source) + y * inputPitch + x * sourceFormatInfo.pixelBytes; const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
fastCopyFunc(src, dest); fastCopyFunc(src, dest);
} }
...@@ -2881,7 +2881,7 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams ...@@ -2881,7 +2881,7 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams
} }
else else
{ {
unsigned char temp[16]; // Maximum size of any Color<T> type used. uint8_t temp[16]; // Maximum size of any Color<T> type used.
META_ASSERT(sizeof(temp) >= sizeof(gl::ColorF) && META_ASSERT(sizeof(temp) >= sizeof(gl::ColorF) &&
sizeof(temp) >= sizeof(gl::ColorUI) && sizeof(temp) >= sizeof(gl::ColorUI) &&
sizeof(temp) >= sizeof(gl::ColorI)); sizeof(temp) >= sizeof(gl::ColorI));
...@@ -2890,8 +2890,8 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams ...@@ -2890,8 +2890,8 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams
{ {
for (int x = 0; x < params.area.width; x++) for (int x = 0; x < params.area.width; x++)
{ {
void *dest = static_cast<unsigned char*>(pixelsOut) + params.offset + y * params.outputPitch + x * destFormatInfo.pixelBytes; uint8_t *dest = pixelsOut + params.offset + y * params.outputPitch + x * destFormatInfo.pixelBytes;
void *src = static_cast<unsigned char*>(source) + y * inputPitch + x * sourceFormatInfo.pixelBytes; const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
// readFunc and writeFunc will be using the same type of color, CopyTexImage // readFunc and writeFunc will be using the same type of color, CopyTexImage
// will not allow the copy otherwise. // will not allow the copy otherwise.
......
...@@ -139,7 +139,7 @@ class Renderer11 : public Renderer ...@@ -139,7 +139,7 @@ class Renderer11 : public Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter); const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels); GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth); virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
...@@ -193,7 +193,7 @@ class Renderer11 : public Renderer ...@@ -193,7 +193,7 @@ class Renderer11 : public Renderer
bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource); bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource);
void unapplyRenderTargets(); void unapplyRenderTargets();
void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView); void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView);
void packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, void *pixelsOut); void packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut);
virtual bool getLUID(LUID *adapterLuid) const; virtual bool getLUID(LUID *adapterLuid) const;
virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const; virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const;
...@@ -208,7 +208,7 @@ class Renderer11 : public Renderer ...@@ -208,7 +208,7 @@ class Renderer11 : public Renderer
void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances); void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format, void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void *pixels); GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget, bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor, RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor,
......
...@@ -123,7 +123,7 @@ static D3D11FastCopyMap BuildFastCopyMap() ...@@ -123,7 +123,7 @@ static D3D11FastCopyMap BuildFastCopyMap()
{ {
D3D11FastCopyMap map; D3D11FastCopyMap map;
map.insert(std::make_pair(DXGI_FORMAT_B8G8R8A8_UNORM, D3D11FastCopyFormat(GL_RGBA, GL_UNSIGNED_BYTE, CopyBGRAUByteToRGBAUByte))); map.insert(std::make_pair(DXGI_FORMAT_B8G8R8A8_UNORM, D3D11FastCopyFormat(GL_RGBA, GL_UNSIGNED_BYTE, CopyBGRA8ToRGBA8)));
return map; return map;
} }
......
...@@ -2579,7 +2579,7 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle & ...@@ -2579,7 +2579,7 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle &
} }
void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
{ {
ASSERT(pack.pixelBuffer.get() == NULL); ASSERT(pack.pixelBuffer.get() == NULL);
...@@ -2622,7 +2622,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2622,7 +2622,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
{ {
// Use the pixels ptr as a shared handle to write directly into client's memory // Use the pixels ptr as a shared handle to write directly into client's memory
result = mDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, result = mDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format,
D3DPOOL_SYSTEMMEM, &systemSurface, &pixels); D3DPOOL_SYSTEMMEM, &systemSurface, reinterpret_cast<void**>(&pixels));
if (FAILED(result)) if (FAILED(result))
{ {
// Try again without the shared handle // Try again without the shared handle
...@@ -2687,16 +2687,16 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2687,16 +2687,16 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
return; // No sensible error to generate return; // No sensible error to generate
} }
unsigned char *source; uint8_t *source;
int inputPitch; int inputPitch;
if (pack.reverseRowOrder) if (pack.reverseRowOrder)
{ {
source = ((unsigned char*)lock.pBits) + lock.Pitch * (rect.bottom - rect.top - 1); source = reinterpret_cast<uint8_t*>(lock.pBits) + lock.Pitch * (rect.bottom - rect.top - 1);
inputPitch = -lock.Pitch; inputPitch = -lock.Pitch;
} }
else else
{ {
source = (unsigned char*)lock.pBits; source = reinterpret_cast<uint8_t*>(lock.pBits);
inputPitch = lock.Pitch; inputPitch = lock.Pitch;
} }
...@@ -2705,10 +2705,9 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2705,10 +2705,9 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
if (sourceFormatInfo.format == format && sourceFormatInfo.type == type) if (sourceFormatInfo.format == format && sourceFormatInfo.type == type)
{ {
// Direct copy possible // Direct copy possible
unsigned char *dest = static_cast<unsigned char*>(pixels);
for (int y = 0; y < rect.bottom - rect.top; y++) for (int y = 0; y < rect.bottom - rect.top; y++)
{ {
memcpy(dest + y * outputPitch, source + y * inputPitch, (rect.right - rect.left) * sourceFormatInfo.pixelBytes); memcpy(pixels + y * outputPitch, source + y * inputPitch, (rect.right - rect.left) * sourceFormatInfo.pixelBytes);
} }
} }
else else
...@@ -2726,8 +2725,8 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2726,8 +2725,8 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
{ {
for (int x = 0; x < rect.right - rect.left; x++) for (int x = 0; x < rect.right - rect.left; x++)
{ {
void *dest = static_cast<unsigned char*>(pixels) + y * outputPitch + x * destFormatInfo.pixelBytes; uint8_t *dest = pixels + y * outputPitch + x * destFormatInfo.pixelBytes;
void *src = static_cast<unsigned char*>(source) + y * inputPitch + x * sourceFormatInfo.pixelBytes; const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
fastCopyFunc(src, dest); fastCopyFunc(src, dest);
} }
...@@ -2735,18 +2734,18 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2735,18 +2734,18 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
} }
else else
{ {
gl::ColorF temp; uint8_t temp[sizeof(gl::ColorF)];
for (int y = 0; y < rect.bottom - rect.top; y++) for (int y = 0; y < rect.bottom - rect.top; y++)
{ {
for (int x = 0; x < rect.right - rect.left; x++) for (int x = 0; x < rect.right - rect.left; x++)
{ {
void *dest = reinterpret_cast<unsigned char*>(pixels) + y * outputPitch + x * destFormatInfo.pixelBytes; uint8_t *dest = pixels + y * outputPitch + x * destFormatInfo.pixelBytes;
void *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes; const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
// readFunc and writeFunc will be using the same type of color, CopyTexImage // readFunc and writeFunc will be using the same type of color, CopyTexImage
// will not allow the copy otherwise. // will not allow the copy otherwise.
sourceD3DFormatInfo.colorReadFunction(src, &temp); sourceD3DFormatInfo.colorReadFunction(src, temp);
destFormatTypeInfo.colorWriteFunction(&temp, dest); destFormatTypeInfo.colorWriteFunction(temp, dest);
} }
} }
} }
......
...@@ -141,7 +141,7 @@ class Renderer9 : public Renderer ...@@ -141,7 +141,7 @@ class Renderer9 : public Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter); const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels); GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth); virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
......
...@@ -46,7 +46,7 @@ static D3D9FastCopyMap BuildFastCopyMap() ...@@ -46,7 +46,7 @@ static D3D9FastCopyMap BuildFastCopyMap()
{ {
D3D9FastCopyMap map; D3D9FastCopyMap map;
map.insert(std::make_pair(D3DFMT_A8R8G8B8, D3D9FastCopyFormat(GL_RGBA, GL_UNSIGNED_BYTE, CopyBGRAUByteToRGBAUByte))); map.insert(std::make_pair(D3DFMT_A8R8G8B8, D3D9FastCopyFormat(GL_RGBA, GL_UNSIGNED_BYTE, CopyBGRA8ToRGBA8)));
return map; return map;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment