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 "CCDamageTracker.h" | 9 #include "CCDamageTracker.h" |
10 #include "FloatQuad.h" | 10 #include "FloatQuad.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 { | 57 { |
58 #if OS(DARWIN) | 58 #if OS(DARWIN) |
59 return true; | 59 return true; |
60 #else | 60 #else |
61 return false; | 61 return false; |
62 #endif | 62 #endif |
63 } | 63 } |
64 | 64 |
65 } // anonymous namespace | 65 } // anonymous namespace |
66 | 66 |
67 scoped_ptr<GLRenderer> GLRenderer::create(RendererClient* client, ResourceProvid er* resourceProvider) | 67 scoped_ptr<GLRenderer> GLRenderer::create(RendererClient* client, ResourceProvid er* resourceProvider, bool hasImplThread) |
68 { | 68 { |
69 scoped_ptr<GLRenderer> renderer(make_scoped_ptr(new GLRenderer(client, resou rceProvider))); | 69 scoped_ptr<GLRenderer> renderer(make_scoped_ptr(new GLRenderer(client, resou rceProvider, hasImplThread))); |
70 if (!renderer->initialize()) | 70 if (!renderer->initialize()) |
71 return scoped_ptr<GLRenderer>(); | 71 return scoped_ptr<GLRenderer>(); |
72 | 72 |
73 return renderer.Pass(); | 73 return renderer.Pass(); |
74 } | 74 } |
75 | 75 |
76 GLRenderer::GLRenderer(RendererClient* client, | 76 GLRenderer::GLRenderer(RendererClient* client, |
77 ResourceProvider* resourceProvider) | 77 ResourceProvider* resourceProvider, |
78 bool hasImplThread) | |
78 : DirectRenderer(client, resourceProvider) | 79 : DirectRenderer(client, resourceProvider) |
80 , m_hasImplThread(hasImplThread) | |
79 , m_offscreenFramebufferId(0) | 81 , m_offscreenFramebufferId(0) |
80 , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f)) | 82 , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f)) |
81 , m_context(resourceProvider->graphicsContext3D()) | 83 , m_context(resourceProvider->graphicsContext3D()) |
82 , m_isViewportChanged(false) | 84 , m_isViewportChanged(false) |
83 , m_isFramebufferDiscarded(false) | 85 , m_isFramebufferDiscarded(false) |
84 , m_discardFramebufferWhenNotVisible(false) | 86 , m_discardFramebufferWhenNotVisible(false) |
85 , m_isUsingBindUniform(false) | 87 , m_isUsingBindUniform(false) |
86 , m_visible(true) | 88 , m_visible(true) |
87 { | 89 { |
88 DCHECK(m_context); | 90 DCHECK(m_context); |
(...skipping 17 matching lines...) Expand all Loading... | |
106 m_capabilities.usingAcceleratedPainting = true; | 108 m_capabilities.usingAcceleratedPainting = true; |
107 else | 109 else |
108 m_capabilities.usingAcceleratedPainting = false; | 110 m_capabilities.usingAcceleratedPainting = false; |
109 | 111 |
110 | 112 |
111 m_capabilities.contextHasCachedFrontBuffer = extensions.count("GL_CHROMIUM_f ront_buffer_cached"); | 113 m_capabilities.contextHasCachedFrontBuffer = extensions.count("GL_CHROMIUM_f ront_buffer_cached"); |
112 | 114 |
113 m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensio ns.count("GL_CHROMIUM_post_sub_buffer"); | 115 m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensio ns.count("GL_CHROMIUM_post_sub_buffer"); |
114 | 116 |
115 // Use the swapBuffers callback only with the threaded proxy. | 117 // Use the swapBuffers callback only with the threaded proxy. |
116 if (Proxy::hasImplThread()) | 118 if (m_hasImplThread) |
117 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback"); | 119 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback"); |
118 if (m_capabilities.usingSwapCompleteCallback) | 120 if (m_capabilities.usingSwapCompleteCallback) |
119 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); | 121 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); |
120 | 122 |
121 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity"); | 123 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity"); |
122 | 124 |
123 if (extensions.count("GL_CHROMIUM_iosurface")) | 125 if (extensions.count("GL_CHROMIUM_iosurface")) |
124 DCHECK(extensions.count("GL_ARB_texture_rectangle")); | 126 DCHECK(extensions.count("GL_ARB_texture_rectangle")); |
125 | 127 |
126 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager"); | 128 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager"); |
(...skipping 12 matching lines...) Expand all Loading... | |
139 if (!initializeSharedObjects()) | 141 if (!initializeSharedObjects()) |
140 return false; | 142 return false; |
141 | 143 |
142 // Make sure the viewport and context gets initialized, even if it is to zer o. | 144 // Make sure the viewport and context gets initialized, even if it is to zer o. |
143 viewportChanged(); | 145 viewportChanged(); |
144 return true; | 146 return true; |
145 } | 147 } |
146 | 148 |
147 GLRenderer::~GLRenderer() | 149 GLRenderer::~GLRenderer() |
148 { | 150 { |
149 DCHECK(Proxy::isImplThread()); | |
150 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); | 151 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); |
151 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); | 152 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); |
152 m_context->setContextLostCallback(0); | 153 m_context->setContextLostCallback(0); |
153 cleanupSharedObjects(); | 154 cleanupSharedObjects(); |
154 } | 155 } |
155 | 156 |
156 const RendererCapabilities& GLRenderer::capabilities() const | 157 const RendererCapabilities& GLRenderer::capabilities() const |
157 { | 158 { |
158 return m_capabilities; | 159 return m_capabilities; |
159 } | 160 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 float alpha = SkColorGetA(color) / 255.0; | 328 float alpha = SkColorGetA(color) / 255.0; |
328 | 329 |
329 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha)); | 330 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha)); |
330 | 331 |
331 GLC(context(), context()->lineWidth(quad->width())); | 332 GLC(context(), context()->lineWidth(quad->width())); |
332 | 333 |
333 // The indices for the line are stored in the same array as the triangle ind ices. | 334 // The indices for the line are stored in the same array as the triangle ind ices. |
334 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short))); | 335 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short))); |
335 } | 336 } |
336 | 337 |
337 static WebGraphicsContext3D* getFilterContext() | 338 static WebGraphicsContext3D* getFilterContext(bool hasImplThread) |
338 { | 339 { |
339 if (Proxy::hasImplThread()) | 340 if (hasImplThread) |
340 return WebSharedGraphicsContext3D::compositorThreadContext(); | 341 return WebSharedGraphicsContext3D::compositorThreadContext(); |
341 else | 342 else |
342 return WebSharedGraphicsContext3D::mainThreadContext(); | 343 return WebSharedGraphicsContext3D::mainThreadContext(); |
343 } | 344 } |
344 | 345 |
345 static GrContext* getFilterGrContext() | 346 static GrContext* getFilterGrContext(bool hasImplThread) |
346 { | 347 { |
347 if (Proxy::hasImplThread()) | 348 if (hasImplThread) |
348 return WebSharedGraphicsContext3D::compositorThreadGrContext(); | 349 return WebSharedGraphicsContext3D::compositorThreadGrContext(); |
349 else | 350 else |
350 return WebSharedGraphicsContext3D::mainThreadGrContext(); | 351 return WebSharedGraphicsContext3D::mainThreadGrContext(); |
351 } | 352 } |
352 | 353 |
353 static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte rOperations& filters, ScopedTexture* sourceTexture) | 354 static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte rOperations& filters, ScopedTexture* sourceTexture, bool hasImplThread) |
354 { | 355 { |
355 if (filters.isEmpty()) | 356 if (filters.isEmpty()) |
356 return SkBitmap(); | 357 return SkBitmap(); |
357 | 358 |
358 WebGraphicsContext3D* filterContext = getFilterContext(); | 359 WebGraphicsContext3D* filterContext = getFilterContext(hasImplThread); |
359 GrContext* filterGrContext = getFilterGrContext(); | 360 GrContext* filterGrContext = getFilterGrContext(hasImplThread); |
360 | 361 |
361 if (!filterContext || !filterGrContext) | 362 if (!filterContext || !filterGrContext) |
362 return SkBitmap(); | 363 return SkBitmap(); |
363 | 364 |
364 renderer->context()->flush(); | 365 renderer->context()->flush(); |
365 | 366 |
366 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id()); | 367 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id()); |
367 SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), sou rceTexture->size(), filterContext, filterGrContext); | 368 SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), sou rceTexture->size(), filterContext, filterGrContext); |
368 return source; | 369 return source; |
369 } | 370 } |
370 | 371 |
371 static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc opedTexture* sourceTexture) | 372 static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc opedTexture* sourceTexture, bool hasImplThread) |
372 { | 373 { |
373 if (!filter) | 374 if (!filter) |
374 return SkBitmap(); | 375 return SkBitmap(); |
375 | 376 |
376 WebGraphicsContext3D* context3d = getFilterContext(); | 377 WebGraphicsContext3D* context3d = getFilterContext(hasImplThread); |
377 GrContext* grContext = getFilterGrContext(); | 378 GrContext* grContext = getFilterGrContext(hasImplThread); |
378 | 379 |
379 if (!context3d || !grContext) | 380 if (!context3d || !grContext) |
380 return SkBitmap(); | 381 return SkBitmap(); |
381 | 382 |
382 renderer->context()->flush(); | 383 renderer->context()->flush(); |
383 | 384 |
384 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id()); | 385 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id()); |
385 | 386 |
386 // Wrap the source texture in a Ganesh platform texture. | 387 // Wrap the source texture in a Ganesh platform texture. |
387 GrPlatformTextureDesc platformTextureDescription; | 388 GrPlatformTextureDesc platformTextureDescription; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 int top, right, bottom, left; | 453 int top, right, bottom, left; |
453 filters.getOutsets(top, right, bottom, left); | 454 filters.getOutsets(top, right, bottom, left); |
454 deviceRect.Inset(-left, -top, -right, -bottom); | 455 deviceRect.Inset(-left, -top, -right, -bottom); |
455 | 456 |
456 deviceRect.Intersect(frame.currentRenderPass->outputRect()); | 457 deviceRect.Intersect(frame.currentRenderPass->outputRect()); |
457 | 458 |
458 scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_ resourceProvider); | 459 scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_ resourceProvider); |
459 if (!getFramebufferTexture(deviceBackgroundTexture.get(), cc::IntRect(device Rect))) | 460 if (!getFramebufferTexture(deviceBackgroundTexture.get(), cc::IntRect(device Rect))) |
460 return scoped_ptr<ScopedTexture>(); | 461 return scoped_ptr<ScopedTexture>(); |
461 | 462 |
462 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr oundTexture.get()); | 463 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr oundTexture.get(), m_hasImplThread); |
463 if (!filteredDeviceBackground.getTexture()) | 464 if (!filteredDeviceBackground.getTexture()) |
464 return scoped_ptr<ScopedTexture>(); | 465 return scoped_ptr<ScopedTexture>(); |
465 | 466 |
466 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g etTexture()); | 467 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g etTexture()); |
467 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); | 468 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); |
468 | 469 |
469 scoped_ptr<ScopedTexture> backgroundTexture = ScopedTexture::create(m_resour ceProvider); | 470 scoped_ptr<ScopedTexture> backgroundTexture = ScopedTexture::create(m_resour ceProvider); |
470 if (!backgroundTexture->allocate(Renderer::ImplPool, cc::IntSize(quad->quadR ect().size()), GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) | 471 if (!backgroundTexture->allocate(Renderer::ImplPool, cc::IntSize(quad->quadR ect().size()), GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) |
471 return scoped_ptr<ScopedTexture>(); | 472 return scoped_ptr<ScopedTexture>(); |
472 | 473 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 // Can only draw surface if device matrix is invertible. | 508 // Can only draw surface if device matrix is invertible. |
508 if (!contentsDeviceTransform.isInvertible()) | 509 if (!contentsDeviceTransform.isInvertible()) |
509 return; | 510 return; |
510 | 511 |
511 scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters(frame, q uad, renderPass->backgroundFilters(), contentsDeviceTransform); | 512 scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters(frame, q uad, renderPass->backgroundFilters(), contentsDeviceTransform); |
512 | 513 |
513 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica. | 514 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica. |
514 // Apply filters to the contents texture. | 515 // Apply filters to the contents texture. |
515 SkBitmap filterBitmap; | 516 SkBitmap filterBitmap; |
516 if (renderPass->filter()) { | 517 if (renderPass->filter()) { |
517 filterBitmap = applyImageFilter(this, renderPass->filter(), contentsText ure); | 518 filterBitmap = applyImageFilter(this, renderPass->filter(), contentsText ure, m_hasImplThread); |
518 } else { | 519 } else { |
519 filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture ); | 520 filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture , m_hasImplThread); |
520 } | 521 } |
521 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; | 522 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; |
522 unsigned contentsTextureId = 0; | 523 unsigned contentsTextureId = 0; |
523 if (filterBitmap.getTexture()) { | 524 if (filterBitmap.getTexture()) { |
524 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e()); | 525 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e()); |
525 contentsTextureId = texture->getTextureHandle(); | 526 contentsTextureId = texture->getTextureHandle(); |
526 } else { | 527 } else { |
527 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id())); | 528 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id())); |
528 contentsTextureId = contentsResourceLock->textureId(); | 529 contentsTextureId = contentsResourceLock->textureId(); |
529 } | 530 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 template<class Program> void set(Program* program) | 940 template<class Program> void set(Program* program) |
940 { | 941 { |
941 TextureProgramBinding::set(program); | 942 TextureProgramBinding::set(program); |
942 texTransformLocation = program->vertexShader().texTransformLocation(); | 943 texTransformLocation = program->vertexShader().texTransformLocation(); |
943 } | 944 } |
944 int texTransformLocation; | 945 int texTransformLocation; |
945 }; | 946 }; |
946 | 947 |
947 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad) | 948 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad) |
948 { | 949 { |
949 DCHECK(Proxy::isImplThread()); | |
950 | |
951 TexTransformTextureProgramBinding binding; | 950 TexTransformTextureProgramBinding binding; |
952 if (quad->flipped()) | 951 if (quad->flipped()) |
953 binding.set(textureProgramFlip()); | 952 binding.set(textureProgramFlip()); |
954 else | 953 else |
955 binding.set(textureProgram()); | 954 binding.set(textureProgram()); |
956 GLC(context(), context()->useProgram(binding.programId)); | 955 GLC(context(), context()->useProgram(binding.programId)); |
957 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); | 956 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); |
958 const gfx::RectF& uvRect = quad->uvRect(); | 957 const gfx::RectF& uvRect = quad->uvRect(); |
959 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); | 958 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); |
960 | 959 |
(...skipping 22 matching lines...) Expand all Loading... | |
983 | 982 |
984 setShaderOpacity(quad->opacity(), binding.alphaLocation); | 983 setShaderOpacity(quad->opacity(), binding.alphaLocation); |
985 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation); | 984 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation); |
986 | 985 |
987 if (!quad->premultipliedAlpha()) | 986 if (!quad->premultipliedAlpha()) |
988 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 987 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
989 } | 988 } |
990 | 989 |
991 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad) | 990 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad) |
992 { | 991 { |
993 DCHECK(Proxy::isImplThread()); | |
994 TexTransformTextureProgramBinding binding; | 992 TexTransformTextureProgramBinding binding; |
995 binding.set(textureIOSurfaceProgram()); | 993 binding.set(textureIOSurfaceProgram()); |
996 | 994 |
997 GLC(context(), context()->useProgram(binding.programId)); | 995 GLC(context(), context()->useProgram(binding.programId)); |
998 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); | 996 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); |
999 if (quad->orientation() == IOSurfaceDrawQuad::Flipped) | 997 if (quad->orientation() == IOSurfaceDrawQuad::Flipped) |
1000 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0)); | 998 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0)); |
1001 else | 999 else |
1002 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height())); | 1000 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height())); |
1003 | 1001 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1125 return true; | 1123 return true; |
1126 } | 1124 } |
1127 | 1125 |
1128 void GLRenderer::onSwapBuffersComplete() | 1126 void GLRenderer::onSwapBuffersComplete() |
1129 { | 1127 { |
1130 m_client->onSwapBuffersComplete(); | 1128 m_client->onSwapBuffersComplete(); |
1131 } | 1129 } |
1132 | 1130 |
1133 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n) | 1131 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio n) |
1134 { | 1132 { |
1135 // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread. | 1133 onMemoryAllocationChangedOnImplThread(allocation); |
danakj
2012/10/25 05:06:06
Is there a reason to keep the OnImplThread functio
| |
1136 if (!Proxy::hasImplThread()) { | |
1137 DCHECK(Proxy::isMainThread()); | |
1138 DebugScopedSetImplThread impl; | |
1139 onMemoryAllocationChangedOnImplThread(allocation); | |
1140 } else { | |
1141 DCHECK(Proxy::isImplThread()); | |
1142 onMemoryAllocationChangedOnImplThread(allocation); | |
1143 } | |
1144 } | 1134 } |
1145 | 1135 |
1146 void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemory Allocation allocation) | 1136 void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemory Allocation allocation) |
1147 { | 1137 { |
1148 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer; | 1138 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer; |
1149 // 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 |
1150 // 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 |
1151 // is not visible (which the renderer knows better). | 1141 // is not visible (which the renderer knows better). |
1152 if (allocation.gpuResourceSizeInBytes) | 1142 if (allocation.gpuResourceSizeInBytes) |
1153 m_client->setManagedMemoryPolicy(ManagedMemoryPolicy(allocation.gpuResou rceSizeInBytes)); | 1143 m_client->setManagedMemoryPolicy(ManagedMemoryPolicy(allocation.gpuResou rceSizeInBytes)); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1588 | 1578 |
1589 releaseRenderPassTextures(); | 1579 releaseRenderPassTextures(); |
1590 } | 1580 } |
1591 | 1581 |
1592 bool GLRenderer::isContextLost() | 1582 bool GLRenderer::isContextLost() |
1593 { | 1583 { |
1594 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1584 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1595 } | 1585 } |
1596 | 1586 |
1597 } // namespace cc | 1587 } // namespace cc |
OLD | NEW |