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

Unified Diff: content/common/gpu/media/avda_surface_tracker.h

Issue 1878103002: Plumb a Browser->GPU surface destruction message for Android VDAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a threadchecker Created 4 years, 8 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
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/gpu/media/avda_surface_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/avda_surface_tracker.h
diff --git a/content/common/gpu/media/avda_surface_tracker.h b/content/common/gpu/media/avda_surface_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..b1d5258d648536c37c2ae63fe9f7979532710cac
--- /dev/null
+++ b/content/common/gpu/media/avda_surface_tracker.h
@@ -0,0 +1,52 @@
+// 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 CONTENT_COMMON_GPU_MEDIA_AVDA_SURFACE_TRACKER_H_
+#define CONTENT_COMMON_GPU_MEDIA_AVDA_SURFACE_TRACKER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/threading/thread_checker.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+using OnDestroyingSurfaceCallback = base::Callback<void(int)>;
+
+// AVDASurfaceTracker provides AndroidVideoDecodeAccelerators a way to register
+// callbacks that will be called when surfaces are destroyed. This is important
+// because Android SurfaceView Surfaces can be destroyed by the framework at any
+// time and we must stop rendering to them before returning from
+// onSurfaceDestroyed().
+// This is not thread safe. All access should be on the gpu main thread.
+// Callbacks will be run on the same thread.
+class AVDASurfaceTracker {
+ public:
+ AVDASurfaceTracker();
+ ~AVDASurfaceTracker();
+
+ static AVDASurfaceTracker* GetInstance();
+
+ void RegisterOnDestroyingSurfaceCallback(
+ const OnDestroyingSurfaceCallback& cb);
+
+ // Unregister a callback that was previously registered.
+ void UnregisterOnDestroyingSurfaceCallback(
+ const OnDestroyingSurfaceCallback& cb);
+
+ // Called in response to a message from the Browser indicating that the given
+ // surface is in the process of being destroyed.
+ void NotifyDestroyingSurface(int surface_id);
+
+ private:
+ std::vector<OnDestroyingSurfaceCallback> callbacks_;
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(AVDASurfaceTracker);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_MEDIA_AVDA_SURFACE_TRACKER_H_
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/gpu/media/avda_surface_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698