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

Unified Diff: blimp/client/core/compositor/delegated_output_surface.h

Issue 2266863003: blimp: Move BlimpCompositor to use delegated rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments + tests. Created 4 years, 4 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: blimp/client/core/compositor/delegated_output_surface.h
diff --git a/blimp/client/core/compositor/delegated_output_surface.h b/blimp/client/core/compositor/delegated_output_surface.h
new file mode 100644
index 0000000000000000000000000000000000000000..5de9f704738179a0ad32ea1c1f4403544f92d742
--- /dev/null
+++ b/blimp/client/core/compositor/delegated_output_surface.h
@@ -0,0 +1,102 @@
+// 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.
+
+#ifndef BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_
+#define BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "blimp/client/core/compositor/blimp_output_surface.h"
+#include "cc/output/output_surface.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
+namespace cc {
+class ContextProvider;
+} // namespace cc
+
+namespace blimp {
+namespace client {
+
+class DelegatedOutputSurface : public cc::OutputSurface,
+ public BlimpOutputSurface {
+ public:
+ DelegatedOutputSurface(
+ scoped_refptr<cc::ContextProvider> compositor_context_provider,
+ scoped_refptr<cc::ContextProvider> worker_context_provider,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
+ BlimpOutputSurfaceClient* client);
+
+ ~DelegatedOutputSurface() override;
+
+ // cc::OutputSurface implementation.
+ uint32_t GetFramebufferCopyTextureFormat() override;
+ bool BindToClient(cc::OutputSurfaceClient* client) override;
+ void SwapBuffers(cc::CompositorFrame frame) override;
+ void DetachFromClient() override;
+
+ // BlimpOutputSurface implementation.
+ void ReclaimCompositorResources(
+ const cc::ReturnedResourceArray& resources) override;
+
+ protected:
+ // called on compositor thread.
David Trainor- moved to gerrit 2016/08/24 23:09:33 called -> Called
Khushal 2016/08/25 02:35:39 Removed.
+ virtual void ReclaimResourcesOnCompositorThread(
+ const cc::ReturnedResourceArray& resources);
+
+ private:
+ // Called on main thread.
+ void BindOnMainThread(
+ base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr);
+ void SwapBuffersOnMainThread(cc::CompositorFrame frame);
+ void DetachOnMainThread();
+
+ bool IsMainThread() const;
+ bool IsCompositorThread() const;
+
+ struct MainThreadOnly {
+ MainThreadOnly(DelegatedOutputSurface* output_surface,
+ BlimpOutputSurfaceClient* client);
+ ~MainThreadOnly();
+
+ BlimpOutputSurfaceClient* client;
+ // Used to post tasks to the OutputSurface on the compositor thread.
+ base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr;
+
+ base::WeakPtrFactory<DelegatedOutputSurface> weak_ptr_factory;
+ };
+
+ struct CompositorThreadOnly {
+ CompositorThreadOnly(
+ DelegatedOutputSurface* output_surface,
+ base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr);
+ ~CompositorThreadOnly();
+
+ bool bound_to_client;
+
+ // Used to post tasks to the OutputSurface on the main thread.
+ base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr;
+
+ base::WeakPtrFactory<DelegatedOutputSurface> weak_ptr_factory;
+ };
+
+ MainThreadOnly& main();
+ CompositorThreadOnly& compositor();
+
+ MainThreadOnly main_thread_only_;
+ CompositorThreadOnly compositor_thread_only_;
+
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(DelegatedOutputSurface);
+};
+
+} // namespace client
+} // namespace blimp
+
+#endif // BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_

Powered by Google App Engine
This is Rietveld 408576698