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

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: 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
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..714cf2c4955d775b96794fa1bac47791ba0e3cf2 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, int width, int height,
+ size_t bufferSize, WebGLId framebuffer) {
+ if (bufferSize != static_cast<size_t>(4 * width * height))
return false;
makeContextCurrent();
@@ -601,8 +602,9 @@ 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_);
+ 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 +618,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 +635,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, width(), height(), bufferSize, fbo_);
+}
+
void WebGraphicsContext3DInProcessImpl::synthesizeGLError(WGC3Denum error) {
if (synthetic_errors_set_.find(error) == synthetic_errors_set_.end()) {
synthetic_errors_set_.insert(error);

Powered by Google App Engine
This is Rietveld 408576698