blob: eb1d7de25dcb2a943cddf8ced6b0db3de55057a9 [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:
jvanverth672bb7f2015-07-13 07:19:57 -070021 GrTestTarget() {};
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000022
jvanverth672bb7f2015-07-13 07:19:57 -070023 void init(GrContext*, GrDrawTarget*);
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000024
25 GrDrawTarget* target() { return fDrawTarget.get(); }
bsalomon0aff2fa2015-07-31 06:48:27 -070026 GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); }
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000027
28private:
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000029 SkAutoTUnref<GrDrawTarget> fDrawTarget;
30 SkAutoTUnref<GrContext> fContext;
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000031};
32
33#endif