diff options
author | 2011-10-12 19:53:16 +0000 | |
---|---|---|
committer | 2011-10-12 19:53:16 +0000 | |
commit | d38f137e9b813f8193675ebd3dfbfe8bc42639e9 (patch) | |
tree | 1e670c378d7b31a4538fde3c2b3e4e29b72c05b5 /src/gpu/GrPathRendererChain.cpp | |
parent | 4d5cb45f3e3e62633304b4911d131cdd02dfd541 (diff) |
Move gpu/include/* to include/gpu and gpu/src/* to src/gpu
Review URL: http://codereview.appspot.com/5250070/
git-svn-id: http://skia.googlecode.com/svn/trunk@2471 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrPathRendererChain.cpp')
-rw-r--r-- | src/gpu/GrPathRendererChain.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp new file mode 100644 index 0000000000..7a064e8c9c --- /dev/null +++ b/src/gpu/GrPathRendererChain.cpp @@ -0,0 +1,64 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#include "GrPathRendererChain.h" + +#include "GrContext.h" +#include "GrDefaultPathRenderer.h" +#include "GrGpu.h" + +GrPathRendererChain::GrPathRendererChain(GrContext* context, UsageFlags flags) + : fInit(false) + , fOwner(context) + , fFlags(flags) { + fInit = false; +} + +GrPathRendererChain::~GrPathRendererChain() { + for (int i = 0; i < fChain.count(); ++i) { + fChain[i]->unref(); + } +} + +GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { + fChain.push_back() = pr; + pr->ref(); + return pr; +} + +GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrDrawTarget* target, + const GrPath& path, + GrPathFill fill) { + if (!fInit) { + this->init(); + } + bool preferAA = target->isAntialiasState() && + !target->getRenderTarget()->isMultisampled(); + GrPathRenderer* nonAAPR = NULL; + for (int i = 0; i < fChain.count(); ++i) { + if (fChain[i]->canDrawPath(target, path, fill)) { + if (!preferAA || fChain[i]->supportsAA(target, path, fill)) { + return fChain[i]; + } else { + nonAAPR = fChain[i]; + } + } + } + return nonAAPR; +} + +void GrPathRendererChain::init() { + GrAssert(!fInit); + GrGpu* gpu = fOwner->getGpu(); + bool twoSided = gpu->getCaps().fTwoSidedStencilSupport; + bool wrapOp = gpu->getCaps().fStencilWrapOpsSupport; + GrPathRenderer::AddPathRenderers(fOwner, fFlags, this); + this->addPathRenderer(new GrDefaultPathRenderer(twoSided, wrapOp))->unref(); + fInit = true; +} |