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_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H |
6 #define CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H | 6 #define CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Disassociate the GL context with the NSView and unref the IOSurface. Do | 48 // Disassociate the GL context with the NSView and unref the IOSurface. Do |
49 // this to switch to software drawing mode. | 49 // this to switch to software drawing mode. |
50 void ClearDrawable(); | 50 void ClearDrawable(); |
51 | 51 |
52 bool HasIOSurface() { return !!io_surface_.get(); } | 52 bool HasIOSurface() { return !!io_surface_.get(); } |
53 | 53 |
54 const gfx::Size& pixel_io_surface_size() const { | 54 const gfx::Size& pixel_io_surface_size() const { |
55 return pixel_io_surface_size_; | 55 return pixel_io_surface_size_; |
56 } | 56 } |
| 57 // In cocoa view units / DIPs. |
| 58 const gfx::Size& io_surface_size() const { return io_surface_size_; } |
57 | 59 |
58 bool is_vsync_disabled() const { return is_vsync_disabled_; } | 60 bool is_vsync_disabled() const { return is_vsync_disabled_; } |
59 | 61 |
60 private: | 62 private: |
61 // Vertex structure for use in glDraw calls. | 63 // Vertex structure for use in glDraw calls. |
62 struct SurfaceVertex { | 64 struct SurfaceVertex { |
63 SurfaceVertex() : x_(0.0f), y_(0.0f), tx_(0.0f), ty_(0.0f) { } | 65 SurfaceVertex() : x_(0.0f), y_(0.0f), tx_(0.0f), ty_(0.0f) { } |
64 // Currently the texture coords are always the same as vertex coords. | 66 // Currently the texture coords are always the same as vertex coords. |
65 void set(float x, float y, float tx, float ty) { | 67 void set(float x, float y, float tx, float ty) { |
66 x_ = x; | 68 x_ = x; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 123 |
122 // GL context | 124 // GL context |
123 scoped_nsobject<NSOpenGLContext> glContext_; | 125 scoped_nsobject<NSOpenGLContext> glContext_; |
124 CGLContextObj cglContext_; // weak, backed by |glContext_|. | 126 CGLContextObj cglContext_; // weak, backed by |glContext_|. |
125 | 127 |
126 // IOSurface data. | 128 // IOSurface data. |
127 uint64 io_surface_handle_; | 129 uint64 io_surface_handle_; |
128 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; | 130 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; |
129 | 131 |
130 // The width and height of the io surface. | 132 // The width and height of the io surface. |
131 gfx::Size pixel_io_surface_size_; | 133 gfx::Size pixel_io_surface_size_; // In pixels. |
| 134 gfx::Size io_surface_size_; // In view units. |
132 | 135 |
133 // The "live" OpenGL texture referring to this IOSurfaceRef. Note | 136 // The "live" OpenGL texture referring to this IOSurfaceRef. Note |
134 // that per the CGLTexImageIOSurface2D API we do not need to | 137 // that per the CGLTexImageIOSurface2D API we do not need to |
135 // explicitly update this texture's contents once created. All we | 138 // explicitly update this texture's contents once created. All we |
136 // need to do is ensure it is re-bound before attempting to draw | 139 // need to do is ensure it is re-bound before attempting to draw |
137 // with it. | 140 // with it. |
138 GLuint texture_; | 141 GLuint texture_; |
139 | 142 |
140 // Shader parameters. | 143 // Shader parameters. |
141 GLuint shader_program_blit_rgb_; | 144 GLuint shader_program_blit_rgb_; |
142 GLint blit_rgb_sampler_location_; | 145 GLint blit_rgb_sampler_location_; |
143 GLuint shader_program_white_; | 146 GLuint shader_program_white_; |
144 | 147 |
145 SurfaceQuad quad_; | 148 SurfaceQuad quad_; |
146 | 149 |
147 bool is_vsync_disabled_; | 150 bool is_vsync_disabled_; |
148 }; | 151 }; |
149 | 152 |
150 #endif // CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H | 153 #endif // CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H |
OLD | NEW |