| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/AcceleratedStaticBitmapImage.h" | 5 #include "platform/graphics/AcceleratedStaticBitmapImage.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "gpu/command_buffer/common/sync_token.h" | 8 #include "gpu/command_buffer/common/sync_token.h" |
| 9 #include "platform/graphics/MailboxTextureHolder.h" | 9 #include "platform/graphics/MailboxTextureHolder.h" |
| 10 #include "platform/graphics/SkiaTextureHolder.h" | 10 #include "platform/graphics/SkiaTextureHolder.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const gpu::SyncToken& syncToken, | 32 const gpu::SyncToken& syncToken, |
| 33 unsigned textureId, | 33 unsigned textureId, |
| 34 WeakPtr<WebGraphicsContext3DProviderWrapper> contextProvider, | 34 WeakPtr<WebGraphicsContext3DProviderWrapper> contextProvider, |
| 35 IntSize mailboxSize) { | 35 IntSize mailboxSize) { |
| 36 return adoptRef(new AcceleratedStaticBitmapImage( | 36 return adoptRef(new AcceleratedStaticBitmapImage( |
| 37 mailbox, syncToken, textureId, contextProvider, mailboxSize)); | 37 mailbox, syncToken, textureId, contextProvider, mailboxSize)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 AcceleratedStaticBitmapImage::AcceleratedStaticBitmapImage( | 40 AcceleratedStaticBitmapImage::AcceleratedStaticBitmapImage( |
| 41 sk_sp<SkImage> image) { | 41 sk_sp<SkImage> image) { |
| 42 m_textureHolder = wrapUnique(new SkiaTextureHolder(std::move(image))); | 42 m_textureHolder = WTF::wrapUnique(new SkiaTextureHolder(std::move(image))); |
| 43 m_threadChecker.DetachFromThread(); | 43 m_threadChecker.DetachFromThread(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 AcceleratedStaticBitmapImage::AcceleratedStaticBitmapImage( | 46 AcceleratedStaticBitmapImage::AcceleratedStaticBitmapImage( |
| 47 const gpu::Mailbox& mailbox, | 47 const gpu::Mailbox& mailbox, |
| 48 const gpu::SyncToken& syncToken, | 48 const gpu::SyncToken& syncToken, |
| 49 unsigned textureId, | 49 unsigned textureId, |
| 50 WeakPtr<WebGraphicsContext3DProviderWrapper> contextProvider, | 50 WeakPtr<WebGraphicsContext3DProviderWrapper> contextProvider, |
| 51 IntSize mailboxSize) { | 51 IntSize mailboxSize) { |
| 52 m_textureHolder = wrapUnique(new MailboxTextureHolder( | 52 m_textureHolder = WTF::wrapUnique(new MailboxTextureHolder( |
| 53 mailbox, syncToken, textureId, contextProvider, mailboxSize)); | 53 mailbox, syncToken, textureId, contextProvider, mailboxSize)); |
| 54 m_threadChecker.DetachFromThread(); | 54 m_threadChecker.DetachFromThread(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 AcceleratedStaticBitmapImage::~AcceleratedStaticBitmapImage() {} | 57 AcceleratedStaticBitmapImage::~AcceleratedStaticBitmapImage() {} |
| 58 | 58 |
| 59 IntSize AcceleratedStaticBitmapImage::size() const { | 59 IntSize AcceleratedStaticBitmapImage::size() const { |
| 60 return m_textureHolder->size(); | 60 return m_textureHolder->size(); |
| 61 } | 61 } |
| 62 | 62 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void AcceleratedStaticBitmapImage::createImageFromMailboxIfNeeded() { | 129 void AcceleratedStaticBitmapImage::createImageFromMailboxIfNeeded() { |
| 130 if (m_textureHolder->sharedContextId() != SharedGpuContext::kNoSharedContext) | 130 if (m_textureHolder->sharedContextId() != SharedGpuContext::kNoSharedContext) |
| 131 return; | 131 return; |
| 132 if (m_textureHolder->isSkiaTextureHolder()) | 132 if (m_textureHolder->isSkiaTextureHolder()) |
| 133 return; | 133 return; |
| 134 m_textureHolder = | 134 m_textureHolder = |
| 135 wrapUnique(new SkiaTextureHolder(std::move(m_textureHolder))); | 135 WTF::wrapUnique(new SkiaTextureHolder(std::move(m_textureHolder))); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void AcceleratedStaticBitmapImage::ensureMailbox() { | 138 void AcceleratedStaticBitmapImage::ensureMailbox() { |
| 139 if (m_textureHolder->isMailboxTextureHolder()) | 139 if (m_textureHolder->isMailboxTextureHolder()) |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 m_textureHolder = | 142 m_textureHolder = |
| 143 wrapUnique(new MailboxTextureHolder(std::move(m_textureHolder))); | 143 WTF::wrapUnique(new MailboxTextureHolder(std::move(m_textureHolder))); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void AcceleratedStaticBitmapImage::transfer() { | 146 void AcceleratedStaticBitmapImage::transfer() { |
| 147 checkThread(); | 147 checkThread(); |
| 148 ensureMailbox(); | 148 ensureMailbox(); |
| 149 // If |m_textureThreadTaskRunner| in TextureHolder is set, it means that | 149 // If |m_textureThreadTaskRunner| in TextureHolder is set, it means that |
| 150 // the |m_texture| in this class has been consumed on the current thread, | 150 // the |m_texture| in this class has been consumed on the current thread, |
| 151 // which may happen when we have chained transfers. When that is the case, | 151 // which may happen when we have chained transfers. When that is the case, |
| 152 // we must not reset |m_imageThreadTaskRunner|, so we ensure that | 152 // we must not reset |m_imageThreadTaskRunner|, so we ensure that |
| 153 // releaseImage() or releaseTexture() is called on the right thread. | 153 // releaseImage() or releaseTexture() is called on the right thread. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 167 | 167 |
| 168 void AcceleratedStaticBitmapImage::checkThread() { | 168 void AcceleratedStaticBitmapImage::checkThread() { |
| 169 if (m_detachThreadAtNextCheck) { | 169 if (m_detachThreadAtNextCheck) { |
| 170 m_threadChecker.DetachFromThread(); | 170 m_threadChecker.DetachFromThread(); |
| 171 m_detachThreadAtNextCheck = false; | 171 m_detachThreadAtNextCheck = false; |
| 172 } | 172 } |
| 173 CHECK(m_threadChecker.CalledOnValidThread()); | 173 CHECK(m_threadChecker.CalledOnValidThread()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace blink | 176 } // namespace blink |
| OLD | NEW |