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

Side by Side Diff: tools/gpu/gl/GLContext.h

Issue 1849463002: rename sk_gpu_test::GLContext to sk_gpu_test::GLTestContext (Closed) Base URL: https://chromium.googlesource.com/skia.git@move
Patch Set: readd gpu.gypi Created 4 years, 8 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
« no previous file with comments | « tools/gpu/GrContextFactory.cpp ('k') | tools/gpu/gl/GLContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2013 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #ifndef GLContext_DEFINED
9 #define GLContext_DEFINED
10
11 #include "gl/GrGLInterface.h"
12 #include "../private/SkGpuFenceSync.h"
13
14
15 namespace sk_gpu_test {
16 /**
17 * Create an offscreen Oppengl context. Provides a GrGLInterface struct of funct ion pointers for
18 * the context. This class is intended for Skia's internal testing needs and not for general use.
19 */
20 class GLContext : public SkNoncopyable {
21 public:
22 virtual ~GLContext();
23
24 bool isValid() const { return NULL != gl(); }
25
26 const GrGLInterface *gl() const { return fGL.get(); }
27
28 bool fenceSyncSupport() const { return fFenceSync != nullptr; }
29
30 bool getMaxGpuFrameLag(int *maxFrameLag) const {
31 if (!fFenceSync) {
32 return false;
33 }
34 *maxFrameLag = kMaxFrameLag;
35 return true;
36 }
37
38 void makeCurrent() const;
39
40 /** Used for testing EGLImage integration. Take a GL_TEXTURE_2D and wraps it in an EGL Image */
41 virtual GrEGLImage texture2DToEGLImage(GrGLuint /*texID*/) const { return 0; }
42
43 virtual void destroyEGLImage(GrEGLImage) const { }
44
45 /** Used for testing GL_TEXTURE_RECTANGLE integration. */
46 GrGLint createTextureRectangle(int width, int height, GrGLenum internalForma t,
47 GrGLenum externalFormat, GrGLenum externalTyp e,
48 GrGLvoid *data);
49
50 /**
51 * Used for testing EGLImage integration. Takes a EGLImage and wraps it in a
52 * GL_TEXTURE_EXTERNAL_OES.
53 */
54 virtual GrGLuint eglImageToExternalTexture(GrEGLImage) const { return 0; }
55
56 void swapBuffers();
57
58 /**
59 * The only purpose of this function it to provide a means of scheduling
60 * work on the GPU (since all of the subclasses create primary buffers for
61 * testing that are small and not meant to be rendered to the screen).
62 *
63 * If the platform supports fence sync (OpenGL 3.2+ or EGL_KHR_fence_sync),
64 * this will not swap any buffers, but rather emulate triple buffer
65 * synchronization using fences.
66 *
67 * Otherwise it will call the platform SwapBuffers method. This may or may
68 * not perform some sort of synchronization, depending on whether the
69 * drawing surface provided by the platform is double buffered.
70 */
71 void waitOnSyncOrSwap();
72
73 /**
74 * This notifies the context that we are deliberately testing abandoning
75 * the context. It is useful for debugging contexts that would otherwise
76 * test that GPU resources are properly deleted. It also allows a debugging
77 * context to test that further GL calls are not made by Skia GPU code.
78 */
79 void testAbandon();
80
81 /**
82 * Creates a new GL context of the same type and makes the returned context current
83 * (if not null).
84 */
85 virtual GLContext *createNew() const { return nullptr; }
86
87 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu nctionality.
88
89 /*
90 * returns the fencesync object owned by this GLContext
91 */
92 SkGpuFenceSync *fenceSync() { return fFenceSync.get(); }
93
94 protected:
95 GLContext();
96
97 /*
98 * Methods that sublcasses must call from their constructors and destructors .
99 */
100 void init(const GrGLInterface *, SkGpuFenceSync * = NULL);
101
102 void teardown();
103
104 /*
105 * Operations that have a platform-dependent implementation.
106 */
107 virtual void onPlatformMakeCurrent() const = 0;
108
109 virtual void onPlatformSwapBuffers() const = 0;
110
111 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0;
112
113 private:
114 enum {
115 kMaxFrameLag = 3
116 };
117
118 SkAutoTDelete <SkGpuFenceSync> fFenceSync;
119 SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1];
120 int fCurrentFenceIdx;
121
122 /** Subclass provides the gl interface object if construction was
123 * successful. */
124 SkAutoTUnref<const GrGLInterface> fGL;
125
126 friend class GLFenceSync; // For onPlatformGetProcAddress.
127 };
128
129
130 /** Creates platform-dependent GL context object. The shareContext parameter is in an optional
131 * context with which to share display lists. This should be a pointer to an GLC ontext created
132 * with SkCreatePlatformGLContext. NULL indicates that no sharing is to take pl ace. Returns a valid
133 * gl context object or NULL if such can not be created.
134 * Note: If Skia embedder needs a custom GL context that sets up the GL interfac e, this function
135 * should be implemented by the embedder. Otherwise, the default implementation for the platform
136 * should be compiled in the library.
137 */
138 GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareCo ntext = nullptr);
139
140 } // namespace sk_gpu_test
141 #endif
OLDNEW
« no previous file with comments | « tools/gpu/GrContextFactory.cpp ('k') | tools/gpu/gl/GLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698