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

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 165064 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(), sou rceTexture->size(), filterContext, filterGrContext); 375 SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), sou rceTexture->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(), cc::IntRect(device Rect))) 468 if (!getFramebufferTexture(deviceBackgroundTexture.get(), cc::IntRect(device Rect)))
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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 template<class Program> void set(Program* program) 948 template<class Program> void set(Program* program)
950 { 949 {
951 TextureProgramBinding::set(program); 950 TextureProgramBinding::set(program);
952 texTransformLocation = program->vertexShader().texTransformLocation(); 951 texTransformLocation = program->vertexShader().texTransformLocation();
953 } 952 }
954 int texTransformLocation; 953 int texTransformLocation;
955 }; 954 };
956 955
957 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad) 956 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad)
958 { 957 {
959 DCHECK(Proxy::isImplThread());
960
961 TexTransformTextureProgramBinding binding; 958 TexTransformTextureProgramBinding binding;
962 if (quad->flipped()) 959 if (quad->flipped())
963 binding.set(textureProgramFlip()); 960 binding.set(textureProgramFlip());
964 else 961 else
965 binding.set(textureProgram()); 962 binding.set(textureProgram());
966 GLC(context(), context()->useProgram(binding.programId)); 963 GLC(context(), context()->useProgram(binding.programId));
967 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 964 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
968 const gfx::RectF& uvRect = quad->uvRect(); 965 const gfx::RectF& uvRect = quad->uvRect();
969 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); 966 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height()));
970 967
(...skipping 22 matching lines...) Expand all
993 990
994 setShaderOpacity(quad->opacity(), binding.alphaLocation); 991 setShaderOpacity(quad->opacity(), binding.alphaLocation);
995 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation); 992 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation);
996 993
997 if (!quad->premultipliedAlpha()) 994 if (!quad->premultipliedAlpha())
998 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 995 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
999 } 996 }
1000 997
1001 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad) 998 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad)
1002 { 999 {
1003 DCHECK(Proxy::isImplThread());
1004 TexTransformTextureProgramBinding binding; 1000 TexTransformTextureProgramBinding binding;
1005 binding.set(textureIOSurfaceProgram()); 1001 binding.set(textureIOSurfaceProgram());
1006 1002
1007 GLC(context(), context()->useProgram(binding.programId)); 1003 GLC(context(), context()->useProgram(binding.programId));
1008 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 1004 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
1009 if (quad->orientation() == IOSurfaceDrawQuad::Flipped) 1005 if (quad->orientation() == IOSurfaceDrawQuad::Flipped)
1010 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0)); 1006 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0));
1011 else 1007 else
1012 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height())); 1008 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height()));
1013 1009
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 return true; 1131 return true;
1136 } 1132 }
1137 1133
1138 void GLRenderer::onSwapBuffersComplete() 1134 void GLRenderer::onSwapBuffersComplete()
1139 { 1135 {
1140 m_client->onSwapBuffersComplete(); 1136 m_client->onSwapBuffersComplete();
1141 } 1137 }
1142 1138
1143 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n) 1139 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n)
1144 { 1140 {
1145 // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread. 1141 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer;
1146 if (!Proxy::hasImplThread()) {
1147 DCHECK(Proxy::isMainThread());
1148 DebugScopedSetImplThread impl;
1149 onMemoryAllocationChangedOnImplThread(allocation);
1150 } else {
1151 DCHECK(Proxy::isImplThread());
1152 onMemoryAllocationChangedOnImplThread(allocation);
1153 }
1154 }
1155
1156 int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::Priorit yCutoff priorityCutoff)
1157 {
1158 switch (priorityCutoff) {
1159 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing:
1160 return PriorityCalculator::allowNothingCutoff();
1161 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly:
1162 return PriorityCalculator::allowVisibleOnlyCutoff();
1163 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearb y:
1164 return PriorityCalculator::allowVisibleAndNearbyCutoff();
1165 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
1166 return PriorityCalculator::allowEverythingCutoff();
1167 }
1168 NOTREACHED();
1169 return 0;
1170 }
1171
1172 void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemory Allocation allocation)
1173 {
1174 // Just ignore the memory manager when it says to set the limit to zero 1142 // Just ignore the memory manager when it says to set the limit to zero
1175 // bytes. This will happen when the memory manager thinks that the renderer 1143 // bytes. This will happen when the memory manager thinks that the renderer
1176 // is not visible (which the renderer knows better). 1144 // is not visible (which the renderer knows better).
1177 if (allocation.bytesLimitWhenVisible) { 1145 if (allocation.bytesLimitWhenVisible) {
1178 ManagedMemoryPolicy policy( 1146 ManagedMemoryPolicy policy(
1179 allocation.bytesLimitWhenVisible, 1147 allocation.bytesLimitWhenVisible,
1180 priorityCutoffValue(allocation.priorityCutoffWhenVisible), 1148 priorityCutoffValue(allocation.priorityCutoffWhenVisible),
1181 allocation.bytesLimitWhenNotVisible, 1149 allocation.bytesLimitWhenNotVisible,
1182 priorityCutoffValue(allocation.priorityCutoffWhenNotVisible)); 1150 priorityCutoffValue(allocation.priorityCutoffWhenNotVisible));
1183 1151
1184 if (allocation.enforceButDoNotKeepAsPolicy) 1152 if (allocation.enforceButDoNotKeepAsPolicy)
1185 m_client->enforceManagedMemoryPolicy(policy); 1153 m_client->enforceManagedMemoryPolicy(policy);
1186 else 1154 else
1187 m_client->setManagedMemoryPolicy(policy); 1155 m_client->setManagedMemoryPolicy(policy);
1188 } 1156 }
1189 1157
1190 bool oldDiscardFramebufferWhenNotVisible = m_discardFramebufferWhenNotVisibl e; 1158 bool oldDiscardFramebufferWhenNotVisible = m_discardFramebufferWhenNotVisibl e;
1191 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer; 1159 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer;
1192 enforceMemoryPolicy(); 1160 enforceMemoryPolicy();
1193 if (allocation.enforceButDoNotKeepAsPolicy) 1161 if (allocation.enforceButDoNotKeepAsPolicy)
1194 m_discardFramebufferWhenNotVisible = oldDiscardFramebufferWhenNotVisible ; 1162 m_discardFramebufferWhenNotVisible = oldDiscardFramebufferWhenNotVisible ;
1195 } 1163 }
1196 1164
1165 int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::Priorit yCutoff priorityCutoff)
1166 {
1167 switch (priorityCutoff) {
1168 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing:
1169 return PriorityCalculator::allowNothingCutoff();
1170 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly:
1171 return PriorityCalculator::allowVisibleOnlyCutoff();
1172 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearb y:
1173 return PriorityCalculator::allowVisibleAndNearbyCutoff();
1174 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
1175 return PriorityCalculator::allowEverythingCutoff();
1176 }
1177 NOTREACHED();
1178 return 0;
1179 }
1180
1197 void GLRenderer::enforceMemoryPolicy() 1181 void GLRenderer::enforceMemoryPolicy()
1198 { 1182 {
1199 if (!m_visible) { 1183 if (!m_visible) {
1200 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources") ; 1184 TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources") ;
1201 releaseRenderPassTextures(); 1185 releaseRenderPassTextures();
1202 if (m_discardFramebufferWhenNotVisible) 1186 if (m_discardFramebufferWhenNotVisible)
1203 discardFramebuffer(); 1187 discardFramebuffer();
1204 GLC(m_context, m_context->flush()); 1188 GLC(m_context, m_context->flush());
1205 } 1189 }
1206 } 1190 }
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 1612
1629 releaseRenderPassTextures(); 1613 releaseRenderPassTextures();
1630 } 1614 }
1631 1615
1632 bool GLRenderer::isContextLost() 1616 bool GLRenderer::isContextLost()
1633 { 1617 {
1634 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1618 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1635 } 1619 }
1636 1620
1637 } // namespace cc 1621 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698