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_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_ | 5 #ifndef UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_ |
6 #define UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_ | 6 #define UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <d3d9.h> | 9 #include <d3d9.h> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
14 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
16 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
17 #include "ui/gfx/surface/surface_export.h" | 18 #include "ui/gfx/surface/surface_export.h" |
18 | 19 |
19 class PresentThread; | 20 class PresentThread; |
20 | 21 |
21 class AcceleratedPresenter : public base::RefCounted<AcceleratedPresenter> { | 22 class AcceleratedPresenter : public base::RefCounted<AcceleratedPresenter> { |
22 public: | 23 public: |
23 AcceleratedPresenter(); | 24 AcceleratedPresenter(); |
24 | 25 |
25 // The public member functions are called on the main thread. | 26 // The public member functions are called on the main thread. |
26 void AsyncPresentAndAcknowledge(gfx::NativeWindow window, | 27 void AsyncPresentAndAcknowledge(gfx::NativeWindow window, |
27 const gfx::Size& size, | 28 const gfx::Size& size, |
28 int64 surface_id, | 29 int64 surface_id, |
29 const base::Closure& completion_task); | 30 const base::Closure& completion_task); |
30 bool Present(gfx::NativeWindow window); | 31 bool Present(gfx::NativeWindow window); |
| 32 bool CopyTo(const gfx::Size& size, std::vector<unsigned char>* buf); |
31 void Suspend(); | 33 void Suspend(); |
32 void WaitForPendingTasks(); | 34 void WaitForPendingTasks(); |
33 | 35 |
34 private: | 36 private: |
35 friend class base::RefCounted<AcceleratedPresenter>; | 37 friend class base::RefCounted<AcceleratedPresenter>; |
36 | 38 |
37 ~AcceleratedPresenter(); | 39 ~AcceleratedPresenter(); |
38 | 40 |
39 // These member functions are called on the PresentThread with which the | 41 // These member functions are called on the PresentThread with which the |
40 // presenter has affinity. | 42 // presenter has affinity. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // when it is safe to write to the surface on another thread. The lock for | 74 // when it is safe to write to the surface on another thread. The lock for |
73 // this surface will be held while the completion callback runs. | 75 // this surface will be held while the completion callback runs. |
74 void AsyncPresentAndAcknowledge(HWND window, | 76 void AsyncPresentAndAcknowledge(HWND window, |
75 const gfx::Size& size, | 77 const gfx::Size& size, |
76 int64 surface_id, | 78 int64 surface_id, |
77 const base::Closure& completion_task); | 79 const base::Closure& completion_task); |
78 | 80 |
79 // Synchronously present a frame with no acknowledgement. | 81 // Synchronously present a frame with no acknowledgement. |
80 bool Present(HWND window); | 82 bool Present(HWND window); |
81 | 83 |
| 84 // Copies the surface data to |buf|. The image data is transformed so that it |
| 85 // fits in |size|. |
| 86 bool CopyTo(const gfx::Size& size, std::vector<unsigned char>* buf); |
| 87 |
82 // Temporarily release resources until a new surface is asynchronously | 88 // Temporarily release resources until a new surface is asynchronously |
83 // presented. Present will not be able to represent the last surface after | 89 // presented. Present will not be able to represent the last surface after |
84 // calling this and will return false. | 90 // calling this and will return false. |
85 void Suspend(); | 91 void Suspend(); |
86 | 92 |
87 private: | 93 private: |
88 scoped_refptr<AcceleratedPresenter> presenter_; | 94 scoped_refptr<AcceleratedPresenter> presenter_; |
89 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); | 95 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); |
90 }; | 96 }; |
91 | 97 |
92 #endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_ | 98 #endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_ |
OLD | NEW |