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 | #include "GrTest.h" |
| 10 | |
| 11 | #include "GrGpu.h" |
robertphillips@google.com | 94d8f1e | 2013-12-18 17:25:33 +0000 | [diff] [blame] | 12 | #include "GrResourceCache.h" |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 13 | |
| 14 | void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { |
| 15 | SkASSERT(!fContext); |
| 16 | |
| 17 | fContext.reset(SkRef(ctx)); |
| 18 | fDrawTarget.reset(SkRef(target)); |
| 19 | |
| 20 | SkNEW_IN_TLAZY(&fASR, GrDrawTarget::AutoStateRestore, (target, GrDrawTarget::kReset_ASRInit)); |
| 21 | SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target)); |
| 22 | SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target)); |
| 23 | } |
| 24 | |
| 25 | void GrContext::getTestTarget(GrTestTarget* tar) { |
| 26 | this->flush(); |
| 27 | // We could create a proxy GrDrawTarget that passes through to fGpu until ~GrTextTarget() and |
| 28 | // then disconnects. This would help prevent test writers from mixing using the returned |
| 29 | // GrDrawTarget and regular drawing. We could also assert or fail in GrContext drawing methods |
| 30 | // until ~GrTestTarget(). |
| 31 | tar->init(this, fGpu); |
| 32 | } |
| 33 | |
| 34 | /////////////////////////////////////////////////////////////////////////////// |
| 35 | |
| 36 | void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) { |
| 37 | fMaxTextureSizeOverride = maxTextureSizeOverride; |
| 38 | } |
robertphillips@google.com | 94d8f1e | 2013-12-18 17:25:33 +0000 | [diff] [blame] | 39 | |
| 40 | void GrContext::purgeAllUnlockedResources() { |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 41 | fResourceCache->purgeAllUnlocked(); |
robertphillips@google.com | 94d8f1e | 2013-12-18 17:25:33 +0000 | [diff] [blame] | 42 | } |