blob: 7e2ffed540bb7bb1d19998f74a9c27e1f4ede885 [file] [log] [blame]
commit-bot@chromium.org78a10782013-08-21 19:27:48 +00001
2/*
3 * Copyright 2013 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 GrTest_DEFINED
10#define GrTest_DEFINED
11
12#include "GrContext.h"
13#include "GrDrawTarget.h"
reedf9ad5582015-06-25 21:29:25 -070014#include "gl/GrGLContext.h"
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000015
16/** Allows a test to temporarily draw to a GrDrawTarget owned by a GrContext. Tests that use this
17 should be careful not to mix using the GrDrawTarget directly and drawing via SkCanvas or
18 GrContext. In the future this object may provide some guards to prevent this. */
19class GrTestTarget {
20public:
reedf9ad5582015-06-25 21:29:25 -070021 GrTestTarget() : fGLContext(NULL) {};
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000022
reedf9ad5582015-06-25 21:29:25 -070023 void init(GrContext*, GrDrawTarget*, const GrGLContext*);
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000024
25 GrDrawTarget* target() { return fDrawTarget.get(); }
26
reedf9ad5582015-06-25 21:29:25 -070027 /** Returns a GrGLContext if the GrContext is backed by OpenGL. */
28 const GrGLContext* glContext() { return fGLContext; }
bsalomon993a4212015-05-29 11:37:25 -070029
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000030private:
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000031 SkAutoTUnref<GrDrawTarget> fDrawTarget;
32 SkAutoTUnref<GrContext> fContext;
reedf9ad5582015-06-25 21:29:25 -070033 SkAutoTUnref<const GrGLContext> fGLContext;
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000034};
35
36#endif