Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Side by Side Diff: ui/surface/accelerated_surface_win.h

Issue 12090109: Tab Capture: Backing store readbacks to YV12 VideoFrames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix per wjia Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/time.h"
15 #include "base/win/scoped_comptr.h" 16 #include "base/win/scoped_comptr.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/size.h" 18 #include "ui/gfx/size.h"
18 #include "ui/surface/surface_export.h" 19 #include "ui/surface/surface_export.h"
19 20
20 class PresentThread; 21 class PresentThread;
21 22
22 namespace gfx { 23 namespace gfx {
23 class Rect; 24 class Rect;
24 } 25 }
25 26
27 namespace media {
28 class VideoFrame;
29 }
30
26 class SURFACE_EXPORT AcceleratedPresenter 31 class SURFACE_EXPORT AcceleratedPresenter
27 : public base::RefCountedThreadSafe<AcceleratedPresenter> { 32 : public base::RefCountedThreadSafe<AcceleratedPresenter> {
28 public: 33 public:
29 typedef base::Callback<void(bool, 34 typedef base::Callback<void(bool,
30 base::TimeTicks, 35 base::TimeTicks,
31 base::TimeDelta)> CompletionTask; 36 base::TimeDelta)> CompletionTask;
32 37
33 explicit AcceleratedPresenter(gfx::PluginWindowHandle window); 38 explicit AcceleratedPresenter(gfx::PluginWindowHandle window);
34 39
35 // Returns a thread safe reference to the presenter for the given window or 40 // Returns a thread safe reference to the presenter for the given window or
(...skipping 22 matching lines...) Expand all
58 void SetIsSessionLocked(bool locked); 63 void SetIsSessionLocked(bool locked);
59 64
60 // Schedule the presenter to release its reference to the shared surface. 65 // Schedule the presenter to release its reference to the shared surface.
61 void ReleaseSurface(); 66 void ReleaseSurface();
62 67
63 // The public member functions are called on the main thread. 68 // The public member functions are called on the main thread.
64 void Present(HDC dc); 69 void Present(HDC dc);
65 void AsyncCopyTo(const gfx::Rect& src_subrect, 70 void AsyncCopyTo(const gfx::Rect& src_subrect,
66 const gfx::Size& dst_size, 71 const gfx::Size& dst_size,
67 const base::Callback<void(bool, const SkBitmap&)>& callback); 72 const base::Callback<void(bool, const SkBitmap&)>& callback);
73 void AsyncCopyToVideoFrame(
74 const gfx::Rect& src_subrect,
75 const scoped_refptr<media::VideoFrame>& target,
76 const base::Callback<void(bool)>& callback);
68 void Invalidate(); 77 void Invalidate();
69 78
70 #if defined(USE_AURA) 79 #if defined(USE_AURA)
71 // TODO(scottmg): This is a temporary hack until we have a two-worlds ash/aura 80 // TODO(scottmg): This is a temporary hack until we have a two-worlds ash/aura
72 // separation. 81 // separation.
73 void SetNewTargetWindow(gfx::PluginWindowHandle window); 82 void SetNewTargetWindow(gfx::PluginWindowHandle window);
74 #endif 83 #endif
75 84
76 private: 85 private:
77 friend class base::RefCountedThreadSafe<AcceleratedPresenter>; 86 friend class base::RefCountedThreadSafe<AcceleratedPresenter>;
78 87
79 ~AcceleratedPresenter(); 88 ~AcceleratedPresenter();
80 89
81 // These member functions are called on the PresentThread with which the 90 // These member functions are called on the PresentThread with which the
82 // presenter has affinity. 91 // presenter has affinity.
83 void DoPresentAndAcknowledge( 92 void DoPresentAndAcknowledge(
84 const gfx::Size& size, 93 const gfx::Size& size,
85 int64 surface_handle, 94 int64 surface_handle,
86 const CompletionTask& completion_task); 95 const CompletionTask& completion_task);
87 void DoSuspend(); 96 void DoSuspend();
88 void DoPresent(const base::Closure& composite_task); 97 void DoPresent(const base::Closure& composite_task);
89 void DoReleaseSurface(); 98 void DoReleaseSurface();
90 void DoCopyToAndAcknowledge( 99 void DoCopyToAndAcknowledge(
91 const gfx::Rect& src_subrect, 100 const gfx::Rect& src_subrect,
92 const gfx::Size& dst_size, 101 const gfx::Size& dst_size,
93 scoped_refptr<base::SingleThreadTaskRunner> callback_runner, 102 scoped_refptr<base::SingleThreadTaskRunner> callback_runner,
94 const base::Callback<void(bool, const SkBitmap&)>& callback); 103 const base::Callback<void(bool, const SkBitmap&)>& callback);
95 bool DoCopyTo(const gfx::Rect& src_subrect, 104 void DoCopyToVideoFrameAndAcknowledge(
96 const gfx::Size& dst_size, 105 const gfx::Rect& src_subrect,
97 SkBitmap* bitmap); 106 const scoped_refptr<media::VideoFrame>& target,
107 const scoped_refptr<base::SingleThreadTaskRunner>& callback_runner,
108 const base::Callback<void(bool)>& callback);
109 bool DoCopyToYUV(const gfx::Rect& src_subrect,
110 const scoped_refptr<media::VideoFrame>& frame);
111 bool DoCopyToARGB(const gfx::Rect& src_subrect,
112 const gfx::Size& dst_size,
113 SkBitmap* bitmap);
98 114
99 void PresentWithGDI(HDC dc); 115 void PresentWithGDI(HDC dc);
100 gfx::Size GetWindowSize(); 116 gfx::Size GetWindowSize();
101 117
102 // This function tries to guess whether Direct3D will be able to reliably 118 // This function tries to guess whether Direct3D will be able to reliably
103 // present to the window. When the window is resizing, presenting with 119 // present to the window. When the window is resizing, presenting with
104 // Direct3D causes other regions of the window rendered with GDI to 120 // Direct3D causes other regions of the window rendered with GDI to
105 // flicker transparent / non-transparent. 121 // flicker transparent / non-transparent.
106 bool CheckDirect3DWillWork(); 122 bool CheckDirect3DWillWork();
107 123
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 }; 174 };
159 175
160 class SURFACE_EXPORT AcceleratedSurface { 176 class SURFACE_EXPORT AcceleratedSurface {
161 public: 177 public:
162 AcceleratedSurface(gfx::PluginWindowHandle window); 178 AcceleratedSurface(gfx::PluginWindowHandle window);
163 ~AcceleratedSurface(); 179 ~AcceleratedSurface();
164 180
165 // Synchronously present a frame with no acknowledgement. 181 // Synchronously present a frame with no acknowledgement.
166 void Present(HDC dc); 182 void Present(HDC dc);
167 183
168 // Copies the surface data to |buf|. The copied region is specified with 184 // Transfer the contents of the surface to an SkBitmap, and invoke a callback
169 // |src_subrect| and the image data is transformed so that it fits in 185 // with the result.
170 // |dst_size|.
171 // Caller must ensure that |buf| is allocated with the size no less than
172 // |4 * dst_size.width() * dst_size.height()| bytes.
173 void AsyncCopyTo(const gfx::Rect& src_subrect, 186 void AsyncCopyTo(const gfx::Rect& src_subrect,
174 const gfx::Size& dst_size, 187 const gfx::Size& dst_size,
175 const base::Callback<void(bool, const SkBitmap&)>& callback); 188 const base::Callback<void(bool, const SkBitmap&)>& callback);
176 189
190 // Transfer the contents of the surface to an already-allocated YV12
191 // VideoFrame, and invoke a callback to indicate success or failure.
192 void AsyncCopyToVideoFrame(
193 const gfx::Rect& src_subrect,
194 const scoped_refptr<media::VideoFrame>& target,
195 const base::Callback<void(bool)>& callback);
196
177 // Temporarily release resources until a new surface is asynchronously 197 // Temporarily release resources until a new surface is asynchronously
178 // presented. Present will not be able to represent the last surface after 198 // presented. Present will not be able to represent the last surface after
179 // calling this and will return false. 199 // calling this and will return false.
180 void Suspend(); 200 void Suspend();
181 201
182 // Indicates that the surface has become invisible. 202 // Indicates that the surface has become invisible.
183 void WasHidden(); 203 void WasHidden();
184 204
185 // Called when the Windows session in locked or unlocked. 205 // Called when the Windows session in locked or unlocked.
186 void SetIsSessionLocked(bool locked); 206 void SetIsSessionLocked(bool locked);
187 207
188 private: 208 private:
189 const scoped_refptr<AcceleratedPresenter> presenter_; 209 const scoped_refptr<AcceleratedPresenter> presenter_;
190 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); 210 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface);
191 }; 211 };
192 212
193 #endif // UI_SURFACE_ACCELERATED_SURFACE_WIN_H_ 213 #endif // UI_SURFACE_ACCELERATED_SURFACE_WIN_H_
OLDNEW
« no previous file with comments | « ui/surface/accelerated_surface_transformer_win_unittest.cc ('k') | ui/surface/accelerated_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698