178a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
278a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org/*
378a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org * Copyright 2013 Google Inc.
478a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org *
578a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be
678a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org * found in the LICENSE file.
778a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org */
878a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
978a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org#include "GrTest.h"
1078a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
1178a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org#include "GrGpu.h"
1294d8f1ed6116780346ffa39ed683f1977786434arobertphillips@google.com#include "GrResourceCache.h"
1378a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
1478a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.orgvoid GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) {
1578a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    SkASSERT(!fContext);
1678a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
1778a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    fContext.reset(SkRef(ctx));
1878a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    fDrawTarget.reset(SkRef(target));
1978a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
2078a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    SkNEW_IN_TLAZY(&fASR, GrDrawTarget::AutoStateRestore, (target, GrDrawTarget::kReset_ASRInit));
2178a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target));
2278a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target));
2378a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org}
2478a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
2578a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.orgvoid GrContext::getTestTarget(GrTestTarget* tar) {
2678a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    this->flush();
2778a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    // We could create a proxy GrDrawTarget that passes through to fGpu until ~GrTextTarget() and
2878a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    // then disconnects. This would help prevent test writers from mixing using the returned
2978a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    // GrDrawTarget and regular drawing. We could also assert or fail in GrContext drawing methods
3078a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    // until ~GrTestTarget().
3178a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    tar->init(this, fGpu);
3278a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org}
3378a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
3478a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org///////////////////////////////////////////////////////////////////////////////
3578a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org
3678a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.orgvoid GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) {
3778a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org    fMaxTextureSizeOverride = maxTextureSizeOverride;
3878a1078f17f4f0ae63415298517262a64f706af6commit-bot@chromium.org}
3994d8f1ed6116780346ffa39ed683f1977786434arobertphillips@google.com
4094d8f1ed6116780346ffa39ed683f1977786434arobertphillips@google.comvoid GrContext::purgeAllUnlockedResources() {
4195c2003740c4cd01fd1b02ed93b9de7227b1d0f5commit-bot@chromium.org    fResourceCache->purgeAllUnlocked();
4294d8f1ed6116780346ffa39ed683f1977786434arobertphillips@google.com}
43