| 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_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_H_ | 5 #ifndef UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_H_ |
| 6 #define UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_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> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class RenderWidgetHostViewFrameSubscriber; | 34 class RenderWidgetHostViewFrameSubscriber; |
| 35 class RenderWidgetHostViewMac; | 35 class RenderWidgetHostViewMac; |
| 36 | 36 |
| 37 // This class manages an OpenGL context and IOSurfaceTexture for the accelerated | 37 // This class manages an OpenGL context and IOSurfaceTexture for the accelerated |
| 38 // compositing code path. The GL context is attached to | 38 // compositing code path. The GL context is attached to |
| 39 // RenderWidgetHostViewCocoa for blitting the IOSurfaceTexture. | 39 // RenderWidgetHostViewCocoa for blitting the IOSurfaceTexture. |
| 40 class IOSurfaceTexture | 40 class IOSurfaceTexture |
| 41 : public base::RefCounted<IOSurfaceTexture> { | 41 : public base::RefCounted<IOSurfaceTexture> { |
| 42 public: | 42 public: |
| 43 static scoped_refptr<IOSurfaceTexture> Create( | 43 static scoped_refptr<IOSurfaceTexture> Create( |
| 44 bool needs_gl_finish_workaround); | 44 bool needs_gl_finish_workaround, |
| 45 bool use_ns_apis); |
| 45 | 46 |
| 46 // Returns true if there is no need to call SetIOSurface with the provided | 47 // Returns true if there is no need to call SetIOSurface with the provided |
| 47 // values. | 48 // values. |
| 48 bool IsUpToDate( | 49 bool IsUpToDate( |
| 49 IOSurfaceID io_surface_id, const gfx::Size& pixel_size) const; | 50 IOSurfaceID io_surface_id, const gfx::Size& pixel_size) const; |
| 50 | 51 |
| 51 // Set IOSurfaceTexture that will be drawn on the next NSView drawRect. | 52 // Set IOSurfaceTexture that will be drawn on the next NSView drawRect. |
| 52 bool SetIOSurface( | 53 bool SetIOSurface( |
| 53 IOSurfaceID io_surface_id, | 54 IOSurfaceID io_surface_id, |
| 54 const gfx::Size& pixel_size) WARN_UNUSED_RESULT; | 55 const gfx::Size& pixel_size) WARN_UNUSED_RESULT; |
| 55 | 56 |
| 56 // Blit the IOSurface to the rectangle specified by |window_rect| in DIPs, | 57 // Blit the IOSurface to the rectangle specified by |window_rect| in DIPs, |
| 57 // with the origin in the lower left corner. If the window rect's size is | 58 // with the origin in the lower left corner. If the window rect's size is |
| 58 // larger than the IOSurface, the remaining right and bottom edges will be | 59 // larger than the IOSurface, the remaining right and bottom edges will be |
| 59 // white. |window_scale_factor| is 1 in normal views, 2 in HiDPI views. | 60 // white. |window_scale_factor| is 1 in normal views, 2 in HiDPI views. |
| 60 bool DrawIOSurface() WARN_UNUSED_RESULT; | 61 bool DrawIOSurface() WARN_UNUSED_RESULT; |
| 61 bool DrawIOSurfaceWithDamageRect(gfx::Rect damage_rect) WARN_UNUSED_RESULT; | 62 bool DrawIOSurfaceWithDamageRect(gfx::Rect damage_rect) WARN_UNUSED_RESULT; |
| 62 | 63 |
| 63 // Returns true if the offscreen context used by this surface has been | 64 // Returns true if the offscreen context used by this surface has been |
| 64 // poisoned. | 65 // poisoned. |
| 65 bool HasBeenPoisoned() const; | 66 bool HasBeenPoisoned() const; |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 friend class base::RefCounted<IOSurfaceTexture>; | 69 friend class base::RefCounted<IOSurfaceTexture>; |
| 69 | 70 |
| 70 IOSurfaceTexture( | 71 IOSurfaceTexture( |
| 71 const scoped_refptr<IOSurfaceContext>& context, | 72 const scoped_refptr<IOSurfaceContext>& context, |
| 73 bool use_ns_apis, |
| 72 bool needs_gl_finish_workaround); | 74 bool needs_gl_finish_workaround); |
| 73 ~IOSurfaceTexture(); | 75 ~IOSurfaceTexture(); |
| 74 | 76 |
| 75 // Unref the IOSurfaceTexture and delete the associated GL texture. If the GPU | 77 // Unref the IOSurfaceTexture and delete the associated GL texture. If the GPU |
| 76 // process is no longer referencing it, this will delete the IOSurface. | 78 // process is no longer referencing it, this will delete the IOSurface. |
| 77 void ReleaseIOSurfaceAndTexture(); | 79 void ReleaseIOSurfaceAndTexture(); |
| 78 | 80 |
| 79 // Check for GL errors and store the result in error_. Only return new | 81 // Check for GL errors and store the result in error_. Only return new |
| 80 // errors | 82 // errors |
| 81 GLenum GetAndSaveGLError(); | 83 GLenum GetAndSaveGLError(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 106 // Aggressively evict surfaces when more than 8 (the number allowed by the | 108 // Aggressively evict surfaces when more than 8 (the number allowed by the |
| 107 // memory manager for fast tab switching) are allocated. | 109 // memory manager for fast tab switching) are allocated. |
| 108 enum { | 110 enum { |
| 109 kMaximumUnevictedSurfaces = 8, | 111 kMaximumUnevictedSurfaces = 8, |
| 110 }; | 112 }; |
| 111 typedef std::list<IOSurfaceTexture*> EvictionQueue; | 113 typedef std::list<IOSurfaceTexture*> EvictionQueue; |
| 112 void EvictionMarkUpdated(); | 114 void EvictionMarkUpdated(); |
| 113 void EvictionMarkEvicted(); | 115 void EvictionMarkEvicted(); |
| 114 EvictionQueue::iterator eviction_queue_iterator_; | 116 EvictionQueue::iterator eviction_queue_iterator_; |
| 115 bool eviction_has_been_drawn_since_updated_; | 117 bool eviction_has_been_drawn_since_updated_; |
| 118 |
| 116 const bool needs_gl_finish_workaround_; | 119 const bool needs_gl_finish_workaround_; |
| 117 | 120 |
| 121 // Set if this is for access through NS APIs. |
| 122 const bool using_ns_apis_; |
| 123 |
| 118 static void EvictionScheduleDoEvict(); | 124 static void EvictionScheduleDoEvict(); |
| 119 static void EvictionDoEvict(); | 125 static void EvictionDoEvict(); |
| 120 static base::LazyInstance<EvictionQueue> eviction_queue_; | 126 static base::LazyInstance<EvictionQueue> eviction_queue_; |
| 121 static bool eviction_scheduled_; | 127 static bool eviction_scheduled_; |
| 122 }; | 128 }; |
| 123 | 129 |
| 124 } // namespace ui | 130 } // namespace ui |
| 125 | 131 |
| 126 #endif // UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_H_ | 132 #endif // UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_TEXTURE_H_ |
| OLD | NEW |