| 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/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 15 #include "ui/gfx/geometry/rect_f.h" | 15 #include "ui/gfx/geometry/rect_f.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/geometry/vector2d.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 18 #include "ui/gfx/overlay_transform.h" | 19 #include "ui/gfx/overlay_transform.h" |
| 19 #include "ui/gfx/swap_result.h" | 20 #include "ui/gfx/swap_result.h" |
| 20 #include "ui/gl/gl_export.h" | 21 #include "ui/gl/gl_export.h" |
| 21 #include "ui/gl/gl_image.h" | 22 #include "ui/gl/gl_image.h" |
| 22 #include "ui/gl/gl_implementation.h" | 23 #include "ui/gl/gl_implementation.h" |
| 23 #include "ui/gl/gl_surface_format.h" | 24 #include "ui/gl/gl_surface_format.h" |
| 24 | 25 |
| 25 namespace gfx { | 26 namespace gfx { |
| 26 class VSyncProvider; | 27 class VSyncProvider; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 204 |
| 204 // Returns true if SwapBuffers or PostSubBuffers causes a flip, such that | 205 // Returns true if SwapBuffers or PostSubBuffers causes a flip, such that |
| 205 // the next buffer may be 2 frames old. | 206 // the next buffer may be 2 frames old. |
| 206 virtual bool BuffersFlipped() const; | 207 virtual bool BuffersFlipped() const; |
| 207 | 208 |
| 208 virtual bool SupportsSetDrawRectangle() const; | 209 virtual bool SupportsSetDrawRectangle() const; |
| 209 | 210 |
| 210 // Set the rectangle that will be drawn into on the surface. | 211 // Set the rectangle that will be drawn into on the surface. |
| 211 virtual bool SetDrawRectangle(const gfx::Rect& rect); | 212 virtual bool SetDrawRectangle(const gfx::Rect& rect); |
| 212 | 213 |
| 214 // This is the amount by which the scissor and viewport rectangles should be |
| 215 // offset. |
| 216 virtual gfx::Vector2d GetDrawOffset() const; |
| 217 |
| 213 static GLSurface* GetCurrent(); | 218 static GLSurface* GetCurrent(); |
| 214 | 219 |
| 215 // Called when the swap interval for the associated context changes. | 220 // Called when the swap interval for the associated context changes. |
| 216 virtual void OnSetSwapInterval(int interval); | 221 virtual void OnSetSwapInterval(int interval); |
| 217 | 222 |
| 218 protected: | 223 protected: |
| 219 virtual ~GLSurface(); | 224 virtual ~GLSurface(); |
| 220 | 225 |
| 221 static void SetCurrent(GLSurface* surface); | 226 static void SetCurrent(GLSurface* surface); |
| 222 | 227 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 bool ScheduleOverlayPlane(int z_order, | 280 bool ScheduleOverlayPlane(int z_order, |
| 276 gfx::OverlayTransform transform, | 281 gfx::OverlayTransform transform, |
| 277 GLImage* image, | 282 GLImage* image, |
| 278 const gfx::Rect& bounds_rect, | 283 const gfx::Rect& bounds_rect, |
| 279 const gfx::RectF& crop_rect) override; | 284 const gfx::RectF& crop_rect) override; |
| 280 bool IsSurfaceless() const override; | 285 bool IsSurfaceless() const override; |
| 281 bool FlipsVertically() const override; | 286 bool FlipsVertically() const override; |
| 282 bool BuffersFlipped() const override; | 287 bool BuffersFlipped() const override; |
| 283 bool SupportsSetDrawRectangle() const override; | 288 bool SupportsSetDrawRectangle() const override; |
| 284 bool SetDrawRectangle(const gfx::Rect& rect) override; | 289 bool SetDrawRectangle(const gfx::Rect& rect) override; |
| 290 gfx::Vector2d GetDrawOffset() const override; |
| 285 void OnSetSwapInterval(int interval) override; | 291 void OnSetSwapInterval(int interval) override; |
| 286 | 292 |
| 287 GLSurface* surface() const { return surface_.get(); } | 293 GLSurface* surface() const { return surface_.get(); } |
| 288 | 294 |
| 289 protected: | 295 protected: |
| 290 ~GLSurfaceAdapter() override; | 296 ~GLSurfaceAdapter() override; |
| 291 | 297 |
| 292 private: | 298 private: |
| 293 scoped_refptr<GLSurface> surface_; | 299 scoped_refptr<GLSurface> surface_; |
| 294 | 300 |
| 295 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 301 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
| 296 }; | 302 }; |
| 297 | 303 |
| 298 // Wraps GLSurface in scoped_refptr and tries to initializes it. Returns a | 304 // Wraps GLSurface in scoped_refptr and tries to initializes it. Returns a |
| 299 // scoped_refptr containing the initialized GLSurface or nullptr if | 305 // scoped_refptr containing the initialized GLSurface or nullptr if |
| 300 // initialization fails. | 306 // initialization fails. |
| 301 GL_EXPORT scoped_refptr<GLSurface> InitializeGLSurface( | 307 GL_EXPORT scoped_refptr<GLSurface> InitializeGLSurface( |
| 302 scoped_refptr<GLSurface> surface); | 308 scoped_refptr<GLSurface> surface); |
| 303 | 309 |
| 304 GL_EXPORT scoped_refptr<GLSurface> InitializeGLSurfaceWithFormat( | 310 GL_EXPORT scoped_refptr<GLSurface> InitializeGLSurfaceWithFormat( |
| 305 scoped_refptr<GLSurface> surface, GLSurfaceFormat format); | 311 scoped_refptr<GLSurface> surface, GLSurfaceFormat format); |
| 306 | 312 |
| 307 } // namespace gl | 313 } // namespace gl |
| 308 | 314 |
| 309 #endif // UI_GL_GL_SURFACE_H_ | 315 #endif // UI_GL_GL_SURFACE_H_ |
| OLD | NEW |