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 "FloatQuad.h" | 9 #include "FloatQuad.h" |
10 #include "NotImplemented.h" | 10 #include "NotImplemented.h" |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 WebGraphicsContext3D* filterContext = getFilterContext(); | 367 WebGraphicsContext3D* filterContext = getFilterContext(); |
368 GrContext* filterGrContext = getFilterGrContext(); | 368 GrContext* filterGrContext = getFilterGrContext(); |
369 | 369 |
370 if (!filterContext || !filterGrContext) | 370 if (!filterContext || !filterGrContext) |
371 return SkBitmap(); | 371 return SkBitmap(); |
372 | 372 |
373 renderer->context()->flush(); | 373 renderer->context()->flush(); |
374 | 374 |
375 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc
eTexture->id()); | 375 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc
eTexture->id()); |
376 SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), cc:
:IntSize(sourceTexture->size()), filterContext, filterGrContext); | 376 SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), sou
rceTexture->size(), filterContext, filterGrContext); |
377 return source; | 377 return source; |
378 } | 378 } |
379 | 379 |
380 static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
opedTexture* sourceTexture) | 380 static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
opedTexture* sourceTexture) |
381 { | 381 { |
382 if (!filter) | 382 if (!filter) |
383 return SkBitmap(); | 383 return SkBitmap(); |
384 | 384 |
385 WebGraphicsContext3D* context3d = getFilterContext(); | 385 WebGraphicsContext3D* context3d = getFilterContext(); |
386 GrContext* grContext = getFilterGrContext(); | 386 GrContext* grContext = getFilterGrContext(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 return scoped_ptr<ScopedTexture>(); | 470 return scoped_ptr<ScopedTexture>(); |
471 | 471 |
472 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr
oundTexture.get()); | 472 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr
oundTexture.get()); |
473 if (!filteredDeviceBackground.getTexture()) | 473 if (!filteredDeviceBackground.getTexture()) |
474 return scoped_ptr<ScopedTexture>(); | 474 return scoped_ptr<ScopedTexture>(); |
475 | 475 |
476 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g
etTexture()); | 476 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g
etTexture()); |
477 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); | 477 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); |
478 | 478 |
479 scoped_ptr<ScopedTexture> backgroundTexture = ScopedTexture::create(m_resour
ceProvider); | 479 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)) | 480 if (!backgroundTexture->allocate(Renderer::ImplPool, quad->quadRect().size()
, GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) |
481 return scoped_ptr<ScopedTexture>(); | 481 return scoped_ptr<ScopedTexture>(); |
482 | 482 |
483 const RenderPass* targetRenderPass = frame.currentRenderPass; | 483 const RenderPass* targetRenderPass = frame.currentRenderPass; |
484 bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(
), quad->quadRect()); | 484 bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(
), quad->quadRect()); |
485 | 485 |
486 if (usingBackgroundTexture) { | 486 if (usingBackgroundTexture) { |
487 // Copy the readback pixels from device to the background texture for th
e surface. | 487 // Copy the readback pixels from device to the background texture for th
e surface. |
488 WebTransformationMatrix deviceToFramebufferTransform; | 488 WebTransformationMatrix deviceToFramebufferTransform; |
489 deviceToFramebufferTransform.translate(quad->quadRect().width() / 2.0, q
uad->quadRect().height() / 2.0); | 489 deviceToFramebufferTransform.translate(quad->quadRect().width() / 2.0, q
uad->quadRect().height() / 2.0); |
490 deviceToFramebufferTransform.scale3d(quad->quadRect().width(), quad->qua
dRect().height(), 1); | 490 deviceToFramebufferTransform.scale3d(quad->quadRect().width(), quad->qua
dRect().height(), 1); |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 | 1626 |
1627 releaseRenderPassTextures(); | 1627 releaseRenderPassTextures(); |
1628 } | 1628 } |
1629 | 1629 |
1630 bool GLRenderer::isContextLost() | 1630 bool GLRenderer::isContextLost() |
1631 { | 1631 { |
1632 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1632 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1633 } | 1633 } |
1634 | 1634 |
1635 } // namespace cc | 1635 } // namespace cc |
OLD | NEW |