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

Side by Side Diff: content/browser/renderer_host/compositing_iosurface_mac.h

Issue 294023012: Use a separate NSView to draw browser composited content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments, clean-u Created 6 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
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 CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <vector> 10 #include <vector>
11 11
12 #import <Cocoa/Cocoa.h> 12 #import <Cocoa/Cocoa.h>
13 #include <QuartzCore/QuartzCore.h> 13 #include <QuartzCore/QuartzCore.h>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/mac/scoped_cftyperef.h" 17 #include "base/mac/scoped_cftyperef.h"
18 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
20 #include "base/timer/timer.h" 21 #include "base/timer/timer.h"
21 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
22 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
23 #include "ui/gfx/rect.h" 24 #include "ui/gfx/rect.h"
24 #include "ui/gfx/rect_conversions.h" 25 #include "ui/gfx/rect_conversions.h"
25 #include "ui/gfx/size.h" 26 #include "ui/gfx/size.h"
26 27
27 class IOSurfaceSupport; 28 class IOSurfaceSupport;
28 class SkBitmap; 29 class SkBitmap;
29 30
30 namespace gfx { 31 namespace gfx {
31 class Rect; 32 class Rect;
32 } 33 }
33 34
34 namespace content { 35 namespace content {
35 36
36 class CompositingIOSurfaceContext; 37 class CompositingIOSurfaceContext;
37 class CompositingIOSurfaceShaderPrograms; 38 class CompositingIOSurfaceShaderPrograms;
38 class CompositingIOSurfaceTransformer; 39 class CompositingIOSurfaceTransformer;
39 class RenderWidgetHostViewFrameSubscriber; 40 class RenderWidgetHostViewFrameSubscriber;
40 class RenderWidgetHostViewMac; 41 class RenderWidgetHostViewMac;
41 42
42 // This class manages an OpenGL context and IOSurface for the accelerated 43 // This class manages an OpenGL context and IOSurface for the accelerated
43 // compositing code path. The GL context is attached to 44 // compositing code path. The GL context is attached to
44 // RenderWidgetHostViewCocoa for blitting the IOSurface. 45 // RenderWidgetHostViewCocoa for blitting the IOSurface.
45 class CompositingIOSurfaceMac { 46 class CompositingIOSurfaceMac
47 : public base::RefCounted<CompositingIOSurfaceMac> {
46 public: 48 public:
47 // Returns NULL if IOSurface support is missing or GL APIs fail. 49 // Returns NULL if IOSurface support is missing or GL APIs fail.
48 static CompositingIOSurfaceMac* Create(); 50 static scoped_refptr<CompositingIOSurfaceMac> Create();
49 ~CompositingIOSurfaceMac();
50 51
51 // Set IOSurface that will be drawn on the next NSView drawRect. 52 // Set IOSurface that will be drawn on the next NSView drawRect.
52 bool SetIOSurfaceWithContextCurrent( 53 bool SetIOSurfaceWithContextCurrent(
53 scoped_refptr<CompositingIOSurfaceContext> current_context, 54 scoped_refptr<CompositingIOSurfaceContext> current_context,
54 uint64 io_surface_handle, 55 uint64 io_surface_handle,
55 const gfx::Size& size, 56 const gfx::Size& size,
56 float scale_factor) WARN_UNUSED_RESULT; 57 float scale_factor) WARN_UNUSED_RESULT;
57 58
58 // Get the CGL renderer ID currently associated with this context. 59 // Get the CGL renderer ID currently associated with this context.
59 int GetRendererID(); 60 int GetRendererID();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Scan the list of started asynchronous copies and test if each one has 107 // Scan the list of started asynchronous copies and test if each one has
107 // completed. If |block_until_finished| is true, then block until all 108 // completed. If |block_until_finished| is true, then block until all
108 // pending copies are finished. 109 // pending copies are finished.
109 void CheckIfAllCopiesAreFinished(bool block_until_finished); 110 void CheckIfAllCopiesAreFinished(bool block_until_finished);
110 111
111 // Returns true if the offscreen context used by this surface has been 112 // Returns true if the offscreen context used by this surface has been
112 // poisoned. 113 // poisoned.
113 bool HasBeenPoisoned() const; 114 bool HasBeenPoisoned() const;
114 115
115 private: 116 private:
117 friend class base::RefCounted<CompositingIOSurfaceMac>;
118
116 // Vertex structure for use in glDraw calls. 119 // Vertex structure for use in glDraw calls.
117 struct SurfaceVertex { 120 struct SurfaceVertex {
118 SurfaceVertex() : x_(0.0f), y_(0.0f), tx_(0.0f), ty_(0.0f) { } 121 SurfaceVertex() : x_(0.0f), y_(0.0f), tx_(0.0f), ty_(0.0f) { }
119 void set(float x, float y, float tx, float ty) { 122 void set(float x, float y, float tx, float ty) {
120 x_ = x; 123 x_ = x;
121 y_ = y; 124 y_ = y;
122 tx_ = tx; 125 tx_ = tx;
123 ty_ = ty; 126 ty_ = ty;
124 } 127 }
125 void set_position(float x, float y) { 128 void set_position(float x, float y) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 GLuint pixel_buffers[3]; 199 GLuint pixel_buffers[3];
197 GLuint fence; // When non-zero, doing an asynchronous copy. 200 GLuint fence; // When non-zero, doing an asynchronous copy.
198 int cycles_elapsed; 201 int cycles_elapsed;
199 base::Callback<bool(const void*, int)> map_buffer_callback; 202 base::Callback<bool(const void*, int)> map_buffer_callback;
200 base::Callback<void(bool)> done_callback; 203 base::Callback<void(bool)> done_callback;
201 }; 204 };
202 205
203 CompositingIOSurfaceMac( 206 CompositingIOSurfaceMac(
204 IOSurfaceSupport* io_surface_support, 207 IOSurfaceSupport* io_surface_support,
205 const scoped_refptr<CompositingIOSurfaceContext>& context); 208 const scoped_refptr<CompositingIOSurfaceContext>& context);
209 ~CompositingIOSurfaceMac();
206 210
207 // If this IOSurface has moved to a different window, use that window's 211 // If this IOSurface has moved to a different window, use that window's
208 // GL context (if multiple visible windows are using the same GL context 212 // GL context (if multiple visible windows are using the same GL context
209 // then call to setView call can stall and prevent reaching 60fps). 213 // then call to setView call can stall and prevent reaching 60fps).
210 void SwitchToContextOnNewWindow(NSView* view, 214 void SwitchToContextOnNewWindow(NSView* view,
211 int window_number); 215 int window_number);
212 216
213 // Returns true if IOSurface is ready to render. False otherwise. 217 // Returns true if IOSurface is ready to render. False otherwise.
214 bool MapIOSurfaceToTextureWithContextCurrent( 218 bool MapIOSurfaceToTextureWithContextCurrent(
215 const scoped_refptr<CompositingIOSurfaceContext>& current_context, 219 const scoped_refptr<CompositingIOSurfaceContext>& current_context,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 327
324 static void EvictionScheduleDoEvict(); 328 static void EvictionScheduleDoEvict();
325 static void EvictionDoEvict(); 329 static void EvictionDoEvict();
326 static base::LazyInstance<EvictionQueue> eviction_queue_; 330 static base::LazyInstance<EvictionQueue> eviction_queue_;
327 static bool eviction_scheduled_; 331 static bool eviction_scheduled_;
328 }; 332 };
329 333
330 } // namespace content 334 } // namespace content
331 335
332 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_ 336 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698