| 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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
| 18 #include "ui/surface/surface_export.h" | 18 #include "ui/surface/surface_export.h" |
| 19 | 19 |
| 20 class PresentThread; | 20 class PresentThread; |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 class Rect; | 23 class Rect; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class SURFACE_EXPORT AcceleratedPresenter | 26 class SURFACE_EXPORT AcceleratedPresenter |
| 27 : public base::RefCountedThreadSafe<AcceleratedPresenter> { | 27 : public base::RefCountedThreadSafe<AcceleratedPresenter> { |
| 28 public: | 28 public: |
| 29 typedef base::Callback<void(bool)> CopyCompletionTask; | 29 typedef base::Callback<void(bool, |
| 30 | 30 base::TimeTicks, |
| 31 typedef base::Callback<void(base::TimeTicks, | 31 base::TimeDelta)> CompletionTask; |
| 32 base::TimeDelta)> PresentCompletionTask; | |
| 33 | 32 |
| 34 explicit AcceleratedPresenter(gfx::PluginWindowHandle window); | 33 explicit AcceleratedPresenter(gfx::PluginWindowHandle window); |
| 35 | 34 |
| 36 // Returns a thread safe reference to the presenter for the given window or | 35 // Returns a thread safe reference to the presenter for the given window or |
| 37 // null is no such presenter exists. The thread safe refptr ensures the | 36 // null is no such presenter exists. The thread safe refptr ensures the |
| 38 // presenter will not be destroyed. This can be called on any thread. | 37 // presenter will not be destroyed. This can be called on any thread. |
| 39 static scoped_refptr<AcceleratedPresenter> GetForWindow( | 38 static scoped_refptr<AcceleratedPresenter> GetForWindow( |
| 40 gfx::PluginWindowHandle window); | 39 gfx::PluginWindowHandle window); |
| 41 | 40 |
| 42 // Schedule a frame to be presented. The completion callback will be invoked | 41 // Schedule a frame to be presented. The completion callback will be invoked |
| 43 // when it is safe to write to the surface on another thread. The lock for | 42 // when it is safe to write to the surface on another thread. The lock for |
| 44 // this surface will be held while the completion callback runs. This can be | 43 // this surface will be held while the completion callback runs. This can be |
| 45 // called on any thread. | 44 // called on any thread. |
| 46 void AsyncPresentAndAcknowledge( | 45 void AsyncPresentAndAcknowledge( |
| 47 const gfx::Size& size, | 46 const gfx::Size& size, |
| 48 int64 surface_handle, | 47 int64 surface_handle, |
| 49 const CopyCompletionTask& copy_completion_task, | 48 const CompletionTask& completion_task); |
| 50 const PresentCompletionTask& present_completion_task); | |
| 51 | 49 |
| 52 // Schedule the presenter to free all its resources. This can be called on any | 50 // Schedule the presenter to free all its resources. This can be called on any |
| 53 // thread. | 51 // thread. |
| 54 void Suspend(); | 52 void Suspend(); |
| 55 | 53 |
| 56 // Indicates that the presenter has become invisible. | 54 // Indicates that the presenter has become invisible. |
| 57 void WasHidden(); | 55 void WasHidden(); |
| 58 | 56 |
| 59 // Schedule the presenter to release its reference to the shared surface. | 57 // Schedule the presenter to release its reference to the shared surface. |
| 60 void ReleaseSurface(); | 58 void ReleaseSurface(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 private: | 74 private: |
| 77 friend class base::RefCountedThreadSafe<AcceleratedPresenter>; | 75 friend class base::RefCountedThreadSafe<AcceleratedPresenter>; |
| 78 | 76 |
| 79 ~AcceleratedPresenter(); | 77 ~AcceleratedPresenter(); |
| 80 | 78 |
| 81 // These member functions are called on the PresentThread with which the | 79 // These member functions are called on the PresentThread with which the |
| 82 // presenter has affinity. | 80 // presenter has affinity. |
| 83 void DoPresentAndAcknowledge( | 81 void DoPresentAndAcknowledge( |
| 84 const gfx::Size& size, | 82 const gfx::Size& size, |
| 85 int64 surface_handle, | 83 int64 surface_handle, |
| 86 const CopyCompletionTask& copy_completion_task, | 84 const CompletionTask& completion_task); |
| 87 const PresentCompletionTask& present_completion_task); | |
| 88 void DoSuspend(); | 85 void DoSuspend(); |
| 89 void DoPresent(const base::Closure& composite_task); | 86 void DoPresent(const base::Closure& composite_task); |
| 90 void DoReleaseSurface(); | 87 void DoReleaseSurface(); |
| 91 void DoCopyToAndAcknowledge( | 88 void DoCopyToAndAcknowledge( |
| 92 const gfx::Rect& src_subrect, | 89 const gfx::Rect& src_subrect, |
| 93 const gfx::Size& dst_size, | 90 const gfx::Size& dst_size, |
| 94 void* buf, | 91 void* buf, |
| 95 scoped_refptr<base::SingleThreadTaskRunner> callback_runner, | 92 scoped_refptr<base::SingleThreadTaskRunner> callback_runner, |
| 96 const base::Callback<void(bool)>& callback); | 93 const base::Callback<void(bool)>& callback); |
| 97 bool DoCopyTo(const gfx::Rect& src_subrect, | 94 bool DoCopyTo(const gfx::Rect& src_subrect, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 174 |
| 178 // Indicates that the surface has become invisible. | 175 // Indicates that the surface has become invisible. |
| 179 void WasHidden(); | 176 void WasHidden(); |
| 180 | 177 |
| 181 private: | 178 private: |
| 182 const scoped_refptr<AcceleratedPresenter> presenter_; | 179 const scoped_refptr<AcceleratedPresenter> presenter_; |
| 183 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); | 180 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); |
| 184 }; | 181 }; |
| 185 | 182 |
| 186 #endif // UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ | 183 #endif // UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ |
| OLD | NEW |