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

Side by Side Diff: cc/gl_renderer.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 165444 Created 8 years, 1 month 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 // 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/gl_renderer.h" 7 #include "cc/gl_renderer.h"
8 8
9 #include "FloatQuad.h" 9 #include "FloatQuad.h"
10 #include "NotImplemented.h" 10 #include "NotImplemented.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 m_capabilities.usingAcceleratedPainting = true; 105 m_capabilities.usingAcceleratedPainting = true;
106 else 106 else
107 m_capabilities.usingAcceleratedPainting = false; 107 m_capabilities.usingAcceleratedPainting = false;
108 108
109 109
110 m_capabilities.contextHasCachedFrontBuffer = extensions.count("GL_CHROMIUM_f ront_buffer_cached"); 110 m_capabilities.contextHasCachedFrontBuffer = extensions.count("GL_CHROMIUM_f ront_buffer_cached");
111 111
112 m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensio ns.count("GL_CHROMIUM_post_sub_buffer"); 112 m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensio ns.count("GL_CHROMIUM_post_sub_buffer");
113 113
114 // Use the swapBuffers callback only with the threaded proxy. 114 // Use the swapBuffers callback only with the threaded proxy.
115 if (Proxy::hasImplThread()) 115 if (m_client->hasImplThread())
116 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback"); 116 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback");
117 if (m_capabilities.usingSwapCompleteCallback) 117 if (m_capabilities.usingSwapCompleteCallback)
118 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); 118 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this);
119 119
120 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity"); 120 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity");
121 121
122 if (extensions.count("GL_CHROMIUM_iosurface")) 122 if (extensions.count("GL_CHROMIUM_iosurface"))
123 DCHECK(extensions.count("GL_ARB_texture_rectangle")); 123 DCHECK(extensions.count("GL_ARB_texture_rectangle"));
124 124
125 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager"); 125 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager");
(...skipping 12 matching lines...) Expand all
138 if (!initializeSharedObjects()) 138 if (!initializeSharedObjects())
139 return false; 139 return false;
140 140
141 // Make sure the viewport and context gets initialized, even if it is to zer o. 141 // Make sure the viewport and context gets initialized, even if it is to zer o.
142 viewportChanged(); 142 viewportChanged();
143 return true; 143 return true;
144 } 144 }
145 145
146 GLRenderer::~GLRenderer() 146 GLRenderer::~GLRenderer()
147 { 147 {
148 DCHECK(Proxy::isImplThread());
149 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); 148 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
150 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); 149 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
151 m_context->setContextLostCallback(0); 150 m_context->setContextLostCallback(0);
152 cleanupSharedObjects(); 151 cleanupSharedObjects();
153 } 152 }
154 153
155 const RendererCapabilities& GLRenderer::capabilities() const 154 const RendererCapabilities& GLRenderer::capabilities() const
156 { 155 {
157 return m_capabilities; 156 return m_capabilities;
158 } 157 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 float alpha = SkColorGetA(color) / 255.0; 335 float alpha = SkColorGetA(color) / 255.0;
337 336
338 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha)); 337 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha));
339 338
340 GLC(context(), context()->lineWidth(quad->width())); 339 GLC(context(), context()->lineWidth(quad->width()));
341 340
342 // The indices for the line are stored in the same array as the triangle ind ices. 341 // The indices for the line are stored in the same array as the triangle ind ices.
343 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short))); 342 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short)));
344 } 343 }
345 344
346 static WebGraphicsContext3D* getFilterContext() 345 static WebGraphicsContext3D* getFilterContext(bool hasImplThread)
347 { 346 {
348 if (Proxy::hasImplThread()) 347 if (hasImplThread)
349 return WebSharedGraphicsContext3D::compositorThreadContext(); 348 return WebSharedGraphicsContext3D::compositorThreadContext();
350 else 349 else
351 return WebSharedGraphicsContext3D::mainThreadContext(); 350 return WebSharedGraphicsContext3D::mainThreadContext();
352 } 351 }
353 352
354 static GrContext* getFilterGrContext() 353 static GrContext* getFilterGrContext(bool hasImplThread)
355 { 354 {
356 if (Proxy::hasImplThread()) 355 if (hasImplThread)
357 return WebSharedGraphicsContext3D::compositorThreadGrContext(); 356 return WebSharedGraphicsContext3D::compositorThreadGrContext();
358 else 357 else
359 return WebSharedGraphicsContext3D::mainThreadGrContext(); 358 return WebSharedGraphicsContext3D::mainThreadGrContext();
360 } 359 }
361 360
362 static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte rOperations& filters, ScopedTexture* sourceTexture) 361 static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte rOperations& filters, ScopedTexture* sourceTexture, bool hasImplThread)
363 { 362 {
364 if (filters.isEmpty()) 363 if (filters.isEmpty())
365 return SkBitmap(); 364 return SkBitmap();
366 365
367 WebGraphicsContext3D* filterContext = getFilterContext(); 366 WebGraphicsContext3D* filterContext = getFilterContext(hasImplThread);
368 GrContext* filterGrContext = getFilterGrContext(); 367 GrContext* filterGrContext = getFilterGrContext(hasImplThread);
369 368
370 if (!filterContext || !filterGrContext) 369 if (!filterContext || !filterGrContext)
371 return SkBitmap(); 370 return SkBitmap();
372 371
373 renderer->context()->flush(); 372 renderer->context()->flush();
374 373
375 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id()); 374 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id());
376 SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), cc: :IntSize(sourceTexture->size()), filterContext, filterGrContext); 375 SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), cc: :IntSize(sourceTexture->size()), filterContext, filterGrContext);
377 return source; 376 return source;
378 } 377 }
379 378
380 static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc opedTexture* sourceTexture) 379 static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc opedTexture* sourceTexture, bool hasImplThread)
381 { 380 {
382 if (!filter) 381 if (!filter)
383 return SkBitmap(); 382 return SkBitmap();
384 383
385 WebGraphicsContext3D* context3d = getFilterContext(); 384 WebGraphicsContext3D* context3d = getFilterContext(hasImplThread);
386 GrContext* grContext = getFilterGrContext(); 385 GrContext* grContext = getFilterGrContext(hasImplThread);
387 386
388 if (!context3d || !grContext) 387 if (!context3d || !grContext)
389 return SkBitmap(); 388 return SkBitmap();
390 389
391 renderer->context()->flush(); 390 renderer->context()->flush();
392 391
393 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id()); 392 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id());
394 393
395 // Wrap the source texture in a Ganesh platform texture. 394 // Wrap the source texture in a Ganesh platform texture.
396 GrPlatformTextureDesc platformTextureDescription; 395 GrPlatformTextureDesc platformTextureDescription;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 int top, right, bottom, left; 461 int top, right, bottom, left;
463 filters.getOutsets(top, right, bottom, left); 462 filters.getOutsets(top, right, bottom, left);
464 deviceRect.Inset(-left, -top, -right, -bottom); 463 deviceRect.Inset(-left, -top, -right, -bottom);
465 464
466 deviceRect.Intersect(frame.currentRenderPass->outputRect()); 465 deviceRect.Intersect(frame.currentRenderPass->outputRect());
467 466
468 scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_ resourceProvider); 467 scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_ resourceProvider);
469 if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect)) 468 if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
470 return scoped_ptr<ScopedTexture>(); 469 return scoped_ptr<ScopedTexture>();
471 470
472 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr oundTexture.get()); 471 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr oundTexture.get(), m_client->hasImplThread());
473 if (!filteredDeviceBackground.getTexture()) 472 if (!filteredDeviceBackground.getTexture())
474 return scoped_ptr<ScopedTexture>(); 473 return scoped_ptr<ScopedTexture>();
475 474
476 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g etTexture()); 475 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g etTexture());
477 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); 476 int filteredDeviceBackgroundTextureId = texture->getTextureHandle();
478 477
479 scoped_ptr<ScopedTexture> backgroundTexture = ScopedTexture::create(m_resour ceProvider); 478 scoped_ptr<ScopedTexture> backgroundTexture = ScopedTexture::create(m_resour ceProvider);
480 if (!backgroundTexture->allocate(Renderer::ImplPool, cc::IntSize(quad->quadR ect().size()), GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) 479 if (!backgroundTexture->allocate(Renderer::ImplPool, cc::IntSize(quad->quadR ect().size()), GL_RGBA, ResourceProvider::TextureUsageFramebuffer))
481 return scoped_ptr<ScopedTexture>(); 480 return scoped_ptr<ScopedTexture>();
482 481
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 // Can only draw surface if device matrix is invertible. 516 // Can only draw surface if device matrix is invertible.
518 if (!contentsDeviceTransform.isInvertible()) 517 if (!contentsDeviceTransform.isInvertible())
519 return; 518 return;
520 519
521 scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters(frame, q uad, renderPass->backgroundFilters(), contentsDeviceTransform); 520 scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters(frame, q uad, renderPass->backgroundFilters(), contentsDeviceTransform);
522 521
523 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica. 522 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica.
524 // Apply filters to the contents texture. 523 // Apply filters to the contents texture.
525 SkBitmap filterBitmap; 524 SkBitmap filterBitmap;
526 if (renderPass->filter()) { 525 if (renderPass->filter()) {
527 filterBitmap = applyImageFilter(this, renderPass->filter(), contentsText ure); 526 filterBitmap = applyImageFilter(this, renderPass->filter(), contentsText ure, m_client->hasImplThread());
528 } else { 527 } else {
529 filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture ); 528 filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture , m_client->hasImplThread());
530 } 529 }
531 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; 530 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock;
532 unsigned contentsTextureId = 0; 531 unsigned contentsTextureId = 0;
533 if (filterBitmap.getTexture()) { 532 if (filterBitmap.getTexture()) {
534 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e()); 533 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e());
535 contentsTextureId = texture->getTextureHandle(); 534 contentsTextureId = texture->getTextureHandle();
536 } else { 535 } else {
537 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id())); 536 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id()));
538 contentsTextureId = contentsResourceLock->textureId(); 537 contentsTextureId = contentsResourceLock->textureId();
539 } 538 }
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 template<class Program> void set(Program* program) 946 template<class Program> void set(Program* program)
948 { 947 {
949 TextureProgramBinding::set(program); 948 TextureProgramBinding::set(program);
950 texTransformLocation = program->vertexShader().texTransformLocation(); 949 texTransformLocation = program->vertexShader().texTransformLocation();
951 } 950 }
952 int texTransformLocation; 951 int texTransformLocation;
953 }; 952 };
954 953
955 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad) 954 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad)
956 { 955 {
957 DCHECK(Proxy::isImplThread());
958
959 TexTransformTextureProgramBinding binding; 956 TexTransformTextureProgramBinding binding;
960 if (quad->flipped()) 957 if (quad->flipped())
961 binding.set(textureProgramFlip()); 958 binding.set(textureProgramFlip());
962 else 959 else
963 binding.set(textureProgram()); 960 binding.set(textureProgram());
964 GLC(context(), context()->useProgram(binding.programId)); 961 GLC(context(), context()->useProgram(binding.programId));
965 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 962 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
966 const gfx::RectF& uvRect = quad->uvRect(); 963 const gfx::RectF& uvRect = quad->uvRect();
967 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); 964 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height()));
968 965
(...skipping 22 matching lines...) Expand all
991 988
992 setShaderOpacity(quad->opacity(), binding.alphaLocation); 989 setShaderOpacity(quad->opacity(), binding.alphaLocation);
993 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation); 990 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation);
994 991
995 if (!quad->premultipliedAlpha()) 992 if (!quad->premultipliedAlpha())
996 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 993 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
997 } 994 }
998 995
999 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad) 996 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad)
1000 { 997 {
1001 DCHECK(Proxy::isImplThread());
1002 TexTransformTextureProgramBinding binding; 998 TexTransformTextureProgramBinding binding;
1003 binding.set(textureIOSurfaceProgram()); 999 binding.set(textureIOSurfaceProgram());
1004 1000
1005 GLC(context(), context()->useProgram(binding.programId)); 1001 GLC(context(), context()->useProgram(binding.programId));
1006 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 1002 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
1007 if (quad->orientation() == IOSurfaceDrawQuad::Flipped) 1003 if (quad->orientation() == IOSurfaceDrawQuad::Flipped)
1008 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0)); 1004 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0));
1009 else 1005 else
1010 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height())); 1006 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height()));
1011 1007
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 return true; 1129 return true;
1134 } 1130 }
1135 1131
1136 void GLRenderer::onSwapBuffersComplete() 1132 void GLRenderer::onSwapBuffersComplete()
1137 { 1133 {
1138 m_client->onSwapBuffersComplete(); 1134 m_client->onSwapBuffersComplete();
1139 } 1135 }
1140 1136
1141 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n) 1137 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n)
1142 { 1138 {
1143 // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread.
1144 if (!Proxy::hasImplThread()) {
1145 DCHECK(Proxy::isMainThread());
1146 DebugScopedSetImplThread impl;
1147 onMemoryAllocationChangedOnImplThread(allocation);
1148 } else {
1149 DCHECK(Proxy::isImplThread());
1150 onMemoryAllocationChangedOnImplThread(allocation);
1151 }
1152 }
1153
1154 int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::Priorit yCutoff priorityCutoff)
1155 {
1156 switch (priorityCutoff) {
1157 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing:
1158 return PriorityCalculator::allowNothingCutoff();
1159 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly:
1160 return PriorityCalculator::allowVisibleOnlyCutoff();
1161 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearb y:
1162 return PriorityCalculator::allowVisibleAndNearbyCutoff();
1163 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
1164 return PriorityCalculator::allowEverythingCutoff();
1165 }
1166 NOTREACHED();
1167 return 0;
1168 }
1169
1170 void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemory Allocation allocation)
1171 {
1172 // Just ignore the memory manager when it says to set the limit to zero 1139 // Just ignore the memory manager when it says to set the limit to zero
1173 // bytes. This will happen when the memory manager thinks that the renderer 1140 // bytes. This will happen when the memory manager thinks that the renderer
1174 // is not visible (which the renderer knows better). 1141 // is not visible (which the renderer knows better).
1175 if (allocation.bytesLimitWhenVisible) { 1142 if (allocation.bytesLimitWhenVisible) {
1176 ManagedMemoryPolicy policy( 1143 ManagedMemoryPolicy policy(
1177 allocation.bytesLimitWhenVisible, 1144 allocation.bytesLimitWhenVisible,
1178 priorityCutoffValue(allocation.priorityCutoffWhenVisible), 1145 priorityCutoffValue(allocation.priorityCutoffWhenVisible),
1179 allocation.bytesLimitWhenNotVisible, 1146 allocation.bytesLimitWhenNotVisible,
1180 priorityCutoffValue(allocation.priorityCutoffWhenNotVisible)); 1147 priorityCutoffValue(allocation.priorityCutoffWhenNotVisible));
1181 1148
1182 if (allocation.enforceButDoNotKeepAsPolicy) 1149 if (allocation.enforceButDoNotKeepAsPolicy)
1183 m_client->enforceManagedMemoryPolicy(policy); 1150 m_client->enforceManagedMemoryPolicy(policy);
1184 else 1151 else
1185 m_client->setManagedMemoryPolicy(policy); 1152 m_client->setManagedMemoryPolicy(policy);
1186 } 1153 }
1187 1154
1188 bool oldDiscardFramebufferWhenNotVisible = m_discardFramebufferWhenNotVisibl e; 1155 bool oldDiscardFramebufferWhenNotVisible = m_discardFramebufferWhenNotVisibl e;
1189 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer; 1156 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer;
1190 enforceMemoryPolicy(); 1157 enforceMemoryPolicy();
1191 if (allocation.enforceButDoNotKeepAsPolicy) 1158 if (allocation.enforceButDoNotKeepAsPolicy)
1192 m_discardFramebufferWhenNotVisible = oldDiscardFramebufferWhenNotVisible ; 1159 m_discardFramebufferWhenNotVisible = oldDiscardFramebufferWhenNotVisible ;
1193 } 1160 }
1194 1161
1162 int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::Priorit yCutoff priorityCutoff)
1163 {
1164 switch (priorityCutoff) {
1165 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing:
1166 return PriorityCalculator::allowNothingCutoff();
1167 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly:
1168 return PriorityCalculator::allowVisibleOnlyCutoff();
1169 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearb y:
1170 return PriorityCalculator::allowVisibleAndNearbyCutoff();
1171 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
1172 return PriorityCalculator::allowEverythingCutoff();
1173 }
1174 NOTREACHED();
1175 return 0;
1176 }
1177
1195 void GLRenderer::enforceMemoryPolicy() 1178 void GLRenderer::enforceMemoryPolicy()
1196 { 1179 {
1197 if (!m_visible) { 1180 if (!m_visible) {
1198 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources") ; 1181 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources") ;
1199 releaseRenderPassTextures(); 1182 releaseRenderPassTextures();
1200 if (m_discardFramebufferWhenNotVisible) 1183 if (m_discardFramebufferWhenNotVisible)
1201 discardFramebuffer(); 1184 discardFramebuffer();
1202 GLC(m_context, m_context->flush()); 1185 GLC(m_context, m_context->flush());
1203 } 1186 }
1204 } 1187 }
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1609
1627 releaseRenderPassTextures(); 1610 releaseRenderPassTextures();
1628 } 1611 }
1629 1612
1630 bool GLRenderer::isContextLost() 1613 bool GLRenderer::isContextLost()
1631 { 1614 {
1632 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1615 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1633 } 1616 }
1634 1617
1635 } // namespace cc 1618 } // namespace cc
OLDNEW
« cc/frame_rate_counter.cc ('K') | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698