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