Changeset 128269 in webkit
- Timestamp:
- Sep 12, 2012 12:02:02 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128261 r128269 1 2012-09-12 Alexandre Elias <aelias@chromium.org> 2 3 [chromium] Flip Y and swizzle inside compositeAndReadback implementation 4 https://bugs.webkit.org/show_bug.cgi?id=96458 5 6 Reviewed by James Robinson. 7 8 Currently, compositeAndReadback API assumes a GL-style texture 9 and is converted to the normal software format in WebViewImpl. 10 For the software implementation, this API would result in two 11 redundant conversions. This patch makes the conversion inside 12 CCRendererGL instead. I rolled my own for loop as I didn't find the 13 appropriate function within raw Skia. 14 15 No new tests (covered by existing layout tests). 16 17 * platform/graphics/chromium/cc/CCRendererGL.cpp: 18 (WebCore::CCRendererGL::getFramebufferPixels): 19 1 20 2012-09-11 Ryuan Choi <ryuan.choi@samsung.com> 2 21 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRendererGL.cpp
r126473 r128269 1161 1161 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); 1162 1162 // Copy the contents of the current (IOSurface-backed) framebuffer into a temporary texture. 1163 GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, rect.maxX(), rect.maxY(), 0));1163 GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, viewportSize().width(), viewportSize().height(), 0)); 1164 1164 temporaryFBO = m_context->createFramebuffer(); 1165 1165 // Attach this texture to an FBO, and perform the readback from that FBO. … … 1170 1170 } 1171 1171 1172 GLC(m_context, m_context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(), 1173 GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels)); 1172 OwnPtr<uint8_t> srcPixels = adoptPtr(new uint8_t[rect.width() * rect.height() * 4]); 1173 GLC(m_context, m_context->readPixels(rect.x(), viewportSize().height() - rect.maxY(), rect.width(), rect.height(), 1174 GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, srcPixels.get())); 1175 1176 uint8_t* destPixels = static_cast<uint8_t*>(pixels); 1177 size_t rowBytes = rect.width() * 4; 1178 int numRows = rect.height(); 1179 size_t totalBytes = numRows * rowBytes; 1180 for (size_t destY = 0; destY < totalBytes; destY += rowBytes) { 1181 // Flip Y axis. 1182 size_t srcY = totalBytes - destY - rowBytes; 1183 // Swizzle BGRA -> RGBA. 1184 for (size_t x = 0; x < rowBytes; x += 4) { 1185 destPixels[destY + (x+0)] = srcPixels.get()[srcY + (x+2)]; 1186 destPixels[destY + (x+1)] = srcPixels.get()[srcY + (x+1)]; 1187 destPixels[destY + (x+2)] = srcPixels.get()[srcY + (x+0)]; 1188 destPixels[destY + (x+3)] = srcPixels.get()[srcY + (x+3)]; 1189 } 1190 } 1174 1191 1175 1192 if (doWorkaround) { -
trunk/Source/WebKit/chromium/ChangeLog
r128263 r128269 1 2012-09-12 Alexandre Elias <aelias@chromium.org> 2 3 [chromium] Flip Y and swizzle inside compositeAndReadback implementation 4 https://bugs.webkit.org/show_bug.cgi?id=96458 5 6 Reviewed by James Robinson. 7 8 Currently, compositeAndReadback API assumes a GL-style texture 9 and is converted to the normal software format in WebViewImpl. 10 For the software implementation, this API would result in two 11 redundant conversions. This patch makes the conversion inside 12 CCRendererGL instead. I rolled my own for loop as I didn't find the 13 appropriate function within raw Skia. 14 15 No new tests (covered by existing layout tests). 16 17 * src/WebViewImpl.cpp: 18 (WebKit::WebViewImpl::doPixelReadbackToCanvas): 19 1 20 2012-09-11 Taiju Tsuiki <tzik@chromium.org> 2 21 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r128133 r128269 1742 1742 ASSERT(m_layerTreeView); 1743 1743 1744 PlatformContextSkia context(canvas); 1745 1746 // PlatformGraphicsContext is actually a pointer to PlatformContextSkia 1747 GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); 1748 int bitmapHeight = canvas->getDevice()->accessBitmap(false).height(); 1749 1750 // Compute rect to sample from inverted GPU buffer. 1751 IntRect invertRect(rect.x(), bitmapHeight - rect.maxY(), rect.width(), rect.height()); 1752 1753 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(rect.size())); 1754 RefPtr<Uint8ClampedArray> pixelArray(Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4)); 1755 if (imageBuffer && pixelArray) { 1756 m_layerTreeView->compositeAndReadback(pixelArray->data(), invertRect); 1757 imageBuffer->putByteArray(Premultiplied, pixelArray.get(), rect.size(), IntRect(IntPoint(), rect.size()), IntPoint()); 1758 gc.save(); 1759 gc.translate(IntSize(0, bitmapHeight)); 1760 gc.scale(FloatSize(1.0f, -1.0f)); 1761 // Use invertRect in next line, so that transform above inverts it back to 1762 // desired destination rect. 1763 gc.drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, invertRect.location()); 1764 gc.restore(); 1765 } 1744 SkBitmap target; 1745 target.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height(), rect.width() * 4); 1746 target.allocPixels(); 1747 m_layerTreeView->compositeAndReadback(target.getPixels(), rect); 1748 canvas->writePixels(target, rect.x(), rect.y()); 1766 1749 } 1767 1750 #endif
Note: See TracChangeset
for help on using the changeset viewer.