blob: 55235fa6032ab4848a7bbf4970e4590fdcf3ec58 [file] [log] [blame]
bsalomon@google.com373a6632011-10-19 20:43:20 +00001
2/*
3 * Copyright 2011 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 SkMesaGLContext_DEFINED
9#define SkMesaGLContext_DEFINED
10
robertphillips@google.com6177e692013-02-28 20:16:25 +000011#include "SkGLContextHelper.h"
bsalomon@google.com373a6632011-10-19 20:43:20 +000012
13#if SK_MESA
14
robertphillips@google.com6177e692013-02-28 20:16:25 +000015class SkMesaGLContext : public SkGLContextHelper {
bsalomon@google.com57f5d982011-10-24 21:17:53 +000016private:
17 typedef intptr_t Context;
18
bsalomon@google.com373a6632011-10-19 20:43:20 +000019public:
20 SkMesaGLContext();
21
22 virtual ~SkMesaGLContext();
23
24 virtual void makeCurrent() const SK_OVERRIDE;
djsollen@google.comc9542ca2013-10-09 18:25:38 +000025 virtual void swapBuffers() const SK_OVERRIDE;
bsalomon@google.com373a6632011-10-19 20:43:20 +000026
bsalomon@google.com57f5d982011-10-24 21:17:53 +000027 class AutoContextRestore {
28 public:
29 AutoContextRestore();
30 ~AutoContextRestore();
31
32 private:
33 Context fOldContext;
bsalomon@google.comb3400ba2012-04-19 19:27:19 +000034 GrGLint fOldWidth;
35 GrGLint fOldHeight;
36 GrGLint fOldFormat;
bsalomon@google.com57f5d982011-10-24 21:17:53 +000037 void* fOldImage;
38 };
39
bsalomon@google.com373a6632011-10-19 20:43:20 +000040protected:
41 virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
bsalomon@google.com74913722011-10-27 20:44:19 +000042 virtual void destroyGLContext() SK_OVERRIDE;
bsalomon@google.com373a6632011-10-19 20:43:20 +000043
44private:
bsalomon@google.com373a6632011-10-19 20:43:20 +000045 Context fContext;
46 GrGLubyte *fImage;
47};
48
49#endif
50
bsalomon@google.com57f5d982011-10-24 21:17:53 +000051#endif