| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ | 5 #ifndef UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ |
| 6 #define UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ | 6 #define UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ |
| 7 | 7 |
| 8 #include <d3d9.h> | 8 #include <d3d9.h> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class Rect; | 25 class Rect; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace media { | 28 namespace media { |
| 29 class VideoFrame; | 29 class VideoFrame; |
| 30 } | 30 } |
| 31 | 31 |
| 32 class SURFACE_EXPORT AcceleratedPresenter | 32 class SURFACE_EXPORT AcceleratedPresenter |
| 33 : public base::RefCountedThreadSafe<AcceleratedPresenter> { | 33 : public base::RefCountedThreadSafe<AcceleratedPresenter> { |
| 34 public: | 34 public: |
| 35 typedef base::Callback<void(bool, | 35 typedef base::Callback<void( |
| 36 base::TimeTicks, | 36 bool, |
| 37 base::TimeDelta, | 37 base::TimeTicks, |
| 38 const ui::LatencyInfo&)> CompletionTask; | 38 base::TimeDelta, |
| 39 const std::vector<ui::LatencyInfo>&)> CompletionTask; |
| 39 | 40 |
| 40 explicit AcceleratedPresenter(gfx::PluginWindowHandle window); | 41 explicit AcceleratedPresenter(gfx::PluginWindowHandle window); |
| 41 | 42 |
| 42 static void SetAdapterLUID(uint64 adapter_luid); | 43 static void SetAdapterLUID(uint64 adapter_luid); |
| 43 | 44 |
| 44 // Returns a thread safe reference to the presenter for the given window or | 45 // Returns a thread safe reference to the presenter for the given window or |
| 45 // null is no such presenter exists. The thread safe refptr ensures the | 46 // null is no such presenter exists. The thread safe refptr ensures the |
| 46 // presenter will not be destroyed. This can be called on any thread. | 47 // presenter will not be destroyed. This can be called on any thread. |
| 47 static scoped_refptr<AcceleratedPresenter> GetForWindow( | 48 static scoped_refptr<AcceleratedPresenter> GetForWindow( |
| 48 gfx::PluginWindowHandle window); | 49 gfx::PluginWindowHandle window); |
| 49 | 50 |
| 50 // Schedule a frame to be presented. The completion callback will be invoked | 51 // Schedule a frame to be presented. The completion callback will be invoked |
| 51 // when it is safe to write to the surface on another thread. The lock for | 52 // when it is safe to write to the surface on another thread. The lock for |
| 52 // this surface will be held while the completion callback runs. This can be | 53 // this surface will be held while the completion callback runs. This can be |
| 53 // called on any thread. | 54 // called on any thread. |
| 54 void AsyncPresentAndAcknowledge( | 55 void AsyncPresentAndAcknowledge( |
| 55 const gfx::Size& size, | 56 const gfx::Size& size, |
| 56 int64 surface_handle, | 57 int64 surface_handle, |
| 57 const ui::LatencyInfo& latency_info, | 58 const std::vector<ui::LatencyInfo>& latency_info, |
| 58 const CompletionTask& completion_task); | 59 const CompletionTask& completion_task); |
| 59 | 60 |
| 60 // Returns true if the swap chain has been created and initialized. This can | 61 // Returns true if the swap chain has been created and initialized. This can |
| 61 // be called on any thread. | 62 // be called on any thread. |
| 62 bool IsSwapChainInitialized() const; | 63 bool IsSwapChainInitialized() const; |
| 63 | 64 |
| 64 // Schedule the presenter to free all its resources. This can be called on any | 65 // Schedule the presenter to free all its resources. This can be called on any |
| 65 // thread. | 66 // thread. |
| 66 void Suspend(); | 67 void Suspend(); |
| 67 | 68 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 92 private: | 93 private: |
| 93 friend class base::RefCountedThreadSafe<AcceleratedPresenter>; | 94 friend class base::RefCountedThreadSafe<AcceleratedPresenter>; |
| 94 | 95 |
| 95 ~AcceleratedPresenter(); | 96 ~AcceleratedPresenter(); |
| 96 | 97 |
| 97 // These member functions are called on the PresentThread with which the | 98 // These member functions are called on the PresentThread with which the |
| 98 // presenter has affinity. | 99 // presenter has affinity. |
| 99 void DoPresentAndAcknowledge( | 100 void DoPresentAndAcknowledge( |
| 100 const gfx::Size& size, | 101 const gfx::Size& size, |
| 101 int64 surface_handle, | 102 int64 surface_handle, |
| 102 const ui::LatencyInfo& latency_info, | 103 const std::vector<ui::LatencyInfo>& latency_info, |
| 103 const CompletionTask& completion_task); | 104 const CompletionTask& completion_task); |
| 104 void DoSuspend(); | 105 void DoSuspend(); |
| 105 void DoPresent(const base::Closure& composite_task); | 106 void DoPresent(const base::Closure& composite_task); |
| 106 void DoReleaseSurface(); | 107 void DoReleaseSurface(); |
| 107 void DoCopyToAndAcknowledge( | 108 void DoCopyToAndAcknowledge( |
| 108 const gfx::Rect& src_subrect, | 109 const gfx::Rect& src_subrect, |
| 109 const gfx::Size& dst_size, | 110 const gfx::Size& dst_size, |
| 110 scoped_refptr<base::SingleThreadTaskRunner> callback_runner, | 111 scoped_refptr<base::SingleThreadTaskRunner> callback_runner, |
| 111 const base::Callback<void(bool, const SkBitmap&)>& callback); | 112 const base::Callback<void(bool, const SkBitmap&)>& callback); |
| 112 void DoCopyToVideoFrameAndAcknowledge( | 113 void DoCopyToVideoFrameAndAcknowledge( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // Set to true when the Windows session is locked. | 167 // Set to true when the Windows session is locked. |
| 167 bool is_session_locked_; | 168 bool is_session_locked_; |
| 168 | 169 |
| 169 // These are used to detect when the window is resizing. For some reason, | 170 // These are used to detect when the window is resizing. For some reason, |
| 170 // presenting with D3D while the window resizes causes those parts not | 171 // presenting with D3D while the window resizes causes those parts not |
| 171 // drawn with D3D (e.g. with GDI) to flicker visible / invisible. | 172 // drawn with D3D (e.g. with GDI) to flicker visible / invisible. |
| 172 // http://crbug.com/120904 | 173 // http://crbug.com/120904 |
| 173 gfx::Size last_window_size_; | 174 gfx::Size last_window_size_; |
| 174 base::Time last_window_resize_time_; | 175 base::Time last_window_resize_time_; |
| 175 | 176 |
| 176 ui::LatencyInfo latency_info_; | 177 std::vector<ui::LatencyInfo> latency_info_; |
| 177 | 178 |
| 178 DISALLOW_COPY_AND_ASSIGN(AcceleratedPresenter); | 179 DISALLOW_COPY_AND_ASSIGN(AcceleratedPresenter); |
| 179 }; | 180 }; |
| 180 | 181 |
| 181 class SURFACE_EXPORT AcceleratedSurface { | 182 class SURFACE_EXPORT AcceleratedSurface { |
| 182 public: | 183 public: |
| 183 AcceleratedSurface(gfx::PluginWindowHandle window); | 184 AcceleratedSurface(gfx::PluginWindowHandle window); |
| 184 ~AcceleratedSurface(); | 185 ~AcceleratedSurface(); |
| 185 | 186 |
| 186 // Synchronously present a frame with no acknowledgement. | 187 // Synchronously present a frame with no acknowledgement. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 213 | 214 |
| 214 // Called when the Windows session in locked or unlocked. | 215 // Called when the Windows session in locked or unlocked. |
| 215 void SetIsSessionLocked(bool locked); | 216 void SetIsSessionLocked(bool locked); |
| 216 | 217 |
| 217 private: | 218 private: |
| 218 const scoped_refptr<AcceleratedPresenter> presenter_; | 219 const scoped_refptr<AcceleratedPresenter> presenter_; |
| 219 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); | 220 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); |
| 220 }; | 221 }; |
| 221 | 222 |
| 222 #endif // UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ | 223 #endif // UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ |
| OLD | NEW |