Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: webkit/gpu/webgraphicscontext3d_in_process_impl.cc

Issue 7566046: Add WebGraphicsContext support for readbacks from any framebuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix in-process default framebuffer Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/gpu/webgraphicscontext3d_in_process_impl.cc
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
index 6b8d7fc03217ebea1fad7b3a38ec35e24a5f68d3..9bcea10ed5d659806261dce833781356ee7973f8 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
@@ -588,8 +588,9 @@ void WebGraphicsContext3DInProcessImpl::FlipVertically(
#endif
bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
- unsigned char* pixels, size_t bufferSize) {
- if (bufferSize != static_cast<size_t>(4 * width() * height()))
+ unsigned char* pixels, size_t bufferSize, WebGLId framebuffer,
+ int width, int height) {
+ if (bufferSize != static_cast<size_t>(4 * width * height))
return false;
makeContextCurrent();
@@ -601,8 +602,14 @@ bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
// vertical flip is only a temporary solution anyway until Chrome
// is fully GPU composited, it wasn't worth the complexity.
- ResolveMultisampledFramebuffer(0, 0, cached_width_, cached_height_);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_);
+ // In this implementation fbo_, not 0, is the drawing buffer, so
+ // special-case that.
+ if (framebuffer == 0)
+ framebuffer = fbo_;
+
+ if (framebuffer == fbo_)
+ ResolveMultisampledFramebuffer(0, 0, width, height);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
GLint pack_alignment = 4;
bool must_restore_pack_alignment = false;
@@ -616,13 +623,13 @@ bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
// FIXME: consider testing for presence of GL_OES_read_format
// and GL_EXT_read_format_bgra, and using GL_BGRA_EXT here
// directly.
- glReadPixels(0, 0, cached_width_, cached_height_,
+ glReadPixels(0, 0, width, height,
GL_RGBA, GL_UNSIGNED_BYTE, pixels);
for (size_t i = 0; i < bufferSize; i += 4) {
std::swap(pixels[i], pixels[i + 2]);
}
} else {
- glReadPixels(0, 0, cached_width_, cached_height_,
+ glReadPixels(0, 0, width, height,
GL_BGRA, GL_UNSIGNED_BYTE, pixels);
}
@@ -633,12 +640,17 @@ bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
#ifdef FLIP_FRAMEBUFFER_VERTICALLY
if (pixels)
- FlipVertically(pixels, cached_width_, cached_height_);
+ FlipVertically(pixels, width, height);
#endif
return true;
}
+bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
+ unsigned char* pixels, size_t bufferSize) {
+ return readBackFramebuffer(pixels, bufferSize, fbo_, width(), height());
+}
+
void WebGraphicsContext3DInProcessImpl::synthesizeGLError(WGC3Denum error) {
if (synthetic_errors_set_.find(error) == synthetic_errors_set_.end()) {
synthetic_errors_set_.insert(error);
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698