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