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

Side by Side Diff: Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp

Issue 7664004: Merge 92908 - Readback composited webgl results for printing (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // prepareTexture copies the contents of the off-screen render target in to the texture 90 // prepareTexture copies the contents of the off-screen render target in to the texture
91 // used by the compositor. 91 // used by the compositor.
92 // 92 //
93 m_context->prepareTexture(); 93 m_context->prepareTexture();
94 m_context->markLayerComposited(); 94 m_context->markLayerComposited();
95 m_contentsDirty = false; 95 m_contentsDirty = false;
96 m_textureUpdated = false; 96 m_textureUpdated = false;
97 } 97 }
98 } 98 }
99 99
100 bool WebGLLayerChromium::paintRenderedResultsToCanvas(ImageBuffer* imageBuffer)
101 {
102 if (m_textureUpdated || !layerRenderer() || !drawsContent())
103 return false;
104
105 IntSize framebufferSize = m_context->getInternalFramebufferSize();
106 ASSERT(layerRendererContext());
107
108 // This would ideally be done in the webgl context, but that isn't possible yet.
109 Platform3DObject framebuffer = layerRendererContext()->createFramebuffer();
110 layerRendererContext()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, fram ebuffer);
111 layerRendererContext()->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureI d, 0);
112
113 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(layerR endererContext()->getExtensions());
114 extensions->paintFramebufferToCanvas(framebuffer, framebufferSize.width(), f ramebufferSize.height(), !m_context->getContextAttributes().premultipliedAlpha, imageBuffer);
115 layerRendererContext()->deleteFramebuffer(framebuffer);
116 return true;
117 }
118
100 void WebGLLayerChromium::setTextureUpdated() 119 void WebGLLayerChromium::setTextureUpdated()
101 { 120 {
102 m_textureUpdated = true; 121 m_textureUpdated = true;
103 // If WebGL commands are issued outside of a the animation callbacks, then u se 122 // If WebGL commands are issued outside of a the animation callbacks, then u se
104 // call rateLimitOffscreenContextCHROMIUM() to keep the context from getting too far ahead. 123 // call rateLimitOffscreenContextCHROMIUM() to keep the context from getting too far ahead.
105 if (layerRenderer() && !layerRenderer()->isAnimating() && m_contextSupportsR ateLimitingExtension && !m_rateLimitingTimer.isActive()) 124 if (layerRenderer() && !layerRenderer()->isAnimating() && m_contextSupportsR ateLimitingExtension && !m_rateLimitingTimer.isActive())
106 m_rateLimitingTimer.startOneShot(0); 125 m_rateLimitingTimer.startOneShot(0);
107 } 126 }
108 127
109 void WebGLLayerChromium::setContext(const GraphicsContext3D* context) 128 void WebGLLayerChromium::setContext(const GraphicsContext3D* context)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 172
154 if (!m_context) 173 if (!m_context)
155 return; 174 return;
156 175
157 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_cont ext->getExtensions()); 176 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_cont ext->getExtensions());
158 extensions->rateLimitOffscreenContextCHROMIUM(); 177 extensions->rateLimitOffscreenContextCHROMIUM();
159 } 178 }
160 179
161 } 180 }
162 #endif // USE(ACCELERATED_COMPOSITING) 181 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698