2016-03-31 01:56:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2016-03-31 17:22:40 +00:00
|
|
|
#ifndef GLContext_command_buffer_DEFINED
|
|
|
|
#define GLContext_command_buffer_DEFINED
|
2016-03-31 01:56:19 +00:00
|
|
|
|
2016-03-31 17:22:40 +00:00
|
|
|
#include "gl/GLContext.h"
|
2016-03-31 01:56:19 +00:00
|
|
|
|
|
|
|
namespace sk_gpu_test {
|
2016-03-31 17:22:40 +00:00
|
|
|
class CommandBufferGLContext : public GLContext {
|
2016-03-31 01:56:19 +00:00
|
|
|
public:
|
2016-03-31 17:22:40 +00:00
|
|
|
~CommandBufferGLContext() override;
|
2016-03-31 01:56:19 +00:00
|
|
|
|
2016-03-31 17:22:40 +00:00
|
|
|
static CommandBufferGLContext *Create() {
|
|
|
|
CommandBufferGLContext *ctx = new CommandBufferGLContext;
|
2016-03-31 01:56:19 +00:00
|
|
|
if (!ctx->isValid()) {
|
|
|
|
delete ctx;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
2016-03-31 17:22:40 +00:00
|
|
|
static CommandBufferGLContext *Create(void *nativeWindow, int msaaSampleCount) {
|
|
|
|
CommandBufferGLContext *ctx = new CommandBufferGLContext(nativeWindow, msaaSampleCount);
|
2016-03-31 01:56:19 +00:00
|
|
|
if (!ctx->isValid()) {
|
|
|
|
delete ctx;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void presentCommandBuffer();
|
|
|
|
|
|
|
|
bool makeCurrent();
|
|
|
|
|
|
|
|
int getStencilBits();
|
|
|
|
|
|
|
|
int getSampleCount();
|
|
|
|
|
|
|
|
private:
|
2016-03-31 17:22:40 +00:00
|
|
|
CommandBufferGLContext();
|
2016-03-31 01:56:19 +00:00
|
|
|
|
2016-03-31 17:22:40 +00:00
|
|
|
CommandBufferGLContext(void *nativeWindow, int msaaSampleCount);
|
2016-03-31 01:56:19 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
} // namespace sk_gpu_test
|
|
|
|
|
|
|
|
#endif
|