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

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: comment 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // if this is not possible. 144 // if this is not possible.
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 default format of the surface.
155 virtual GLSurface::Format GetDefaultFormat() const;
no sievers 2016/02/18 20:19:45 This is not needed anymore, right? Because how we
Jinsuk Kim 2016/02/19 01:04:40 Removed.
156
154 // Get the GL pixel format of the surface, if available. 157 // Get the GL pixel format of the surface, if available.
155 virtual unsigned GetFormat(); 158 virtual GLSurface::Format GetFormat();
156 159
157 // Get access to a helper providing time of recent refresh and period 160 // Get access to a helper providing time of recent refresh and period
158 // of screen refresh. If unavailable, returns NULL. 161 // of screen refresh. If unavailable, returns NULL.
159 virtual VSyncProvider* GetVSyncProvider(); 162 virtual VSyncProvider* GetVSyncProvider();
160 163
161 // Schedule an overlay plane to be shown at swap time, or on the next 164 // Schedule an overlay plane to be shown at swap time, or on the next
162 // CommitOverlayPlanes call. 165 // CommitOverlayPlanes call.
163 // |z_order| specifies the stacking order of the plane relative to the 166 // |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 167 // 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. 168 // 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 207 // Create a GL surface that renders directly into a window with surfaceless
205 // semantics - there is no default framebuffer and the primary surface must 208 // semantics - there is no default framebuffer and the primary surface must
206 // be presented as an overlay. If surfaceless mode is not supported or 209 // be presented as an overlay. If surfaceless mode is not supported or
207 // enabled it will return a null pointer. 210 // enabled it will return a null pointer.
208 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( 211 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
209 gfx::AcceleratedWidget window); 212 gfx::AcceleratedWidget window);
210 #endif // defined(USE_OZONE) 213 #endif // defined(USE_OZONE)
211 214
212 // Create a GL surface used for offscreen rendering. 215 // Create a GL surface used for offscreen rendering.
213 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( 216 static scoped_refptr<GLSurface> CreateOffscreenGLSurface(
214 const gfx::Size& size) { 217 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 218
221 static GLSurface* GetCurrent(); 219 static GLSurface* GetCurrent();
222 220
223 // Called when the swap interval for the associated context changes. 221 // Called when the swap interval for the associated context changes.
224 virtual void OnSetSwapInterval(int interval); 222 virtual void OnSetSwapInterval(int interval);
225 223
226 protected: 224 protected:
227 virtual ~GLSurface(); 225 virtual ~GLSurface();
228 static bool InitializeOneOffImplementation(GLImplementation impl, 226 static bool InitializeOneOffImplementation(GLImplementation impl,
229 bool fallback_to_osmesa, 227 bool fallback_to_osmesa,
230 bool gpu_service_logging, 228 bool gpu_service_logging,
231 bool disable_gl_drawing); 229 bool disable_gl_drawing);
232 static bool InitializeOneOffInternal(); 230 static bool InitializeOneOffInternal();
233 static void SetCurrent(GLSurface* surface); 231 static void SetCurrent(GLSurface* surface);
234 232
235 static bool ExtensionsContain(const char* extensions, const char* name); 233 static bool ExtensionsContain(const char* extensions, const char* name);
236 234
235 GLSurface::Format format_;
236
237 private: 237 private:
238 friend class base::RefCounted<GLSurface>; 238 friend class base::RefCounted<GLSurface>;
239 friend class GLContext; 239 friend class GLContext;
240 friend class GLSurfaceTestSupport; 240 friend class GLSurfaceTestSupport;
241 241
242 DISALLOW_COPY_AND_ASSIGN(GLSurface); 242 DISALLOW_COPY_AND_ASSIGN(GLSurface);
243 }; 243 };
244 244
245 // Implementation of GLSurface that forwards all calls through to another 245 // Implementation of GLSurface that forwards all calls through to another
246 // GLSurface. 246 // GLSurface.
(...skipping 25 matching lines...) Expand all
272 bool SupportsAsyncSwap() override; 272 bool SupportsAsyncSwap() override;
273 gfx::Size GetSize() override; 273 gfx::Size GetSize() override;
274 void* GetHandle() override; 274 void* GetHandle() override;
275 unsigned int GetBackingFrameBufferObject() override; 275 unsigned int GetBackingFrameBufferObject() override;
276 bool OnMakeCurrent(GLContext* context) override; 276 bool OnMakeCurrent(GLContext* context) override;
277 bool SetBackbufferAllocation(bool allocated) override; 277 bool SetBackbufferAllocation(bool allocated) override;
278 void SetFrontbufferAllocation(bool allocated) override; 278 void SetFrontbufferAllocation(bool allocated) override;
279 void* GetShareHandle() override; 279 void* GetShareHandle() override;
280 void* GetDisplay() override; 280 void* GetDisplay() override;
281 void* GetConfig() override; 281 void* GetConfig() override;
282 unsigned GetFormat() override; 282 GLSurface::Format GetFormat() override;
283 VSyncProvider* GetVSyncProvider() override; 283 VSyncProvider* GetVSyncProvider() override;
284 bool ScheduleOverlayPlane(int z_order, 284 bool ScheduleOverlayPlane(int z_order,
285 OverlayTransform transform, 285 OverlayTransform transform,
286 gl::GLImage* image, 286 gl::GLImage* image,
287 const Rect& bounds_rect, 287 const Rect& bounds_rect,
288 const RectF& crop_rect) override; 288 const RectF& crop_rect) override;
289 bool IsSurfaceless() const override; 289 bool IsSurfaceless() const override;
290 bool FlipsVertically() const override; 290 bool FlipsVertically() const override;
291 bool BuffersFlipped() const override; 291 bool BuffersFlipped() const override;
292 292
293 GLSurface* surface() const { return surface_.get(); } 293 GLSurface* surface() const { return surface_.get(); }
294 294
295 protected: 295 protected:
296 ~GLSurfaceAdapter() override; 296 ~GLSurfaceAdapter() override;
297 297
298 private: 298 private:
299 scoped_refptr<GLSurface> surface_; 299 scoped_refptr<GLSurface> surface_;
300 300
301 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); 301 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter);
302 }; 302 };
303 303
304 } // namespace gfx 304 } // namespace gfx
305 305
306 #endif // UI_GL_GL_SURFACE_H_ 306 #endif // UI_GL_GL_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698