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

Side by Side Diff: tools/gpu/TestContext.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/GrContextFactory.cpp ('k') | tools/gpu/TestContext.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 2016 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
9 #ifndef TestContext_DEFINED
10 #define TestContext_DEFINED
11
12 #include "GrTypes.h"
13 #include "../private/SkGpuFenceSync.h"
14 #include "../private/SkTemplates.h"
15
16 namespace sk_gpu_test {
17 /**
18 * An offscreen 3D context. This class is intended for Skia's internal testing n eeds and not
19 * for general use.
20 */
21 class TestContext : public SkNoncopyable {
22 public:
23 virtual ~TestContext();
24
25 virtual bool isValid() const = 0;
26
27 bool fenceSyncSupport() const { return fFenceSync != nullptr; }
28
29 bool getMaxGpuFrameLag(int *maxFrameLag) const {
30 if (!fFenceSync) {
31 return false;
32 }
33 *maxFrameLag = kMaxFrameLag;
34 return true;
35 }
36
37 void makeCurrent() const;
38
39 virtual GrBackend backend() = 0;
40 virtual GrBackendContext backendContext() = 0;
41
42 /** Swaps front and back buffer (if the context has such buffers) */
43 void swapBuffers();
44
45 /**
46 * The only purpose of this function it to provide a means of scheduling
47 * work on the GPU (since all of the subclasses create primary buffers for
48 * testing that are small and not meant to be rendered to the screen).
49 *
50 * If the platform supports fence syncs (OpenGL 3.2+ or EGL_KHR_fence_sync),
51 * this will not swap any buffers, but rather emulate triple buffer synchron ization
52 * using fences.
53 *
54 * Otherwise it will call the platform SwapBuffers method. This may or may
55 * not perform some sort of synchronization, depending on whether the
56 * drawing surface provided by the platform is double buffered.
57 */
58 void waitOnSyncOrSwap();
59
60 /**
61 * This notifies the context that we are deliberately testing abandoning
62 * the context. It is useful for debugging contexts that would otherwise
63 * test that GPU resources are properly deleted. It also allows a debugging
64 * context to test that further API calls are not made by Skia GPU code.
65 */
66 virtual void testAbandon();
67
68 /**
69 * returns the fencesync object owned by this GLTestContext
70 */
71 SkGpuFenceSync *fenceSync() { return fFenceSync; }
72
73 protected:
74 SkGpuFenceSync* fFenceSync;
75
76 TestContext();
77
78 /** This should destroy the 3D context. */
79 virtual void teardown();
80
81 virtual void onPlatformMakeCurrent() const = 0;
82 virtual void onPlatformSwapBuffers() const = 0;
83
84 private:
85 enum {
86 kMaxFrameLag = 3
87 };
88
89 SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1];
90 int fCurrentFenceIdx;
91
92 typedef SkNoncopyable INHERITED;
93 };
94 } // namespace sk_gpu_test
95 #endif
OLDNEW
« no previous file with comments | « tools/gpu/GrContextFactory.cpp ('k') | tools/gpu/TestContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698