| 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 CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // compositing code path. The GL context is attached to | 42 // compositing code path. The GL context is attached to |
| 43 // RenderWidgetHostViewCocoa for blitting the IOSurfaceTexture. | 43 // RenderWidgetHostViewCocoa for blitting the IOSurfaceTexture. |
| 44 class IOSurfaceTexture | 44 class IOSurfaceTexture |
| 45 : public base::RefCounted<IOSurfaceTexture> { | 45 : public base::RefCounted<IOSurfaceTexture> { |
| 46 public: | 46 public: |
| 47 // Returns NULL if IOSurfaceTexture or GL API calls fail. | 47 // Returns NULL if IOSurfaceTexture or GL API calls fail. |
| 48 static scoped_refptr<IOSurfaceTexture> Create(); | 48 static scoped_refptr<IOSurfaceTexture> Create(); |
| 49 | 49 |
| 50 // Set IOSurfaceTexture that will be drawn on the next NSView drawRect. | 50 // Set IOSurfaceTexture that will be drawn on the next NSView drawRect. |
| 51 bool SetIOSurface( | 51 bool SetIOSurface( |
| 52 scoped_refptr<IOSurfaceContext> context, | |
| 53 IOSurfaceID io_surface_id, | 52 IOSurfaceID io_surface_id, |
| 54 const gfx::Size& pixel_size) WARN_UNUSED_RESULT; | 53 const gfx::Size& pixel_size) WARN_UNUSED_RESULT; |
| 55 | 54 |
| 56 // Get the CGL renderer ID currently associated with this context. | |
| 57 int GetRendererID(); | |
| 58 | |
| 59 // Blit the IOSurface to the rectangle specified by |window_rect| in DIPs, | 55 // Blit the IOSurface to the rectangle specified by |window_rect| in DIPs, |
| 60 // with the origin in the lower left corner. If the window rect's size is | 56 // with the origin in the lower left corner. If the window rect's size is |
| 61 // larger than the IOSurface, the remaining right and bottom edges will be | 57 // larger than the IOSurface, the remaining right and bottom edges will be |
| 62 // white. |window_scale_factor| is 1 in normal views, 2 in HiDPI views. | 58 // white. |window_scale_factor| is 1 in normal views, 2 in HiDPI views. |
| 63 bool DrawIOSurface() WARN_UNUSED_RESULT; | 59 bool DrawIOSurface() WARN_UNUSED_RESULT; |
| 64 | 60 |
| 65 bool HasIOSurface() { return !!io_surface_.get(); } | |
| 66 | |
| 67 // Returns true if the offscreen context used by this surface has been | 61 // Returns true if the offscreen context used by this surface has been |
| 68 // poisoned. | 62 // poisoned. |
| 69 bool HasBeenPoisoned() const; | 63 bool HasBeenPoisoned() const; |
| 70 | 64 |
| 71 private: | 65 private: |
| 72 friend class base::RefCounted<IOSurfaceTexture>; | 66 friend class base::RefCounted<IOSurfaceTexture>; |
| 73 | 67 |
| 74 IOSurfaceTexture( | 68 IOSurfaceTexture( |
| 75 const scoped_refptr<IOSurfaceContext>& context); | 69 const scoped_refptr<IOSurfaceContext>& context); |
| 76 ~IOSurfaceTexture(); | 70 ~IOSurfaceTexture(); |
| 77 | 71 |
| 78 // Unref the IOSurfaceTexture and delete the associated GL texture. If the GPU | 72 // Unref the IOSurfaceTexture and delete the associated GL texture. If the GPU |
| 79 // process is no longer referencing it, this will delete the IOSurface. | 73 // process is no longer referencing it, this will delete the IOSurface. |
| 80 void UnrefIOSurface(); | 74 void ReleaseIOSurfaceAndTexture(); |
| 81 void UnrefIOSurfaceWithContextCurrent(); | |
| 82 | 75 |
| 83 // Check for GL errors and store the result in error_. Only return new | 76 // Check for GL errors and store the result in error_. Only return new |
| 84 // errors | 77 // errors |
| 85 GLenum GetAndSaveGLError(); | 78 GLenum GetAndSaveGLError(); |
| 86 | 79 |
| 87 // Offscreen context used for all operations other than drawing to the | 80 // Offscreen context used for all operations other than drawing to the |
| 88 // screen. This is in the same share group as the contexts used for | 81 // screen. This is in the same share group as the contexts used for |
| 89 // drawing, and is the same for all IOSurfaces in all windows. | 82 // drawing, and is the same for all IOSurfaces in all windows. |
| 90 scoped_refptr<IOSurfaceContext> offscreen_context_; | 83 scoped_refptr<IOSurfaceContext> offscreen_context_; |
| 91 | 84 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 120 | 113 |
| 121 static void EvictionScheduleDoEvict(); | 114 static void EvictionScheduleDoEvict(); |
| 122 static void EvictionDoEvict(); | 115 static void EvictionDoEvict(); |
| 123 static base::LazyInstance<EvictionQueue> eviction_queue_; | 116 static base::LazyInstance<EvictionQueue> eviction_queue_; |
| 124 static bool eviction_scheduled_; | 117 static bool eviction_scheduled_; |
| 125 }; | 118 }; |
| 126 | 119 |
| 127 } // namespace content | 120 } // namespace content |
| 128 | 121 |
| 129 #endif // CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ | 122 #endif // CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_TEXTURE_MAC_H_ |
| OLD | NEW |