Chromium Code Reviews| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) | 180 SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) |
| 181 { | 181 { |
| 182 if (!m_surface) { | 182 if (!m_surface) { |
| 183 if (m_layer) | 183 if (m_layer) |
| 184 return nullptr; // recreation will happen through restore() | 184 return nullptr; // recreation will happen through restore() |
| 185 | 185 |
| 186 bool wantAccelerated = shouldAccelerate(hint); | 186 bool wantAccelerated = shouldAccelerate(hint); |
| 187 bool surfaceIsAccelerated; | 187 bool surfaceIsAccelerated; |
| 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 m_imageBuffer->updateGPUMemoryUsage(); | |
|
Justin Novosad
2015/12/08 22:15:27
Should call this after creating m_layer, otherwise
| |
| 190 | 191 |
| 191 if (m_surface && surfaceIsAccelerated && !m_layer) { | 192 if (m_surface && surfaceIsAccelerated && !m_layer) { |
| 192 m_layer = adoptPtr(Platform::current()->compositorSupport()->createE xternalTextureLayer(this)); | 193 m_layer = adoptPtr(Platform::current()->compositorSupport()->createE xternalTextureLayer(this)); |
| 193 m_layer->setOpaque(m_opacityMode == Opaque); | 194 m_layer->setOpaque(m_opacityMode == Opaque); |
| 194 m_layer->setBlendBackgroundColor(m_opacityMode != Opaque); | 195 m_layer->setBlendBackgroundColor(m_opacityMode != Opaque); |
| 195 GraphicsLayer::registerContentsLayer(m_layer->layer()); | 196 GraphicsLayer::registerContentsLayer(m_layer->layer()); |
| 196 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality ); | 197 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality ); |
| 197 } | 198 } |
| 198 } | 199 } |
| 199 return m_surface.get(); | 200 return m_surface.get(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 | 397 |
| 397 if (sharedContext && !sharedContext->isContextLost()) { | 398 if (sharedContext && !sharedContext->isContextLost()) { |
| 398 GrContext* grCtx = m_contextProvider->grContext(); | 399 GrContext* grCtx = m_contextProvider->grContext(); |
| 399 bool surfaceIsAccelerated; | 400 bool surfaceIsAccelerated; |
| 400 RefPtr<SkSurface> surface(createSkSurface(grCtx, m_size, m_msaaSampleCou nt, m_opacityMode, &surfaceIsAccelerated)); | 401 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 | 402 // 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. | 403 // 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. | 404 // Therefore, we can only accept the restored surface if it is accelerat ed. |
| 404 if (surface.get() && surfaceIsAccelerated) { | 405 if (surface.get() && surfaceIsAccelerated) { |
| 405 m_surface = surface.release(); | 406 m_surface = surface.release(); |
| 407 m_imageBuffer->updateGPUMemoryUsage(); | |
| 406 // FIXME: draw sad canvas picture into new buffer crbug.com/243842 | 408 // FIXME: draw sad canvas picture into new buffer crbug.com/243842 |
| 407 } | 409 } |
| 408 } | 410 } |
| 409 | 411 |
| 410 return m_surface; | 412 return m_surface; |
| 411 } | 413 } |
| 412 | 414 |
| 413 bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExternalBitmap* bitmap) | 415 bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExternalBitmap* bitmap) |
| 414 { | 416 { |
| 415 ASSERT(isAccelerated()); | 417 ASSERT(isAccelerated()); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 } | 647 } |
| 646 | 648 |
| 647 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) | 649 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) |
| 648 { | 650 { |
| 649 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 651 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
| 650 m_image = other.m_image; | 652 m_image = other.m_image; |
| 651 m_parentLayerBridge = other.m_parentLayerBridge; | 653 m_parentLayerBridge = other.m_parentLayerBridge; |
| 652 } | 654 } |
| 653 | 655 |
| 654 } // namespace blink | 656 } // namespace blink |
| OLD | NEW |