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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 12676029: cc: Fix capitalization style in chromified files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 #include "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 << static_cast<int>(error) << "\n"; 206 << static_cast<int>(error) << "\n";
207 } 207 }
208 208
209 void GLRenderer::SetVisible(bool visible) { 209 void GLRenderer::SetVisible(bool visible) {
210 if (visible_ == visible) 210 if (visible_ == visible)
211 return; 211 return;
212 visible_ = visible; 212 visible_ = visible;
213 213
214 EnforceMemoryPolicy(); 214 EnforceMemoryPolicy();
215 215
216 // TODO: Replace setVisibilityCHROMIUM with an extension to explicitly manage 216 // TODO: Replace setVisibilityCHROMIUM() with an extension to explicitly
217 // front/backbuffers 217 // manage front/backbuffers
218 // crbug.com/116049 218 // crbug.com/116049
219 if (capabilities_.using_set_visibility) 219 if (capabilities_.using_set_visibility)
220 context_->setVisibilityCHROMIUM(visible); 220 context_->setVisibilityCHROMIUM(visible);
221 } 221 }
222 222
223 void GLRenderer::SendManagedMemoryStats(size_t bytes_visible, 223 void GLRenderer::SendManagedMemoryStats(size_t bytes_visible,
224 size_t bytes_visible_and_nearby, 224 size_t bytes_visible_and_nearby,
225 size_t bytes_allocated) { 225 size_t bytes_allocated) {
226 WebKit::WebGraphicsManagedMemoryStats stats; 226 WebKit::WebGraphicsManagedMemoryStats stats;
227 stats.bytesVisible = bytes_visible; 227 stats.bytesVisible = bytes_visible;
(...skipping 21 matching lines...) Expand all
249 context_->clear(GL_COLOR_BUFFER_BIT); 249 context_->clear(GL_COLOR_BUFFER_BIT);
250 } 250 }
251 251
252 void GLRenderer::BeginDrawingFrame(DrawingFrame& frame) { 252 void GLRenderer::BeginDrawingFrame(DrawingFrame& frame) {
253 // FIXME: Remove this once backbuffer is automatically recreated on first use 253 // FIXME: Remove this once backbuffer is automatically recreated on first use
254 EnsureBackbuffer(); 254 EnsureBackbuffer();
255 255
256 if (ViewportSize().IsEmpty()) 256 if (ViewportSize().IsEmpty())
257 return; 257 return;
258 258
259 TRACE_EVENT0("cc", "GLRenderer::drawLayers"); 259 TRACE_EVENT0("cc", "GLRenderer::DrawLayers");
260 if (is_viewport_changed_) { 260 if (is_viewport_changed_) {
261 // Only reshape when we know we are going to draw. Otherwise, the reshape 261 // Only reshape when we know we are going to draw. Otherwise, the reshape
262 // can leave the window at the wrong size if we never draw and the proper 262 // can leave the window at the wrong size if we never draw and the proper
263 // viewport size is never set. 263 // viewport size is never set.
264 is_viewport_changed_ = false; 264 is_viewport_changed_ = false;
265 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight())); 265 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight()));
266 } 266 }
267 267
268 MakeContextCurrent(); 268 MakeContextCurrent();
269 // Bind the common vertex attributes used for drawing all the layers. 269 // Bind the common vertex attributes used for drawing all the layers.
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 // set up premultiplied alpha. 1328 // set up premultiplied alpha.
1329 if (!draw_cache_.use_premultiplied_alpha) { 1329 if (!draw_cache_.use_premultiplied_alpha) {
1330 // As it turns out, the premultiplied alpha blending function (ONE, 1330 // As it turns out, the premultiplied alpha blending function (ONE,
1331 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to 1331 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to
1332 // anything less than 1.0f if it is initialized to that value! Therefore, 1332 // anything less than 1.0f if it is initialized to that value! Therefore,
1333 // premultiplied_alpha being false is the first situation we can generally 1333 // premultiplied_alpha being false is the first situation we can generally
1334 // see an alpha channel less than 1.0f coming out of the compositor. This is 1334 // see an alpha channel less than 1.0f coming out of the compositor. This is
1335 // causing platform differences in some layout tests (see 1335 // causing platform differences in some layout tests (see
1336 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use 1336 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use
1337 // a separate blend function for the alpha channel to avoid modifying it. 1337 // a separate blend function for the alpha channel to avoid modifying it.
1338 // Don't use colorMask for this as it has performance implications on some 1338 // Don't use colorMask() for this as it has performance implications on some
1339 // platforms. 1339 // platforms.
1340 GLC(Context(), 1340 GLC(Context(),
1341 Context()->blendFuncSeparate( 1341 Context()->blendFuncSeparate(
1342 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE)); 1342 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE));
1343 } 1343 }
1344 1344
1345 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed); 1345 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed);
1346 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float), 1346 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float),
1347 struct_is_densely_packed); 1347 struct_is_densely_packed);
1348 1348
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 1460
1461 if (!quad->premultiplied_alpha) { 1461 if (!quad->premultiplied_alpha) {
1462 // As it turns out, the premultiplied alpha blending function (ONE, 1462 // As it turns out, the premultiplied alpha blending function (ONE,
1463 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to 1463 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to
1464 // anything less than 1.0f if it is initialized to that value! Therefore, 1464 // anything less than 1.0f if it is initialized to that value! Therefore,
1465 // premultiplied_alpha being false is the first situation we can generally 1465 // premultiplied_alpha being false is the first situation we can generally
1466 // see an alpha channel less than 1.0f coming out of the compositor. This is 1466 // see an alpha channel less than 1.0f coming out of the compositor. This is
1467 // causing platform differences in some layout tests (see 1467 // causing platform differences in some layout tests (see
1468 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use 1468 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use
1469 // a separate blend function for the alpha channel to avoid modifying it. 1469 // a separate blend function for the alpha channel to avoid modifying it.
1470 // Don't use colorMask for this as it has performance implications on some 1470 // Don't use colorMask() for this as it has performance implications on some
1471 // platforms. 1471 // platforms.
1472 GLC(Context(), 1472 GLC(Context(),
1473 Context()->blendFuncSeparate( 1473 Context()->blendFuncSeparate(
1474 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE)); 1474 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE));
1475 } 1475 }
1476 1476
1477 DrawQuadGeometry( 1477 DrawQuadGeometry(
1478 frame, quad->quadTransform(), quad->rect, binding.matrix_location); 1478 frame, quad->quadTransform(), quad->rect, binding.matrix_location);
1479 1479
1480 if (!quad->premultiplied_alpha) 1480 if (!quad->premultiplied_alpha)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 1639
1640 void GLRenderer::Finish() { 1640 void GLRenderer::Finish() {
1641 TRACE_EVENT0("cc", "GLRenderer::finish"); 1641 TRACE_EVENT0("cc", "GLRenderer::finish");
1642 context_->finish(); 1642 context_->finish();
1643 } 1643 }
1644 1644
1645 bool GLRenderer::SwapBuffers() { 1645 bool GLRenderer::SwapBuffers() {
1646 DCHECK(visible_); 1646 DCHECK(visible_);
1647 DCHECK(!is_backbuffer_discarded_); 1647 DCHECK(!is_backbuffer_discarded_);
1648 1648
1649 TRACE_EVENT0("cc", "GLRenderer::swapBuffers"); 1649 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers");
1650 // We're done! Time to swapbuffers! 1650 // We're done! Time to swapbuffers!
1651 1651
1652 if (capabilities_.using_partial_swap) { 1652 if (capabilities_.using_partial_swap) {
1653 // If supported, we can save significant bandwidth by only swapping the 1653 // If supported, we can save significant bandwidth by only swapping the
1654 // damaged/scissored region (clamped to the viewport) 1654 // damaged/scissored region (clamped to the viewport)
1655 swap_buffer_rect_.Intersect(gfx::Rect(gfx::Point(), ViewportSize())); 1655 swap_buffer_rect_.Intersect(gfx::Rect(gfx::Point(), ViewportSize()));
1656 int flipped_y_pos_of_rect_bottom = 1656 int flipped_y_pos_of_rect_bottom =
1657 ViewportHeight() - swap_buffer_rect_.y() - swap_buffer_rect_.height(); 1657 ViewportHeight() - swap_buffer_rect_.y() - swap_buffer_rect_.height();
1658 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(), 1658 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(),
1659 flipped_y_pos_of_rect_bottom, 1659 flipped_y_pos_of_rect_bottom,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 return ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; 1723 return ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE;
1724 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: 1724 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
1725 return ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING; 1725 return ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING;
1726 } 1726 }
1727 NOTREACHED(); 1727 NOTREACHED();
1728 return ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; 1728 return ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING;
1729 } 1729 }
1730 1730
1731 void GLRenderer::EnforceMemoryPolicy() { 1731 void GLRenderer::EnforceMemoryPolicy() {
1732 if (!visible_) { 1732 if (!visible_) {
1733 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources"); 1733 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources");
1734 ReleaseRenderPassTextures(); 1734 ReleaseRenderPassTextures();
1735 if (discard_backbuffer_when_not_visible_) 1735 if (discard_backbuffer_when_not_visible_)
1736 DiscardBackbuffer(); 1736 DiscardBackbuffer();
1737 resource_provider_->ReleaseCachedData(); 1737 resource_provider_->ReleaseCachedData();
1738 GLC(context_, context_->flush()); 1738 GLC(context_, context_->flush());
1739 } 1739 }
1740 } 1740 }
1741 1741
1742 void GLRenderer::DiscardBackbuffer() { 1742 void GLRenderer::DiscardBackbuffer() {
1743 if (is_backbuffer_discarded_) 1743 if (is_backbuffer_discarded_)
(...skipping 25 matching lines...) Expand all
1769 return; 1769 return;
1770 1770
1771 MakeContextCurrent(); 1771 MakeContextCurrent();
1772 1772
1773 bool do_workaround = NeedsIOSurfaceReadbackWorkaround(); 1773 bool do_workaround = NeedsIOSurfaceReadbackWorkaround();
1774 1774
1775 GLuint temporary_texture = 0; 1775 GLuint temporary_texture = 0;
1776 GLuint temporary_fbo = 0; 1776 GLuint temporary_fbo = 0;
1777 1777
1778 if (do_workaround) { 1778 if (do_workaround) {
1779 // On Mac OS X, calling glReadPixels against an FBO whose color attachment 1779 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment
1780 // is an IOSurface-backed texture causes corruption of future glReadPixels 1780 // is an IOSurface-backed texture causes corruption of future glReadPixels()
1781 // calls, even those on different OpenGL contexts. It is believed that this 1781 // calls, even those on different OpenGL contexts. It is believed that this
1782 // is the root cause of top crasher 1782 // is the root cause of top crasher
1783 // http://crbug.com/99393. <rdar://problem/10949687> 1783 // http://crbug.com/99393. <rdar://problem/10949687>
1784 1784
1785 temporary_texture = context_->createTexture(); 1785 temporary_texture = context_->createTexture();
1786 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture)); 1786 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture));
1787 GLC(context_, 1787 GLC(context_,
1788 context_->texParameteri( 1788 context_->texParameteri(
1789 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 1789 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
1790 GLC(context_, 1790 GLC(context_,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 } 1940 }
1941 1941
1942 void GLRenderer::SetDrawViewportSize(gfx::Size viewport_size) { 1942 void GLRenderer::SetDrawViewportSize(gfx::Size viewport_size) {
1943 GLC(context_, 1943 GLC(context_,
1944 context_->viewport(0, 0, viewport_size.width(), viewport_size.height())); 1944 context_->viewport(0, 0, viewport_size.width(), viewport_size.height()));
1945 } 1945 }
1946 1946
1947 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); } 1947 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); }
1948 1948
1949 bool GLRenderer::InitializeSharedObjects() { 1949 bool GLRenderer::InitializeSharedObjects() {
1950 TRACE_EVENT0("cc", "GLRenderer::initializeSharedObjects"); 1950 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
1951 MakeContextCurrent(); 1951 MakeContextCurrent();
1952 1952
1953 // Create an FBO for doing offscreen rendering. 1953 // Create an FBO for doing offscreen rendering.
1954 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); 1954 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer());
1955 1955
1956 // We will always need these programs to render, so create the programs 1956 // We will always need these programs to render, so create the programs
1957 // eagerly so that the shader compilation can start while we do other work. 1957 // eagerly so that the shader compilation can start while we do other work.
1958 // Other programs are created lazily on first access. 1958 // Other programs are created lazily on first access.
1959 shared_geometry_ = 1959 shared_geometry_ =
1960 make_scoped_ptr(new GeometryBinding(context_, QuadVertexRect())); 1960 make_scoped_ptr(new GeometryBinding(context_, QuadVertexRect()));
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); 2225 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_));
2226 2226
2227 ReleaseRenderPassTextures(); 2227 ReleaseRenderPassTextures();
2228 } 2228 }
2229 2229
2230 bool GLRenderer::IsContextLost() { 2230 bool GLRenderer::IsContextLost() {
2231 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); 2231 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR);
2232 } 2232 }
2233 2233
2234 } // namespace cc 2234 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698