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

Side by Side Diff: ui/accelerated_widget_mac/io_surface_texture.h

Issue 753933002: MacViews: Move content::AcceleratedWidget to new component, ui/accelerated_widget_mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20141124-MacViews-MoveSoftwareLayerMac-fromcl
Patch Set: gn check Created 6 years 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_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ 5 #ifndef UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_H_
6 #define CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ 6 #define UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_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 <IOSurface/IOSurfaceAPI.h> 13 #include <IOSurface/IOSurfaceAPI.h>
14 #include <QuartzCore/QuartzCore.h> 14 #include <QuartzCore/QuartzCore.h>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/mac/scoped_cftyperef.h" 18 #include "base/mac/scoped_cftyperef.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "media/base/video_frame.h" 22 #include "ui/gfx/geometry/size.h"
23 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
24 #include "ui/gfx/rect.h"
25 #include "ui/gfx/rect_conversions.h"
26 #include "ui/gfx/size.h"
27 24
28 class SkBitmap; 25 class SkBitmap;
29 26
30 namespace gfx { 27 namespace gfx {
31 class Rect; 28 class Rect;
32 } 29 }
33 30
34 namespace content { 31 namespace ui {
35 32
36 class IOSurfaceContext; 33 class IOSurfaceContext;
37 class RenderWidgetHostViewFrameSubscriber; 34 class RenderWidgetHostViewFrameSubscriber;
38 class RenderWidgetHostViewMac; 35 class RenderWidgetHostViewMac;
39 36
40 // This class manages an OpenGL context and IOSurfaceTexture for the accelerated 37 // This class manages an OpenGL context and IOSurfaceTexture for the accelerated
41 // compositing code path. The GL context is attached to 38 // compositing code path. The GL context is attached to
42 // RenderWidgetHostViewCocoa for blitting the IOSurfaceTexture. 39 // RenderWidgetHostViewCocoa for blitting the IOSurfaceTexture.
43 class IOSurfaceTexture 40 class IOSurfaceTexture
44 : public base::RefCounted<IOSurfaceTexture> { 41 : public base::RefCounted<IOSurfaceTexture> {
45 public: 42 public:
46 // Returns NULL if IOSurfaceTexture or GL API calls fail. 43 // Returns NULL if IOSurfaceTexture or GL API calls fail.
47 static scoped_refptr<IOSurfaceTexture> Create(); 44 static scoped_refptr<IOSurfaceTexture> Create(
45 bool needs_gl_finish_workaround);
48 46
49 // Set IOSurfaceTexture that will be drawn on the next NSView drawRect. 47 // Set IOSurfaceTexture that will be drawn on the next NSView drawRect.
50 bool SetIOSurface( 48 bool SetIOSurface(
51 IOSurfaceID io_surface_id, 49 IOSurfaceID io_surface_id,
52 const gfx::Size& pixel_size) WARN_UNUSED_RESULT; 50 const gfx::Size& pixel_size) WARN_UNUSED_RESULT;
53 51
54 // Blit the IOSurface to the rectangle specified by |window_rect| in DIPs, 52 // Blit the IOSurface to the rectangle specified by |window_rect| in DIPs,
55 // with the origin in the lower left corner. If the window rect's size is 53 // with the origin in the lower left corner. If the window rect's size is
56 // larger than the IOSurface, the remaining right and bottom edges will be 54 // larger than the IOSurface, the remaining right and bottom edges will be
57 // white. |window_scale_factor| is 1 in normal views, 2 in HiDPI views. 55 // white. |window_scale_factor| is 1 in normal views, 2 in HiDPI views.
58 bool DrawIOSurface() WARN_UNUSED_RESULT; 56 bool DrawIOSurface() WARN_UNUSED_RESULT;
59 57
60 // Returns true if the offscreen context used by this surface has been 58 // Returns true if the offscreen context used by this surface has been
61 // poisoned. 59 // poisoned.
62 bool HasBeenPoisoned() const; 60 bool HasBeenPoisoned() const;
63 61
64 private: 62 private:
65 friend class base::RefCounted<IOSurfaceTexture>; 63 friend class base::RefCounted<IOSurfaceTexture>;
66 64
67 IOSurfaceTexture( 65 IOSurfaceTexture(
68 const scoped_refptr<IOSurfaceContext>& context); 66 const scoped_refptr<IOSurfaceContext>& context,
67 bool needs_gl_finish_workaround);
69 ~IOSurfaceTexture(); 68 ~IOSurfaceTexture();
70 69
71 // Unref the IOSurfaceTexture and delete the associated GL texture. If the GPU 70 // Unref the IOSurfaceTexture and delete the associated GL texture. If the GPU
72 // process is no longer referencing it, this will delete the IOSurface. 71 // process is no longer referencing it, this will delete the IOSurface.
73 void ReleaseIOSurfaceAndTexture(); 72 void ReleaseIOSurfaceAndTexture();
74 73
75 // Check for GL errors and store the result in error_. Only return new 74 // Check for GL errors and store the result in error_. Only return new
76 // errors 75 // errors
77 GLenum GetAndSaveGLError(); 76 GLenum GetAndSaveGLError();
78 77
(...skipping 23 matching lines...) Expand all
102 // Aggressively evict surfaces when more than 8 (the number allowed by the 101 // Aggressively evict surfaces when more than 8 (the number allowed by the
103 // memory manager for fast tab switching) are allocated. 102 // memory manager for fast tab switching) are allocated.
104 enum { 103 enum {
105 kMaximumUnevictedSurfaces = 8, 104 kMaximumUnevictedSurfaces = 8,
106 }; 105 };
107 typedef std::list<IOSurfaceTexture*> EvictionQueue; 106 typedef std::list<IOSurfaceTexture*> EvictionQueue;
108 void EvictionMarkUpdated(); 107 void EvictionMarkUpdated();
109 void EvictionMarkEvicted(); 108 void EvictionMarkEvicted();
110 EvictionQueue::iterator eviction_queue_iterator_; 109 EvictionQueue::iterator eviction_queue_iterator_;
111 bool eviction_has_been_drawn_since_updated_; 110 bool eviction_has_been_drawn_since_updated_;
111 const bool needs_gl_finish_workaround_;
112 112
113 static void EvictionScheduleDoEvict(); 113 static void EvictionScheduleDoEvict();
114 static void EvictionDoEvict(); 114 static void EvictionDoEvict();
115 static base::LazyInstance<EvictionQueue> eviction_queue_; 115 static base::LazyInstance<EvictionQueue> eviction_queue_;
116 static bool eviction_scheduled_; 116 static bool eviction_scheduled_;
117 }; 117 };
118 118
119 } // namespace content 119 } // namespace ui
120 120
121 #endif // CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ 121 #endif // UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_H_
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/io_surface_layer.mm ('k') | ui/accelerated_widget_mac/io_surface_texture.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698