summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-12 07:40:59 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-12 07:40:59 +0000
commit387e543b11b8898524b9ab52bd5a9fb4c4a7df24 (patch)
tree063297f6dfc4fe15de0a08cee43c548ef7ea79c6
parentab74e5c0ce761db4c2ad37edb31c6cfce6a06354 (diff)
downloadchromium_src-387e543b11b8898524b9ab52bd5a9fb4c4a7df24.zip
chromium_src-387e543b11b8898524b9ab52bd5a9fb4c4a7df24.tar.gz
chromium_src-387e543b11b8898524b9ab52bd5a9fb4c4a7df24.tar.bz2
Patch in CCRendererGL.cpp changes from WK r128269
The WK side of this patch changes WebViewImpl not to y-flip / swizzle, so we need to do those in cc or all the compositor tests will be busted. BUG= Review URL: https://chromiumcodereview.appspot.com/10928136 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156255 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/CCRendererGL.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/cc/CCRendererGL.cpp b/cc/CCRendererGL.cpp
index 086d050..9b374ed 100644
--- a/cc/CCRendererGL.cpp
+++ b/cc/CCRendererGL.cpp
@@ -1137,7 +1137,7 @@ void CCRendererGL::getFramebufferPixels(void *pixels, const IntRect& rect)
GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
// Copy the contents of the current (IOSurface-backed) framebuffer into a temporary texture.
- GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, rect.maxX(), rect.maxY(), 0));
+ GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, viewportSize().width(), viewportSize().height(), 0));
temporaryFBO = m_context->createFramebuffer();
// Attach this texture to an FBO, and perform the readback from that FBO.
GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, temporaryFBO));
@@ -1146,8 +1146,25 @@ void CCRendererGL::getFramebufferPixels(void *pixels, const IntRect& rect)
ASSERT(m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE);
}
- GLC(m_context, m_context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(),
- GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
+ OwnPtr<uint8_t> srcPixels = adoptPtr(new uint8_t[rect.width() * rect.height() * 4]);
+ GLC(m_context, m_context->readPixels(rect.x(), viewportSize().height() - rect.maxY(), rect.width(), rect.height(),
+ GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, srcPixels.get()));
+
+ uint8_t* destPixels = static_cast<uint8_t*>(pixels);
+ size_t rowBytes = rect.width() * 4;
+ int numRows = rect.height();
+ size_t totalBytes = numRows * rowBytes;
+ for (size_t destY = 0; destY < totalBytes; destY += rowBytes) {
+ // Flip Y axis.
+ size_t srcY = totalBytes - destY - rowBytes;
+ // Swizzle BGRA -> RGBA.
+ for (size_t x = 0; x < rowBytes; x += 4) {
+ destPixels[destY + (x+0)] = srcPixels.get()[srcY + (x+2)];
+ destPixels[destY + (x+1)] = srcPixels.get()[srcY + (x+1)];
+ destPixels[destY + (x+2)] = srcPixels.get()[srcY + (x+0)];
+ destPixels[destY + (x+3)] = srcPixels.get()[srcY + (x+3)];
+ }
+ }
if (doWorkaround) {
// Clean up.