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

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

Issue 1964243003: Add base class for GLTestContext and add new subclass VkTestContext. (Closed) Base URL: https://chromium.googlesource.com/skia.git@ContextInfo
Patch Set: move #include "GrVkBackendContext.h" inside #ifdef SK_VULKAN Created 4 years, 7 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/TestContext.cpp ('k') | tools/gpu/gl/GLTestContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #ifndef GLTestContext_DEFINED 8 #ifndef GLTestContext_DEFINED
9 #define GLTestContext_DEFINED 9 #define GLTestContext_DEFINED
10 10
11 #include "TestContext.h"
11 #include "gl/GrGLInterface.h" 12 #include "gl/GrGLInterface.h"
12 #include "../private/SkGpuFenceSync.h"
13
14 13
15 namespace sk_gpu_test { 14 namespace sk_gpu_test {
16 /** 15 /**
17 * Create an offscreen Oppengl context. Provides a GrGLInterface struct of funct ion pointers for 16 * An offscreen OpenGL context. Provides a GrGLInterface struct of function poin ters for the context
18 * the context. This class is intended for Skia's internal testing needs and not for general use. 17 * This class is intended for Skia's internal testing needs and not for general use.
19 */ 18 */
20 class GLTestContext : public SkNoncopyable { 19 class GLTestContext : public TestContext {
21 public: 20 public:
22 virtual ~GLTestContext(); 21 virtual ~GLTestContext();
23 22
24 bool isValid() const { return NULL != gl(); } 23 virtual GrBackend backend() override { return kOpenGL_GrBackend; }
24 virtual GrBackendContext backendContext() override {
25 return reinterpret_cast<GrBackendContext>(fGL.get());
26 }
27
28 bool isValid() const override { return SkToBool(this->gl()); }
25 29
26 const GrGLInterface *gl() const { return fGL.get(); } 30 const GrGLInterface *gl() const { return fGL.get(); }
27 31
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 */ 32 /** 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; } 33 virtual GrEGLImage texture2DToEGLImage(GrGLuint /*texID*/) const { return 0; }
42 34
43 virtual void destroyEGLImage(GrEGLImage) const { } 35 virtual void destroyEGLImage(GrEGLImage) const { }
44 36
45 /** Used for testing GL_TEXTURE_RECTANGLE integration. */ 37 /** Used for testing GL_TEXTURE_RECTANGLE integration. */
46 GrGLint createTextureRectangle(int width, int height, GrGLenum internalForma t, 38 GrGLint createTextureRectangle(int width, int height, GrGLenum internalForma t,
47 GrGLenum externalFormat, GrGLenum externalTyp e, 39 GrGLenum externalFormat, GrGLenum externalTyp e,
48 GrGLvoid *data); 40 GrGLvoid *data);
49 41
50 /** 42 /**
51 * Used for testing EGLImage integration. Takes a EGLImage and wraps it in a 43 * Used for testing EGLImage integration. Takes a EGLImage and wraps it in a
52 * GL_TEXTURE_EXTERNAL_OES. 44 * GL_TEXTURE_EXTERNAL_OES.
53 */ 45 */
54 virtual GrGLuint eglImageToExternalTexture(GrEGLImage) const { return 0; } 46 virtual GrGLuint eglImageToExternalTexture(GrEGLImage) const { return 0; }
55 47
56 void swapBuffers(); 48 void testAbandon() override;
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 49
81 /** 50 /**
82 * Creates a new GL context of the same type and makes the returned context current 51 * Creates a new GL context of the same type and makes the returned context current
83 * (if not null). 52 * (if not null).
84 */ 53 */
85 virtual GLTestContext *createNew() const { return nullptr; } 54 virtual GLTestContext *createNew() const { return nullptr; }
86 55
87 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu nctionality.
88
89 /*
90 * returns the fencesync object owned by this GLTestContext
91 */
92 SkGpuFenceSync *fenceSync() { return fFenceSync.get(); }
93
94 protected: 56 protected:
95 GLTestContext(); 57 GLTestContext();
96 58
97 /* 59 /*
98 * Methods that sublcasses must call from their constructors and destructors . 60 * Methods that sublcasses must call from their constructors and destructors .
99 */ 61 */
100 void init(const GrGLInterface *, SkGpuFenceSync * = NULL); 62 void init(const GrGLInterface *, SkGpuFenceSync * = NULL);
101 63
102 void teardown(); 64 void teardown() override;
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 65
111 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0; 66 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0;
112 67
113 private: 68 private:
114 enum { 69 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu nctionality.
115 kMaxFrameLag = 3
116 };
117
118 SkAutoTDelete <SkGpuFenceSync> fFenceSync;
119 SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1];
120 int fCurrentFenceIdx;
121 70
122 /** Subclass provides the gl interface object if construction was 71 /** Subclass provides the gl interface object if construction was
123 * successful. */ 72 * successful. */
124 SkAutoTUnref<const GrGLInterface> fGL; 73 SkAutoTUnref<const GrGLInterface> fGL;
125 74
126 friend class GLFenceSync; // For onPlatformGetProcAddress. 75 friend class GLFenceSync; // For onPlatformGetProcAddress.
76
77 typedef TestContext INHERITED;
127 }; 78 };
128 79
129 80 /**
130 /** Creates platform-dependent GL context object. The shareContext parameter is in an optional 81 * 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 GLT estContext created 82 * context with which to share display lists. This should be a pointer to an GLT estContext created
132 * with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to tak e place. Returns a valid 83 * with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to tak e place. Returns a
133 * gl context object or NULL if such can not be created. 84 * valid 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 */ 85 */
138 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, GLTestCont ext *shareContext = nullptr); 86 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI,
87 GLTestContext *shareContext = nullptr );
139 88
140 } // namespace sk_gpu_test 89 } // namespace sk_gpu_test
141 #endif 90 #endif
OLDNEW
« no previous file with comments | « tools/gpu/TestContext.cpp ('k') | tools/gpu/gl/GLTestContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698