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

Unified Diff: components/mus/gles2/gl_surface_adapter.cc

Issue 1854953002: Plumb GpuSwapBuffers completion from Mus GPU thread to WS thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review nits Created 4 years, 9 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: components/mus/gles2/gl_surface_adapter.cc
diff --git a/components/mus/gles2/gl_surface_adapter.cc b/components/mus/gles2/gl_surface_adapter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..827028821b29e329792cdf3c31b5f01827857521
--- /dev/null
+++ b/components/mus/gles2/gl_surface_adapter.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 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 "components/mus/gles2/gl_surface_adapter.h"
+
+#include "base/bind.h"
+
+namespace mus {
+
+GLSurfaceAdapterMus::GLSurfaceAdapterMus(scoped_refptr<gfx::GLSurface> surface)
+ : gfx::GLSurfaceAdapter(surface.get()),
+ surface_(surface),
+ weak_ptr_factory_(this) {}
+
+GLSurfaceAdapterMus::~GLSurfaceAdapterMus() {}
+
+void GLSurfaceAdapterMus::SwapBuffersAsync(
+ const GLSurface::SwapCompletionCallback& callback) {
+ gfx::GLSurfaceAdapter::SwapBuffersAsync(
+ base::Bind(&GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+}
+
+void GLSurfaceAdapterMus::PostSubBufferAsync(
+ int x,
+ int y,
+ int width,
+ int height,
+ const GLSurface::SwapCompletionCallback& callback) {
+ gfx::GLSurfaceAdapter::PostSubBufferAsync(
+ x, y, width, height,
+ base::Bind(&GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+}
+
+void GLSurfaceAdapterMus::CommitOverlayPlanesAsync(
+ const GLSurface::SwapCompletionCallback& callback) {
+ gfx::GLSurfaceAdapter::CommitOverlayPlanesAsync(
+ base::Bind(&GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+}
+
+void GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync(
+ const gfx::GLSurface::SwapCompletionCallback& original_callback,
+ gfx::SwapResult result) {
+ if (!adapter_callback_.is_null())
+ adapter_callback_.Run(result);
+ original_callback.Run(result);
+}
+
+void GLSurfaceAdapterMus::SetGpuCompletedSwapBuffersCallback(
+ gfx::GLSurface::SwapCompletionCallback callback) {
+ adapter_callback_ = std::move(callback);
+}
+
+} // namespace mus

Powered by Google App Engine
This is Rietveld 408576698