Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1339)

Unified Diff: third_party/WebKit/Source/platform/graphics/MailboxTextureHolder.cpp

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/MailboxTextureHolder.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/MailboxTextureHolder.cpp b/third_party/WebKit/Source/platform/graphics/MailboxTextureHolder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dbd71edf9d294ed68f8161eee468d76d034a774d
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/MailboxTextureHolder.cpp
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/graphics/MailboxTextureHolder.h"
+
+#include "gpu/command_buffer/client/gles2_interface.h"
+#include "platform/graphics/gpu/SharedGpuContext.h"
+#include "public/platform/Platform.h"
+#include "skia/ext/texture_handle.h"
+#include "third_party/skia/include/gpu/GrContext.h"
+
+namespace blink {
+
+MailboxTextureHolder::MailboxTextureHolder(const gpu::Mailbox& mailbox,
+ const gpu::SyncToken& syncToken,
+ unsigned textureId,
+ gpu::gles2::GLES2Interface* gl,
+ IntSize mailboxSize)
+ : m_mailbox(mailbox),
+ m_syncToken(syncToken),
+ m_textureId(textureId),
+ m_gl(gl),
+ m_size(mailboxSize) {}
+
+MailboxTextureHolder::MailboxTextureHolder(sk_sp<SkImage> image) {
+ gpu::gles2::GLES2Interface* sharedGL = SharedGpuContext::gl();
+ GrContext* sharedGrContext = SharedGpuContext::gr();
+ if (!sharedGrContext) {
+ // Can happen if the context is lost. The SkImage won't be any good now
+ // anyway.
+ return;
+ }
+ GLuint imageTextureId =
+ skia::GrBackendObjectToGrGLTextureInfo(image->getTextureHandle(true))
+ ->fID;
+ sharedGL->BindTexture(GL_TEXTURE_2D, imageTextureId);
+
+ sharedGL->GenMailboxCHROMIUM(m_mailbox.name);
+ sharedGL->ProduceTextureCHROMIUM(GL_TEXTURE_2D, m_mailbox.name);
+ const GLuint64 fenceSync = sharedGL->InsertFenceSyncCHROMIUM();
+ sharedGL->Flush();
+ sharedGL->GenSyncTokenCHROMIUM(fenceSync, m_syncToken.GetData());
+
+ sharedGL->BindTexture(GL_TEXTURE_2D, 0);
+ // We changed bound textures in this function, so reset the GrContext.
+ sharedGrContext->resetContext(kTextureBinding_GrGLBackendState);
+ m_size = IntSize(image->width(), image->height());
+}
+
+WebThread* MailboxTextureHolder::getImageThread() {
+ return Platform::current()->currentThread();
+}
+
+void MailboxTextureHolder::deleteTexture(const int8_t* syncTokenData) {
+ if (m_gl && m_textureId) {
+ m_gl->WaitSyncTokenCHROMIUM(syncTokenData);
+ m_gl->DeleteTextures(1, &m_textureId);
Fady Samuel 2016/10/28 17:33:45 Something is failing in here. It sounds like the b
+ }
+}
+
+unsigned MailboxTextureHolder::sharedContextId() {
+ return SharedGpuContext::kNoSharedContext;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698