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

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
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 // set up premultiplied alpha. 1332 // set up premultiplied alpha.
1333 if (!draw_cache_.use_premultiplied_alpha) { 1333 if (!draw_cache_.use_premultiplied_alpha) {
1334 // As it turns out, the premultiplied alpha blending function (ONE, 1334 // As it turns out, the premultiplied alpha blending function (ONE,
1335 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to 1335 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to
1336 // anything less than 1.0f if it is initialized to that value! Therefore, 1336 // anything less than 1.0f if it is initialized to that value! Therefore,
1337 // premultiplied_alpha being false is the first situation we can generally 1337 // premultiplied_alpha being false is the first situation we can generally
1338 // see an alpha channel less than 1.0f coming out of the compositor. This is 1338 // see an alpha channel less than 1.0f coming out of the compositor. This is
1339 // causing platform differences in some layout tests (see 1339 // causing platform differences in some layout tests (see
1340 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use 1340 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use
1341 // a separate blend function for the alpha channel to avoid modifying it. 1341 // a separate blend function for the alpha channel to avoid modifying it.
1342 // Don't use colorMask for this as it has performance implications on some 1342 // Don't use colorMask() for this as it has performance implications on some
1343 // platforms. 1343 // platforms.
1344 GLC(Context(), 1344 GLC(Context(),
1345 Context()->blendFuncSeparate( 1345 Context()->blendFuncSeparate(
1346 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE)); 1346 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE));
1347 } 1347 }
1348 1348
1349 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed); 1349 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed);
1350 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float), 1350 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float),
1351 struct_is_densely_packed); 1351 struct_is_densely_packed);
1352 1352
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 1464
1465 if (!quad->premultiplied_alpha) { 1465 if (!quad->premultiplied_alpha) {
1466 // As it turns out, the premultiplied alpha blending function (ONE, 1466 // As it turns out, the premultiplied alpha blending function (ONE,
1467 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to 1467 // ONE_MINUS_SRC_ALPHA) will never cause the alpha channel to be set to
1468 // anything less than 1.0f if it is initialized to that value! Therefore, 1468 // anything less than 1.0f if it is initialized to that value! Therefore,
1469 // premultiplied_alpha being false is the first situation we can generally 1469 // premultiplied_alpha being false is the first situation we can generally
1470 // see an alpha channel less than 1.0f coming out of the compositor. This is 1470 // see an alpha channel less than 1.0f coming out of the compositor. This is
1471 // causing platform differences in some layout tests (see 1471 // causing platform differences in some layout tests (see
1472 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use 1472 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use
1473 // a separate blend function for the alpha channel to avoid modifying it. 1473 // a separate blend function for the alpha channel to avoid modifying it.
1474 // Don't use colorMask for this as it has performance implications on some 1474 // Don't use colorMask() for this as it has performance implications on some
1475 // platforms. 1475 // platforms.
1476 GLC(Context(), 1476 GLC(Context(),
1477 Context()->blendFuncSeparate( 1477 Context()->blendFuncSeparate(
1478 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE)); 1478 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE));
1479 } 1479 }
1480 1480
1481 DrawQuadGeometry( 1481 DrawQuadGeometry(
1482 frame, quad->quadTransform(), quad->rect, binding.matrix_location); 1482 frame, quad->quadTransform(), quad->rect, binding.matrix_location);
1483 1483
1484 if (!quad->premultiplied_alpha) 1484 if (!quad->premultiplied_alpha)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1643
1644 void GLRenderer::Finish() { 1644 void GLRenderer::Finish() {
1645 TRACE_EVENT0("cc", "GLRenderer::finish"); 1645 TRACE_EVENT0("cc", "GLRenderer::finish");
1646 context_->finish(); 1646 context_->finish();
1647 } 1647 }
1648 1648
1649 bool GLRenderer::SwapBuffers() { 1649 bool GLRenderer::SwapBuffers() {
1650 DCHECK(visible_); 1650 DCHECK(visible_);
1651 DCHECK(!is_backbuffer_discarded_); 1651 DCHECK(!is_backbuffer_discarded_);
1652 1652
1653 TRACE_EVENT0("cc", "GLRenderer::swapBuffers"); 1653 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers");
1654 // We're done! Time to swapbuffers! 1654 // We're done! Time to swapbuffers!
1655 1655
1656 if (capabilities_.using_partial_swap) { 1656 if (capabilities_.using_partial_swap) {
1657 // If supported, we can save significant bandwidth by only swapping the 1657 // If supported, we can save significant bandwidth by only swapping the
1658 // damaged/scissored region (clamped to the viewport) 1658 // damaged/scissored region (clamped to the viewport)
1659 swap_buffer_rect_.Intersect(gfx::Rect(gfx::Point(), ViewportSize())); 1659 swap_buffer_rect_.Intersect(gfx::Rect(gfx::Point(), ViewportSize()));
1660 int flipped_y_pos_of_rect_bottom = 1660 int flipped_y_pos_of_rect_bottom =
1661 ViewportHeight() - swap_buffer_rect_.y() - swap_buffer_rect_.height(); 1661 ViewportHeight() - swap_buffer_rect_.y() - swap_buffer_rect_.height();
1662 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(), 1662 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(),
1663 flipped_y_pos_of_rect_bottom, 1663 flipped_y_pos_of_rect_bottom,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 return ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; 1727 return ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE;
1728 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: 1728 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
1729 return ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING; 1729 return ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING;
1730 } 1730 }
1731 NOTREACHED(); 1731 NOTREACHED();
1732 return ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; 1732 return ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING;
1733 } 1733 }
1734 1734
1735 void GLRenderer::EnforceMemoryPolicy() { 1735 void GLRenderer::EnforceMemoryPolicy() {
1736 if (!visible_) { 1736 if (!visible_) {
1737 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources"); 1737 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources");
1738 ReleaseRenderPassTextures(); 1738 ReleaseRenderPassTextures();
1739 if (discard_backbuffer_when_not_visible_) 1739 if (discard_backbuffer_when_not_visible_)
1740 DiscardBackbuffer(); 1740 DiscardBackbuffer();
1741 resource_provider_->ReleaseCachedData(); 1741 resource_provider_->ReleaseCachedData();
1742 GLC(context_, context_->flush()); 1742 GLC(context_, context_->flush());
1743 } 1743 }
1744 } 1744 }
1745 1745
1746 void GLRenderer::DiscardBackbuffer() { 1746 void GLRenderer::DiscardBackbuffer() {
1747 if (is_backbuffer_discarded_) 1747 if (is_backbuffer_discarded_)
(...skipping 25 matching lines...) Expand all
1773 return; 1773 return;
1774 1774
1775 MakeContextCurrent(); 1775 MakeContextCurrent();
1776 1776
1777 bool do_workaround = NeedsIOSurfaceReadbackWorkaround(); 1777 bool do_workaround = NeedsIOSurfaceReadbackWorkaround();
1778 1778
1779 GLuint temporary_texture = 0; 1779 GLuint temporary_texture = 0;
1780 GLuint temporary_fbo = 0; 1780 GLuint temporary_fbo = 0;
1781 1781
1782 if (do_workaround) { 1782 if (do_workaround) {
1783 // On Mac OS X, calling glReadPixels against an FBO whose color attachment 1783 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment
1784 // is an IOSurface-backed texture causes corruption of future glReadPixels 1784 // is an IOSurface-backed texture causes corruption of future glReadPixels()
1785 // calls, even those on different OpenGL contexts. It is believed that this 1785 // calls, even those on different OpenGL contexts. It is believed that this
1786 // is the root cause of top crasher 1786 // is the root cause of top crasher
1787 // http://crbug.com/99393. <rdar://problem/10949687> 1787 // http://crbug.com/99393. <rdar://problem/10949687>
1788 1788
1789 temporary_texture = context_->createTexture(); 1789 temporary_texture = context_->createTexture();
1790 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture)); 1790 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture));
1791 GLC(context_, 1791 GLC(context_,
1792 context_->texParameteri( 1792 context_->texParameteri(
1793 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 1793 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
1794 GLC(context_, 1794 GLC(context_,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 } 1944 }
1945 1945
1946 void GLRenderer::SetDrawViewportSize(gfx::Size viewport_size) { 1946 void GLRenderer::SetDrawViewportSize(gfx::Size viewport_size) {
1947 GLC(context_, 1947 GLC(context_,
1948 context_->viewport(0, 0, viewport_size.width(), viewport_size.height())); 1948 context_->viewport(0, 0, viewport_size.width(), viewport_size.height()));
1949 } 1949 }
1950 1950
1951 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); } 1951 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); }
1952 1952
1953 bool GLRenderer::InitializeSharedObjects() { 1953 bool GLRenderer::InitializeSharedObjects() {
1954 TRACE_EVENT0("cc", "GLRenderer::initializeSharedObjects"); 1954 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
1955 MakeContextCurrent(); 1955 MakeContextCurrent();
1956 1956
1957 // Create an FBO for doing offscreen rendering. 1957 // Create an FBO for doing offscreen rendering.
1958 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); 1958 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer());
1959 1959
1960 // We will always need these programs to render, so create the programs 1960 // We will always need these programs to render, so create the programs
1961 // eagerly so that the shader compilation can start while we do other work. 1961 // eagerly so that the shader compilation can start while we do other work.
1962 // Other programs are created lazily on first access. 1962 // Other programs are created lazily on first access.
1963 shared_geometry_ = 1963 shared_geometry_ =
1964 make_scoped_ptr(new GeometryBinding(context_, QuadVertexRect())); 1964 make_scoped_ptr(new GeometryBinding(context_, QuadVertexRect()));
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); 2229 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_));
2230 2230
2231 ReleaseRenderPassTextures(); 2231 ReleaseRenderPassTextures();
2232 } 2232 }
2233 2233
2234 bool GLRenderer::IsContextLost() { 2234 bool GLRenderer::IsContextLost() {
2235 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); 2235 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR);
2236 } 2236 }
2237 2237
2238 } // namespace cc 2238 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698