| 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_GL_GL_SURFACE_H_ |    5 #ifndef UI_GL_GL_SURFACE_H_ | 
|    6 #define UI_GL_GL_SURFACE_H_ |    6 #define UI_GL_GL_SURFACE_H_ | 
|    7  |    7  | 
|    8 #include <string> |    8 #include <string> | 
|    9  |    9  | 
|   10 #include "base/memory/ref_counted.h" |   10 #include "base/memory/ref_counted.h" | 
|   11 #include "build/build_config.h" |   11 #include "build/build_config.h" | 
|   12 #include "ui/gfx/native_widget_types.h" |   12 #include "ui/gfx/native_widget_types.h" | 
|   13 #include "ui/gfx/size.h" |   13 #include "ui/gfx/size.h" | 
|   14 #include "ui/gl/gl_export.h" |   14 #include "ui/gl/gl_export.h" | 
|   15 #include "ui/gl/gl_implementation.h" |  | 
|   16  |   15  | 
|   17 namespace gfx { |   16 namespace gfx { | 
|   18  |   17  | 
|   19 class GLContext; |   18 class GLContext; | 
|   20 class VSyncProvider; |   19 class VSyncProvider; | 
|   21  |   20  | 
|   22 // Encapsulates a surface that can be rendered to with GL, hiding platform |   21 // Encapsulates a surface that can be rendered to with GL, hiding platform | 
|   23 // specific management. |   22 // specific management. | 
|   24 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { |   23 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { | 
|   25  public: |   24  public: | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   63  |   62  | 
|   64   bool HasExtension(const char* name); |   63   bool HasExtension(const char* name); | 
|   65  |   64  | 
|   66   // Returns the internal frame buffer object name if the surface is backed by |   65   // Returns the internal frame buffer object name if the surface is backed by | 
|   67   // FBO. Otherwise returns 0. |   66   // FBO. Otherwise returns 0. | 
|   68   virtual unsigned int GetBackingFrameBufferObject(); |   67   virtual unsigned int GetBackingFrameBufferObject(); | 
|   69  |   68  | 
|   70   // Copy part of the backbuffer to the frontbuffer. |   69   // Copy part of the backbuffer to the frontbuffer. | 
|   71   virtual bool PostSubBuffer(int x, int y, int width, int height); |   70   virtual bool PostSubBuffer(int x, int y, int width, int height); | 
|   72  |   71  | 
|   73   // Initialize GL bindings. |  | 
|   74   static bool InitializeOneOff(); |   72   static bool InitializeOneOff(); | 
|   75  |   73  | 
|   76   // Unit tests should call these instead of InitializeOneOff() to set up |  | 
|   77   // GL bindings appropriate for tests. |  | 
|   78   static void InitializeOneOffForTests(); |  | 
|   79   static void InitializeOneOffWithMockBindingsForTests(); |  | 
|   80   static void InitializeDynamicMockBindingsForTests(GLContext* context); |  | 
|   81  |  | 
|   82   // Called after a context is made current with this surface. Returns false |   74   // Called after a context is made current with this surface. Returns false | 
|   83   // on error. |   75   // on error. | 
|   84   virtual bool OnMakeCurrent(GLContext* context); |   76   virtual bool OnMakeCurrent(GLContext* context); | 
|   85  |   77  | 
|   86   // Used for explicit buffer management. |   78   // Used for explicit buffer management. | 
|   87   virtual bool SetBackbufferAllocation(bool allocated); |   79   virtual bool SetBackbufferAllocation(bool allocated); | 
|   88   virtual void SetFrontbufferAllocation(bool allocated); |   80   virtual void SetFrontbufferAllocation(bool allocated); | 
|   89  |   81  | 
|   90   // Get a handle used to share the surface with another process. Returns null |   82   // Get a handle used to share the surface with another process. Returns null | 
|   91   // if this is not possible. |   83   // if this is not possible. | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  110       gfx::AcceleratedWidget window); |  102       gfx::AcceleratedWidget window); | 
|  111  |  103  | 
|  112   // Create a GL surface used for offscreen rendering. |  104   // Create a GL surface used for offscreen rendering. | 
|  113   static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |  105   static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 
|  114       const gfx::Size& size); |  106       const gfx::Size& size); | 
|  115  |  107  | 
|  116   static GLSurface* GetCurrent(); |  108   static GLSurface* GetCurrent(); | 
|  117  |  109  | 
|  118  protected: |  110  protected: | 
|  119   virtual ~GLSurface(); |  111   virtual ~GLSurface(); | 
|  120   static bool InitializeOneOffImplementation(GLImplementation impl, |  | 
|  121                                              bool fallback_to_osmesa, |  | 
|  122                                              bool gpu_service_logging, |  | 
|  123                                              bool disable_gl_drawing); |  | 
|  124   static bool InitializeOneOffInternal(); |  112   static bool InitializeOneOffInternal(); | 
|  125   static void SetCurrent(GLSurface* surface); |  113   static void SetCurrent(GLSurface* surface); | 
|  126  |  114  | 
|  127   static bool ExtensionsContain(const char* extensions, const char* name); |  115   static bool ExtensionsContain(const char* extensions, const char* name); | 
|  128  |  116  | 
|  129  private: |  117  private: | 
|  130   friend class base::RefCounted<GLSurface>; |  118   friend class base::RefCounted<GLSurface>; | 
|  131   friend class GLContext; |  119   friend class GLContext; | 
|  132  |  120  | 
|  133   DISALLOW_COPY_AND_ASSIGN(GLSurface); |  121   DISALLOW_COPY_AND_ASSIGN(GLSurface); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  167  |  155  | 
|  168  private: |  156  private: | 
|  169   scoped_refptr<GLSurface> surface_; |  157   scoped_refptr<GLSurface> surface_; | 
|  170  |  158  | 
|  171   DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |  159   DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 
|  172 }; |  160 }; | 
|  173  |  161  | 
|  174 }  // namespace gfx |  162 }  // namespace gfx | 
|  175  |  163  | 
|  176 #endif  // UI_GL_GL_SURFACE_H_ |  164 #endif  // UI_GL_GL_SURFACE_H_ | 
| OLD | NEW |