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

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

Issue 10351002: ui: Move surface/ directory out of gfx/, up to ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gpu DEPS Created 8 years, 7 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
« no previous file with comments | « ui/gfx/surface/accelerated_surface_mac.cc ('k') | ui/gfx/surface/accelerated_surface_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_
6 #define UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_
7 #pragma once
8
9 #include <d3d9.h>
10
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/synchronization/lock.h"
14 #include "base/synchronization/waitable_event.h"
15 #include "base/win/scoped_comptr.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/size.h"
18 #include "ui/gfx/surface/surface_export.h"
19
20 class PresentThread;
21
22 class SURFACE_EXPORT AcceleratedPresenter
23 : public base::RefCountedThreadSafe<AcceleratedPresenter> {
24 public:
25 typedef base::Callback<void(bool)> CompletionTaskl;
26
27 explicit AcceleratedPresenter(gfx::NativeWindow window);
28
29 // Returns a thread safe reference to the presenter for the given window or
30 // null is no such presenter exists. The thread safe refptr ensures the
31 // presenter will not be destroyed. This can be called on any thread.
32 static scoped_refptr<AcceleratedPresenter> GetForWindow(
33 gfx::NativeWindow window);
34
35 // Schedule a frame to be presented. The completion callback will be invoked
36 // when it is safe to write to the surface on another thread. The lock for
37 // this surface will be held while the completion callback runs. This can be
38 // called on any thread.
39 void AsyncPresentAndAcknowledge(
40 const gfx::Size& size,
41 int64 surface_handle,
42 const base::Callback<void(bool)>& completion_task);
43
44 // Schedule the presenter to free all its resources. This can be called on any
45 // thread.
46 void Suspend();
47
48 // Schedule the presenter to release its reference to the shared surface.
49 void ReleaseSurface();
50
51 // The public member functions are called on the main thread.
52 bool Present();
53 bool CopyTo(const gfx::Size& size, void* buf);
54 void Invalidate();
55
56 private:
57 friend class base::RefCountedThreadSafe<AcceleratedPresenter>;
58
59 ~AcceleratedPresenter();
60
61 // These member functions are called on the PresentThread with which the
62 // presenter has affinity.
63 void DoPresentAndAcknowledge(
64 const gfx::Size& size,
65 int64 surface_handle,
66 const base::Callback<void(bool)>& completion_task);
67 void DoSuspend();
68 void DoPresent(bool* presented);
69 bool DoRealPresent();
70 void DoReleaseSurface();
71
72 // The thread with which this presenter has affinity.
73 PresentThread* const present_thread_;
74
75 // The window that is presented to.
76 gfx::NativeWindow window_;
77
78 // The lock is taken while any thread is calling the object, except those that
79 // simply post from the main thread to the present thread via the immutable
80 // present_thread_ member.
81 base::Lock lock_;
82
83 // UI thread can wait on this event to ensure a present is finished.
84 base::WaitableEvent event_;
85
86 // The current size of the swap chain. This is only accessed on the thread
87 // with which the surface has affinity.
88 gfx::Size size_;
89
90 // This is a shared texture that is being presented from.
91 base::win::ScopedComPtr<IDirect3DTexture9> source_texture_;
92
93 // The swap chain is presented to the child window. Copy semantics
94 // are used so it is possible to represent it to quickly validate the window.
95 base::win::ScopedComPtr<IDirect3DSwapChain9> swap_chain_;
96
97 DISALLOW_COPY_AND_ASSIGN(AcceleratedPresenter);
98 };
99
100 class SURFACE_EXPORT AcceleratedSurface {
101 public:
102 AcceleratedSurface(gfx::NativeWindow window);
103 ~AcceleratedSurface();
104
105 // Synchronously present a frame with no acknowledgement.
106 bool Present();
107
108 // Copies the surface data to |buf|. The image data is transformed so that it
109 // fits in |size|.
110 // Caller must ensure that |buf| is allocated with the size no less than
111 // |4 * size.width() * size.height()| bytes.
112 bool CopyTo(const gfx::Size& size, void* buf);
113
114 // Temporarily release resources until a new surface is asynchronously
115 // presented. Present will not be able to represent the last surface after
116 // calling this and will return false.
117 void Suspend();
118
119 private:
120 const scoped_refptr<AcceleratedPresenter> presenter_;
121 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface);
122 };
123
124 #endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_WIN_H_
OLDNEW
« no previous file with comments | « ui/gfx/surface/accelerated_surface_mac.cc ('k') | ui/gfx/surface/accelerated_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698