| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 m_surface = createSkSurface(wantAccelerated ? m_contextProvider->grConte
xt() : nullptr, m_size, m_msaaSampleCount, m_opacityMode, &surfaceIsAccelerated)
; | 189 m_surface = createSkSurface(wantAccelerated ? m_contextProvider->grConte
xt() : nullptr, m_size, m_msaaSampleCount, m_opacityMode, &surfaceIsAccelerated)
; |
| 190 | 190 |
| 191 if (m_surface && surfaceIsAccelerated && !m_layer) { | 191 if (m_surface && surfaceIsAccelerated && !m_layer) { |
| 192 m_layer = adoptPtr(Platform::current()->compositorSupport()->createE
xternalTextureLayer(this)); | 192 m_layer = adoptPtr(Platform::current()->compositorSupport()->createE
xternalTextureLayer(this)); |
| 193 m_layer->setOpaque(m_opacityMode == Opaque); | 193 m_layer->setOpaque(m_opacityMode == Opaque); |
| 194 m_layer->setBlendBackgroundColor(m_opacityMode != Opaque); | 194 m_layer->setBlendBackgroundColor(m_opacityMode != Opaque); |
| 195 GraphicsLayer::registerContentsLayer(m_layer->layer()); | 195 GraphicsLayer::registerContentsLayer(m_layer->layer()); |
| 196 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality
); | 196 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality
); |
| 197 } | 197 } |
| 198 |
| 199 if (m_imageBuffer) |
| 200 m_imageBuffer->updateGPUMemoryUsage(); |
| 198 } | 201 } |
| 199 return m_surface.get(); | 202 return m_surface.get(); |
| 200 } | 203 } |
| 201 | 204 |
| 202 SkCanvas* Canvas2DLayerBridge::canvas() | 205 SkCanvas* Canvas2DLayerBridge::canvas() |
| 203 { | 206 { |
| 204 if (!m_isDeferralEnabled) { | 207 if (!m_isDeferralEnabled) { |
| 205 SkSurface* s = getOrCreateSurface(); | 208 SkSurface* s = getOrCreateSurface(); |
| 206 return s ? s->getCanvas() : nullptr; | 209 return s ? s->getCanvas() : nullptr; |
| 207 } | 210 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 bool surfaceIsAccelerated; | 402 bool surfaceIsAccelerated; |
| 400 RefPtr<SkSurface> surface(createSkSurface(grCtx, m_size, m_msaaSampleCou
nt, m_opacityMode, &surfaceIsAccelerated)); | 403 RefPtr<SkSurface> surface(createSkSurface(grCtx, m_size, m_msaaSampleCou
nt, m_opacityMode, &surfaceIsAccelerated)); |
| 401 // Current paradigm does support switching from accelerated to non-accel
erated, which would be tricky | 404 // Current paradigm does support switching from accelerated to non-accel
erated, which would be tricky |
| 402 // due to changes to the layer tree, which can only happen at specific t
imes during the document lifecycle. | 405 // due to changes to the layer tree, which can only happen at specific t
imes during the document lifecycle. |
| 403 // Therefore, we can only accept the restored surface if it is accelerat
ed. | 406 // Therefore, we can only accept the restored surface if it is accelerat
ed. |
| 404 if (surface.get() && surfaceIsAccelerated) { | 407 if (surface.get() && surfaceIsAccelerated) { |
| 405 m_surface = surface.release(); | 408 m_surface = surface.release(); |
| 406 // FIXME: draw sad canvas picture into new buffer crbug.com/243842 | 409 // FIXME: draw sad canvas picture into new buffer crbug.com/243842 |
| 407 } | 410 } |
| 408 } | 411 } |
| 412 if (m_imageBuffer) |
| 413 m_imageBuffer->updateGPUMemoryUsage(); |
| 409 | 414 |
| 410 return m_surface; | 415 return m_surface; |
| 411 } | 416 } |
| 412 | 417 |
| 413 bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
WebExternalBitmap* bitmap) | 418 bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
WebExternalBitmap* bitmap) |
| 414 { | 419 { |
| 415 ASSERT(isAccelerated()); | 420 ASSERT(isAccelerated()); |
| 416 if (m_destructionInProgress) { | 421 if (m_destructionInProgress) { |
| 417 // It can be hit in the following sequence. | 422 // It can be hit in the following sequence. |
| 418 // 1. Canvas draws something. | 423 // 1. Canvas draws something. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 } | 650 } |
| 646 | 651 |
| 647 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) | 652 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) |
| 648 { | 653 { |
| 649 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 654 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
| 650 m_image = other.m_image; | 655 m_image = other.m_image; |
| 651 m_parentLayerBridge = other.m_parentLayerBridge; | 656 m_parentLayerBridge = other.m_parentLayerBridge; |
| 652 } | 657 } |
| 653 | 658 |
| 654 } // namespace blink | 659 } // namespace blink |
| OLD | NEW |