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

Side by Side Diff: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 7669002: Introduction of parameter to readBackFramebuffer set of APIs to allow reading from the currently ... (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #ifndef GL_GLEXT_PROTOTYPES 10 #ifndef GL_GLEXT_PROTOTYPES
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 // framebuffer vertically before reading it back for compositing 836 // framebuffer vertically before reading it back for compositing
837 // via software. This code was quite complicated, used a lot of 837 // via software. This code was quite complicated, used a lot of
838 // GPU memory, and didn't provide an obvious speedup. Since this 838 // GPU memory, and didn't provide an obvious speedup. Since this
839 // vertical flip is only a temporary solution anyway until Chrome 839 // vertical flip is only a temporary solution anyway until Chrome
840 // is fully GPU composited, it wasn't worth the complexity. 840 // is fully GPU composited, it wasn't worth the complexity.
841 841
842 bool mustRestoreFBO = (bound_fbo_ != framebuffer); 842 bool mustRestoreFBO = (bound_fbo_ != framebuffer);
843 if (mustRestoreFBO) { 843 if (mustRestoreFBO) {
844 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer); 844 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer);
845 } 845 }
846 gl_->ReadPixels(0, 0, width, height, 846 gl_->ReadPixels(0, 0, width, height,
847 GL_RGBA, GL_UNSIGNED_BYTE, pixels); 847 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
848 848
849 // Swizzle red and blue channels 849 // Swizzle red and blue channels
850 // TODO(kbr): expose GL_BGRA as extension 850 // TODO(kbr): expose GL_BGRA as extension
851 for (size_t i = 0; i < buffer_size; i += 4) { 851 for (size_t i = 0; i < buffer_size; i += 4) {
852 std::swap(pixels[i], pixels[i + 2]); 852 std::swap(pixels[i], pixels[i + 2]);
853 } 853 }
854 854
855 if (mustRestoreFBO) { 855 if (mustRestoreFBO) {
856 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); 856 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_);
857 } 857 }
858 858
859 #ifdef FLIP_FRAMEBUFFER_VERTICALLY 859 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
860 if (pixels) { 860 if (pixels) {
861 FlipVertically(pixels, width, height); 861 FlipVertically(pixels, width, height);
862 } 862 }
863 #endif 863 #endif
864 864
865 return true; 865 return true;
866 } 866 }
867 867
868 bool WebGraphicsContext3DInProcessCommandBufferImpl::readBackFramebuffer( 868 bool WebGraphicsContext3DInProcessCommandBufferImpl::readBackFramebuffer(
869 unsigned char* pixels, 869 unsigned char* pixels,
870 size_t buffer_size) { 870 size_t buffer_size, bool bindDefaultBackbuffer) {
871 return readBackFramebuffer(pixels, buffer_size, 0, width(), height()); 871 if (bindDefaultBackbuffer)
872 return readBackFramebuffer(pixels, buffer_size, 0, width(), height());
873
874 return readBackFramebuffer(pixels, buffer_size, bound_fbo_, width(), height()) ;
872 } 875 }
873 876
874 void WebGraphicsContext3DInProcessCommandBufferImpl::synthesizeGLError( 877 void WebGraphicsContext3DInProcessCommandBufferImpl::synthesizeGLError(
875 WGC3Denum error) { 878 WGC3Denum error) {
876 if (find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == 879 if (find(synthetic_errors_.begin(), synthetic_errors_.end(), error) ==
877 synthetic_errors_.end()) { 880 synthetic_errors_.end()) {
878 synthetic_errors_.push_back(error); 881 synthetic_errors_.push_back(error);
879 } 882 }
880 } 883 }
881 884
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 if (context_lost_callback_) { 1634 if (context_lost_callback_) {
1632 context_lost_callback_->onContextLost(); 1635 context_lost_callback_->onContextLost();
1633 } 1636 }
1634 } 1637 }
1635 1638
1636 } // namespace gpu 1639 } // namespace gpu
1637 } // namespace webkit 1640 } // namespace webkit
1638 1641
1639 #endif // defined(ENABLE_GPU) 1642 #endif // defined(ENABLE_GPU)
1640 1643
OLDNEW
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h ('k') | webkit/gpu/webgraphicscontext3d_in_process_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698