| 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 "cc/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 return scoped_ptr<ScopedResource>(); | 471 return scoped_ptr<ScopedResource>(); |
| 472 | 472 |
| 473 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr
oundTexture.get(), m_client->hasImplThread()); | 473 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr
oundTexture.get(), m_client->hasImplThread()); |
| 474 if (!filteredDeviceBackground.getTexture()) | 474 if (!filteredDeviceBackground.getTexture()) |
| 475 return scoped_ptr<ScopedResource>(); | 475 return scoped_ptr<ScopedResource>(); |
| 476 | 476 |
| 477 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g
etTexture()); | 477 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g
etTexture()); |
| 478 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); | 478 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); |
| 479 | 479 |
| 480 scoped_ptr<ScopedResource> backgroundTexture = ScopedResource::create(m_reso
urceProvider); | 480 scoped_ptr<ScopedResource> backgroundTexture = ScopedResource::create(m_reso
urceProvider); |
| 481 if (!backgroundTexture->allocate(Renderer::ImplPool, quad->quadRect().size()
, GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) | 481 if (!backgroundTexture->Allocate(Renderer::ImplPool, quad->quadRect().size()
, GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) |
| 482 return scoped_ptr<ScopedResource>(); | 482 return scoped_ptr<ScopedResource>(); |
| 483 | 483 |
| 484 const RenderPass* targetRenderPass = frame.currentRenderPass; | 484 const RenderPass* targetRenderPass = frame.currentRenderPass; |
| 485 bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(
), quad->quadRect()); | 485 bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(
), quad->quadRect()); |
| 486 | 486 |
| 487 if (usingBackgroundTexture) { | 487 if (usingBackgroundTexture) { |
| 488 // Copy the readback pixels from device to the background texture for th
e surface. | 488 // Copy the readback pixels from device to the background texture for th
e surface. |
| 489 WebTransformationMatrix deviceToFramebufferTransform; | 489 WebTransformationMatrix deviceToFramebufferTransform; |
| 490 deviceToFramebufferTransform.translate(quad->quadRect().width() / 2.0, q
uad->quadRect().height() / 2.0); | 490 deviceToFramebufferTransform.translate(quad->quadRect().width() / 2.0, q
uad->quadRect().height() / 2.0); |
| 491 deviceToFramebufferTransform.scale3d(quad->quadRect().width(), quad->qua
dRect().height(), 1); | 491 deviceToFramebufferTransform.scale3d(quad->quadRect().width(), quad->qua
dRect().height(), 1); |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 GLC(m_context, m_context->deleteTexture(temporaryTexture)); | 1270 GLC(m_context, m_context->deleteTexture(temporaryTexture)); |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 enforceMemoryPolicy(); | 1273 enforceMemoryPolicy(); |
| 1274 } | 1274 } |
| 1275 | 1275 |
| 1276 bool GLRenderer::getFramebufferTexture(ScopedResource* texture, const gfx::Rect&
deviceRect) | 1276 bool GLRenderer::getFramebufferTexture(ScopedResource* texture, const gfx::Rect&
deviceRect) |
| 1277 { | 1277 { |
| 1278 DCHECK(!texture->id() || (texture->size() == deviceRect.size() && texture->f
ormat() == GL_RGB)); | 1278 DCHECK(!texture->id() || (texture->size() == deviceRect.size() && texture->f
ormat() == GL_RGB)); |
| 1279 | 1279 |
| 1280 if (!texture->id() && !texture->allocate(Renderer::ImplPool, deviceRect.size
(), GL_RGB, ResourceProvider::TextureUsageAny)) | 1280 if (!texture->id() && !texture->Allocate(Renderer::ImplPool, deviceRect.size
(), GL_RGB, ResourceProvider::TextureUsageAny)) |
| 1281 return false; | 1281 return false; |
| 1282 | 1282 |
| 1283 ResourceProvider::ScopedWriteLockGL lock(m_resourceProvider, texture->id()); | 1283 ResourceProvider::ScopedWriteLockGL lock(m_resourceProvider, texture->id()); |
| 1284 GLC(m_context, m_context->bindTexture(GL_TEXTURE_2D, lock.textureId())); | 1284 GLC(m_context, m_context->bindTexture(GL_TEXTURE_2D, lock.textureId())); |
| 1285 GLC(m_context, m_context->copyTexImage2D(GL_TEXTURE_2D, 0, texture->format()
, | 1285 GLC(m_context, m_context->copyTexImage2D(GL_TEXTURE_2D, 0, texture->format()
, |
| 1286 deviceRect.x(), deviceRect.y(), dev
iceRect.width(), deviceRect.height(), 0)); | 1286 deviceRect.x(), deviceRect.y(), dev
iceRect.width(), deviceRect.height(), 0)); |
| 1287 return true; | 1287 return true; |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 bool GLRenderer::useScopedTexture(DrawingFrame& frame, const ScopedResource* tex
ture, const gfx::Rect& viewportRect) | 1290 bool GLRenderer::useScopedTexture(DrawingFrame& frame, const ScopedResource* tex
ture, const gfx::Rect& viewportRect) |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 | 1588 |
| 1589 releaseRenderPassTextures(); | 1589 releaseRenderPassTextures(); |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 bool GLRenderer::isContextLost() | 1592 bool GLRenderer::isContextLost() |
| 1593 { | 1593 { |
| 1594 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1594 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 1595 } | 1595 } |
| 1596 | 1596 |
| 1597 } // namespace cc | 1597 } // namespace cc |
| OLD | NEW |