gfx/skia/trunk/include/gpu/GrPathRendererChain.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/gpu/GrPathRendererChain.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +/*
     1.5 + * Copyright 2011 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef GrPathRendererChain_DEFINED
    1.12 +#define GrPathRendererChain_DEFINED
    1.13 +
    1.14 +#include "SkRefCnt.h"
    1.15 +#include "SkTArray.h"
    1.16 +
    1.17 +class GrContext;
    1.18 +class GrDrawTarget;
    1.19 +class GrPathRenderer;
    1.20 +class SkPath;
    1.21 +class SkStrokeRec;
    1.22 +
    1.23 +/**
    1.24 + * Keeps track of an ordered list of path renderers. When a path needs to be
    1.25 + * drawn this list is scanned to find the most preferred renderer. To add your
    1.26 + * path renderer to the list implement the GrPathRenderer::AddPathRenderers
    1.27 + * function.
    1.28 + */
    1.29 +class GrPathRendererChain : public SkRefCnt {
    1.30 +public:
    1.31 +    // See comments in GrPathRenderer.h
    1.32 +    enum StencilSupport {
    1.33 +        kNoSupport_StencilSupport,
    1.34 +        kStencilOnly_StencilSupport,
    1.35 +        kNoRestriction_StencilSupport,
    1.36 +    };
    1.37 +
    1.38 +    SK_DECLARE_INST_COUNT(GrPathRendererChain)
    1.39 +
    1.40 +    GrPathRendererChain(GrContext* context);
    1.41 +
    1.42 +    ~GrPathRendererChain();
    1.43 +
    1.44 +    // takes a ref and unrefs in destructor
    1.45 +    GrPathRenderer* addPathRenderer(GrPathRenderer* pr);
    1.46 +
    1.47 +    /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR
    1.48 +        returned by getPathRenderer */
    1.49 +    enum DrawType {
    1.50 +        kColor_DrawType,                    // draw to the color buffer, no AA
    1.51 +        kColorAntiAlias_DrawType,           // draw to color buffer, with partial coverage AA
    1.52 +        kStencilOnly_DrawType,              // draw just to the stencil buffer
    1.53 +        kStencilAndColor_DrawType,          // draw the stencil and color buffer, no AA
    1.54 +        kStencilAndColorAntiAlias_DrawType  // draw the stencil and color buffer, with partial
    1.55 +                                            // coverage AA.
    1.56 +    };
    1.57 +    /** Returns a GrPathRenderer compatible with the request if one is available. If the caller
    1.58 +        is drawing the path to the stencil buffer then stencilSupport can be used to determine
    1.59 +        whether the path can be rendered with arbitrary stencil rules or not. See comments on
    1.60 +        StencilSupport in GrPathRenderer.h. */
    1.61 +    GrPathRenderer* getPathRenderer(const SkPath& path,
    1.62 +                                    const SkStrokeRec& rec,
    1.63 +                                    const GrDrawTarget* target,
    1.64 +                                    DrawType drawType,
    1.65 +                                    StencilSupport* stencilSupport);
    1.66 +
    1.67 +private:
    1.68 +    GrPathRendererChain();
    1.69 +
    1.70 +    void init();
    1.71 +
    1.72 +    enum {
    1.73 +        kPreAllocCount = 8,
    1.74 +    };
    1.75 +    bool fInit;
    1.76 +    GrContext*                                          fOwner;
    1.77 +    SkSTArray<kPreAllocCount, GrPathRenderer*, true>    fChain;
    1.78 +
    1.79 +    typedef SkRefCnt INHERITED;
    1.80 +};
    1.81 +
    1.82 +#endif

mercurial