aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
blob: 47f3fd967a3b665217864a8d24690452e20751bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SKCOMMANDBUFFERGLCONTEXT_DEFINED
#define SKCOMMANDBUFFERGLCONTEXT_DEFINED

#if SK_COMMAND_BUFFER

#include "gl/SkGLContext.h"

class SkCommandBufferGLContext : public SkGLContext {
public:
    ~SkCommandBufferGLContext() override;

    static SkCommandBufferGLContext* Create() {
        SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext;
        if (!ctx->isValid()) {
            delete ctx;
            return nullptr;
        }
        return ctx;
    }

    static SkCommandBufferGLContext* Create(void* nativeWindow, int msaaSampleCount) {
        SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(nativeWindow,
                                                                     msaaSampleCount);
        if (!ctx->isValid()) {
            delete ctx;
            return nullptr;
        }
        return ctx;
    }

    void presentCommandBuffer();

    bool makeCurrent();
    int getStencilBits();
    int getSampleCount();

private:
    SkCommandBufferGLContext();
    SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount);
    void initializeGLContext(void* nativeWindow, const int* configAttribs,
                             const int* surfaceAttribs);
    void destroyGLContext();

    void onPlatformMakeCurrent() const override;
    void onPlatformSwapBuffers() const override;
    GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;

    void* fContext;
    void* fDisplay;
    void* fSurface;
    void* fConfig;
};

#endif // SK_COMMAND_BUFFER

#endif