commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 1 | |
| 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" |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame^] | 14 | #include "gl/GrGLContext.h" |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 15 | |
| 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. */ |
| 19 | class GrTestTarget { |
| 20 | public: |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame^] | 21 | GrTestTarget() : fGLContext(NULL) {}; |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 22 | |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame^] | 23 | void init(GrContext*, GrDrawTarget*, const GrGLContext*); |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 24 | |
| 25 | GrDrawTarget* target() { return fDrawTarget.get(); } |
| 26 | |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame^] | 27 | /** Returns a GrGLContext if the GrContext is backed by OpenGL. */ |
| 28 | const GrGLContext* glContext() { return fGLContext; } |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 29 | |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 30 | private: |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 31 | SkAutoTUnref<GrDrawTarget> fDrawTarget; |
| 32 | SkAutoTUnref<GrContext> fContext; |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame^] | 33 | SkAutoTUnref<const GrGLContext> fGLContext; |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | #endif |