OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "platform/graphics/MailboxTextureHolder.h" | |
6 | |
7 #include "gpu/command_buffer/client/gles2_interface.h" | |
8 #include "platform/graphics/gpu/SharedGpuContext.h" | |
9 #include "public/platform/Platform.h" | |
10 #include "skia/ext/texture_handle.h" | |
11 #include "third_party/skia/include/gpu/GrContext.h" | |
12 | |
13 namespace blink { | |
14 | |
15 MailboxTextureHolder::MailboxTextureHolder(const gpu::Mailbox& mailbox, | |
16 const gpu::SyncToken& syncToken, | |
17 unsigned textureId, | |
18 gpu::gles2::GLES2Interface* gl, | |
19 IntSize mailboxSize) | |
20 : m_mailbox(mailbox), | |
21 m_syncToken(syncToken), | |
22 m_textureId(textureId), | |
23 m_gl(gl), | |
24 m_size(mailboxSize) {} | |
25 | |
26 MailboxTextureHolder::MailboxTextureHolder(sk_sp<SkImage> image) { | |
27 gpu::gles2::GLES2Interface* sharedGL = SharedGpuContext::gl(); | |
28 GrContext* sharedGrContext = SharedGpuContext::gr(); | |
29 if (!sharedGrContext) { | |
30 // Can happen if the context is lost. The SkImage won't be any good now | |
31 // anyway. | |
32 return; | |
33 } | |
34 GLuint imageTextureId = | |
35 skia::GrBackendObjectToGrGLTextureInfo(image->getTextureHandle(true)) | |
36 ->fID; | |
37 sharedGL->BindTexture(GL_TEXTURE_2D, imageTextureId); | |
38 | |
39 sharedGL->GenMailboxCHROMIUM(m_mailbox.name); | |
40 sharedGL->ProduceTextureCHROMIUM(GL_TEXTURE_2D, m_mailbox.name); | |
41 const GLuint64 fenceSync = sharedGL->InsertFenceSyncCHROMIUM(); | |
42 sharedGL->Flush(); | |
43 sharedGL->GenSyncTokenCHROMIUM(fenceSync, m_syncToken.GetData()); | |
44 | |
45 sharedGL->BindTexture(GL_TEXTURE_2D, 0); | |
46 // We changed bound textures in this function, so reset the GrContext. | |
47 sharedGrContext->resetContext(kTextureBinding_GrGLBackendState); | |
48 m_size = IntSize(image->width(), image->height()); | |
49 } | |
50 | |
51 WebThread* MailboxTextureHolder::getImageThread() { | |
52 return Platform::current()->currentThread(); | |
53 } | |
54 | |
55 void MailboxTextureHolder::deleteTexture(const int8_t* syncTokenData) { | |
56 if (m_gl && m_textureId) { | |
57 m_gl->WaitSyncTokenCHROMIUM(syncTokenData); | |
58 m_gl->DeleteTextures(1, &m_textureId); | |
Fady Samuel
2016/10/28 17:33:45
Something is failing in here. It sounds like the b
| |
59 } | |
60 } | |
61 | |
62 unsigned MailboxTextureHolder::sharedContextId() { | |
63 return SharedGpuContext::kNoSharedContext; | |
64 } | |
65 | |
66 } // namespace blink | |
OLD | NEW |