| 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 #ifndef CONTENT_COMMON_GPU_MEDIA_AVDA_SURFACE_TRACKER_H_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_AVDA_SURFACE_TRACKER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 using OnDestroyingSurfaceCallback = base::Callback<void(int)>; | |
| 17 | |
| 18 // AVDASurfaceTracker provides AndroidVideoDecodeAccelerators a way to register | |
| 19 // callbacks that will be called when surfaces are destroyed. This is important | |
| 20 // because Android SurfaceView Surfaces can be destroyed by the framework at any | |
| 21 // time and we must stop rendering to them before returning from | |
| 22 // onSurfaceDestroyed(). | |
| 23 // This is not thread safe. All access should be on the gpu main thread. | |
| 24 // Callbacks will be run on the same thread. | |
| 25 class AVDASurfaceTracker { | |
| 26 public: | |
| 27 AVDASurfaceTracker(); | |
| 28 ~AVDASurfaceTracker(); | |
| 29 | |
| 30 static AVDASurfaceTracker* GetInstance(); | |
| 31 | |
| 32 void RegisterOnDestroyingSurfaceCallback( | |
| 33 const OnDestroyingSurfaceCallback& cb); | |
| 34 | |
| 35 // Unregister a callback that was previously registered. | |
| 36 void UnregisterOnDestroyingSurfaceCallback( | |
| 37 const OnDestroyingSurfaceCallback& cb); | |
| 38 | |
| 39 // Called in response to a message from the Browser indicating that the given | |
| 40 // surface is in the process of being destroyed. | |
| 41 void NotifyDestroyingSurface(int surface_id); | |
| 42 | |
| 43 private: | |
| 44 std::vector<OnDestroyingSurfaceCallback> callbacks_; | |
| 45 base::ThreadChecker thread_checker_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(AVDASurfaceTracker); | |
| 48 }; | |
| 49 | |
| 50 } // namespace content | |
| 51 | |
| 52 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_SURFACE_TRACKER_H_ | |
| OLD | NEW |