Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: ui/gl/gl_surface.h

Issue 1652873002: Android: Use virtualized context only for those with compatible config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 20 matching lines...) Expand all
31 class VSyncProvider; 31 class VSyncProvider;
32 32
33 // Encapsulates a surface that can be rendered to with GL, hiding platform 33 // Encapsulates a surface that can be rendered to with GL, hiding platform
34 // specific management. 34 // specific management.
35 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { 35 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
36 public: 36 public:
37 GLSurface(); 37 GLSurface();
38 38
39 // Minimum bit depth of surface. 39 // Minimum bit depth of surface.
40 enum Format { 40 enum Format {
41 SURFACE_ARGB8888 = 1, // 32 bits 41 SURFACE_ARGB8888,
42 SURFACE_RGB565 = 2, // 16 bits 42 SURFACE_RGB565,
43 SURFACE_DEFAULT = SURFACE_ARGB8888 43 SURFACE_DEFAULT = SURFACE_ARGB8888
44 }; 44 };
45 45
46 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the 46 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the
47 // EGL surface associated to be recreated without destroying the associated 47 // EGL surface associated to be recreated without destroying the associated
48 // context. The implementation of this function for other GLSurface derived 48 // context. The implementation of this function for other GLSurface derived
49 // classes is in a pending changelist. 49 // classes is in a pending changelist.
50 virtual bool Initialize(); 50 virtual bool Initialize();
51 virtual bool Initialize(GLSurface::Format format); 51 virtual bool Initialize(GLSurface::Format format);
52 52
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 virtual void* GetShareHandle(); 145 virtual void* GetShareHandle();
146 146
147 // Get the platform specific display on which this surface resides, if 147 // Get the platform specific display on which this surface resides, if
148 // available. 148 // available.
149 virtual void* GetDisplay(); 149 virtual void* GetDisplay();
150 150
151 // Get the platfrom specific configuration for this surface, if available. 151 // Get the platfrom specific configuration for this surface, if available.
152 virtual void* GetConfig(); 152 virtual void* GetConfig();
153 153
154 // Get the GL pixel format of the surface, if available. 154 // Get the GL pixel format of the surface, if available.
155 virtual unsigned GetFormat(); 155 virtual GLSurface::Format GetFormat();
156 156
157 // Get access to a helper providing time of recent refresh and period 157 // Get access to a helper providing time of recent refresh and period
158 // of screen refresh. If unavailable, returns NULL. 158 // of screen refresh. If unavailable, returns NULL.
159 virtual VSyncProvider* GetVSyncProvider(); 159 virtual VSyncProvider* GetVSyncProvider();
160 160
161 // Schedule an overlay plane to be shown at swap time, or on the next 161 // Schedule an overlay plane to be shown at swap time, or on the next
162 // CommitOverlayPlanes call. 162 // CommitOverlayPlanes call.
163 // |z_order| specifies the stacking order of the plane relative to the 163 // |z_order| specifies the stacking order of the plane relative to the
164 // main framebuffer located at index 0. For the case where there is no 164 // main framebuffer located at index 0. For the case where there is no
165 // main framebuffer, overlays may be scheduled at 0, taking its place. 165 // main framebuffer, overlays may be scheduled at 0, taking its place.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Create a GL surface that renders directly into a window with surfaceless 204 // Create a GL surface that renders directly into a window with surfaceless
205 // semantics - there is no default framebuffer and the primary surface must 205 // semantics - there is no default framebuffer and the primary surface must
206 // be presented as an overlay. If surfaceless mode is not supported or 206 // be presented as an overlay. If surfaceless mode is not supported or
207 // enabled it will return a null pointer. 207 // enabled it will return a null pointer.
208 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( 208 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
209 gfx::AcceleratedWidget window); 209 gfx::AcceleratedWidget window);
210 #endif // defined(USE_OZONE) 210 #endif // defined(USE_OZONE)
211 211
212 // Create a GL surface used for offscreen rendering. 212 // Create a GL surface used for offscreen rendering.
213 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( 213 static scoped_refptr<GLSurface> CreateOffscreenGLSurface(
214 const gfx::Size& size) { 214 const gfx::Size& size);
215 return CreateOffscreenGLSurface(size, SURFACE_DEFAULT);
216 }
217
218 static scoped_refptr<GLSurface> CreateOffscreenGLSurface(
219 const gfx::Size& size, GLSurface::Format format);
220 215
221 static GLSurface* GetCurrent(); 216 static GLSurface* GetCurrent();
222 217
223 // Called when the swap interval for the associated context changes. 218 // Called when the swap interval for the associated context changes.
224 virtual void OnSetSwapInterval(int interval); 219 virtual void OnSetSwapInterval(int interval);
225 220
226 protected: 221 protected:
227 virtual ~GLSurface(); 222 virtual ~GLSurface();
228 static bool InitializeOneOffImplementation(GLImplementation impl, 223 static bool InitializeOneOffImplementation(GLImplementation impl,
229 bool fallback_to_osmesa, 224 bool fallback_to_osmesa,
230 bool gpu_service_logging, 225 bool gpu_service_logging,
231 bool disable_gl_drawing); 226 bool disable_gl_drawing);
232 static bool InitializeOneOffInternal(); 227 static bool InitializeOneOffInternal();
233 static void SetCurrent(GLSurface* surface); 228 static void SetCurrent(GLSurface* surface);
234 229
235 static bool ExtensionsContain(const char* extensions, const char* name); 230 static bool ExtensionsContain(const char* extensions, const char* name);
236 231
232 GLSurface::Format format_;
no sievers 2016/02/19 20:25:18 Can you initialize this? Actually, do we really ne
Jinsuk Kim 2016/02/20 13:56:57 Removed.
233
237 private: 234 private:
238 friend class base::RefCounted<GLSurface>; 235 friend class base::RefCounted<GLSurface>;
239 friend class GLContext; 236 friend class GLContext;
240 friend class GLSurfaceTestSupport; 237 friend class GLSurfaceTestSupport;
241 238
242 DISALLOW_COPY_AND_ASSIGN(GLSurface); 239 DISALLOW_COPY_AND_ASSIGN(GLSurface);
243 }; 240 };
244 241
245 // Implementation of GLSurface that forwards all calls through to another 242 // Implementation of GLSurface that forwards all calls through to another
246 // GLSurface. 243 // GLSurface.
(...skipping 25 matching lines...) Expand all
272 bool SupportsAsyncSwap() override; 269 bool SupportsAsyncSwap() override;
273 gfx::Size GetSize() override; 270 gfx::Size GetSize() override;
274 void* GetHandle() override; 271 void* GetHandle() override;
275 unsigned int GetBackingFrameBufferObject() override; 272 unsigned int GetBackingFrameBufferObject() override;
276 bool OnMakeCurrent(GLContext* context) override; 273 bool OnMakeCurrent(GLContext* context) override;
277 bool SetBackbufferAllocation(bool allocated) override; 274 bool SetBackbufferAllocation(bool allocated) override;
278 void SetFrontbufferAllocation(bool allocated) override; 275 void SetFrontbufferAllocation(bool allocated) override;
279 void* GetShareHandle() override; 276 void* GetShareHandle() override;
280 void* GetDisplay() override; 277 void* GetDisplay() override;
281 void* GetConfig() override; 278 void* GetConfig() override;
282 unsigned GetFormat() override; 279 GLSurface::Format GetFormat() override;
283 VSyncProvider* GetVSyncProvider() override; 280 VSyncProvider* GetVSyncProvider() override;
284 bool ScheduleOverlayPlane(int z_order, 281 bool ScheduleOverlayPlane(int z_order,
285 OverlayTransform transform, 282 OverlayTransform transform,
286 gl::GLImage* image, 283 gl::GLImage* image,
287 const Rect& bounds_rect, 284 const Rect& bounds_rect,
288 const RectF& crop_rect) override; 285 const RectF& crop_rect) override;
289 bool IsSurfaceless() const override; 286 bool IsSurfaceless() const override;
290 bool FlipsVertically() const override; 287 bool FlipsVertically() const override;
291 bool BuffersFlipped() const override; 288 bool BuffersFlipped() const override;
292 289
293 GLSurface* surface() const { return surface_.get(); } 290 GLSurface* surface() const { return surface_.get(); }
294 291
295 protected: 292 protected:
296 ~GLSurfaceAdapter() override; 293 ~GLSurfaceAdapter() override;
297 294
298 private: 295 private:
299 scoped_refptr<GLSurface> surface_; 296 scoped_refptr<GLSurface> surface_;
300 297
301 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); 298 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter);
302 }; 299 };
303 300
304 } // namespace gfx 301 } // namespace gfx
305 302
306 #endif // UI_GL_GL_SURFACE_H_ 303 #endif // UI_GL_GL_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698