gfx/skia/trunk/src/gpu/GrAARectRenderer.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright 2012 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef GrAARectRenderer_DEFINED
michael@0 9 #define GrAARectRenderer_DEFINED
michael@0 10
michael@0 11 #include "SkMatrix.h"
michael@0 12 #include "SkRect.h"
michael@0 13 #include "SkRefCnt.h"
michael@0 14 #include "SkStrokeRec.h"
michael@0 15
michael@0 16 class GrGpu;
michael@0 17 class GrDrawTarget;
michael@0 18 class GrIndexBuffer;
michael@0 19
michael@0 20 /*
michael@0 21 * This class wraps helper functions that draw AA rects (filled & stroked)
michael@0 22 */
michael@0 23 class GrAARectRenderer : public SkRefCnt {
michael@0 24 public:
michael@0 25 SK_DECLARE_INST_COUNT(GrAARectRenderer)
michael@0 26
michael@0 27 GrAARectRenderer()
michael@0 28 : fAAFillRectIndexBuffer(NULL)
michael@0 29 , fAAMiterStrokeRectIndexBuffer(NULL)
michael@0 30 , fAABevelStrokeRectIndexBuffer(NULL) {
michael@0 31 }
michael@0 32
michael@0 33 void reset();
michael@0 34
michael@0 35 ~GrAARectRenderer() {
michael@0 36 this->reset();
michael@0 37 }
michael@0 38
michael@0 39 // TODO: potentialy fuse the fill & stroke methods and differentiate
michael@0 40 // between them by passing in stroke (==NULL means fill).
michael@0 41
michael@0 42 void fillAARect(GrGpu* gpu,
michael@0 43 GrDrawTarget* target,
michael@0 44 const SkRect& rect,
michael@0 45 const SkMatrix& combinedMatrix,
michael@0 46 const SkRect& devRect,
michael@0 47 bool useVertexCoverage) {
michael@0 48 #ifdef SHADER_AA_FILL_RECT
michael@0 49 if (combinedMatrix.rectStaysRect()) {
michael@0 50 this->shaderFillAlignedAARect(gpu, target,
michael@0 51 rect, combinedMatrix);
michael@0 52 } else {
michael@0 53 this->shaderFillAARect(gpu, target,
michael@0 54 rect, combinedMatrix);
michael@0 55 }
michael@0 56 #else
michael@0 57 this->geometryFillAARect(gpu, target,
michael@0 58 rect, combinedMatrix,
michael@0 59 devRect, useVertexCoverage);
michael@0 60 #endif
michael@0 61 }
michael@0 62
michael@0 63 void strokeAARect(GrGpu* gpu,
michael@0 64 GrDrawTarget* target,
michael@0 65 const SkRect& rect,
michael@0 66 const SkMatrix& combinedMatrix,
michael@0 67 const SkRect& devRect,
michael@0 68 const SkStrokeRec* stroke,
michael@0 69 bool useVertexCoverage);
michael@0 70
michael@0 71 // First rect is outer; second rect is inner
michael@0 72 void fillAANestedRects(GrGpu* gpu,
michael@0 73 GrDrawTarget* target,
michael@0 74 const SkRect rects[2],
michael@0 75 const SkMatrix& combinedMatrix,
michael@0 76 bool useVertexCoverage);
michael@0 77
michael@0 78 private:
michael@0 79 GrIndexBuffer* fAAFillRectIndexBuffer;
michael@0 80 GrIndexBuffer* fAAMiterStrokeRectIndexBuffer;
michael@0 81 GrIndexBuffer* fAABevelStrokeRectIndexBuffer;
michael@0 82
michael@0 83 GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu);
michael@0 84
michael@0 85 static int aaStrokeRectIndexCount(bool miterStroke);
michael@0 86 GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke);
michael@0 87
michael@0 88 // TODO: Remove the useVertexCoverage boolean. Just use it all the time
michael@0 89 // since we now have a coverage vertex attribute
michael@0 90 void geometryFillAARect(GrGpu* gpu,
michael@0 91 GrDrawTarget* target,
michael@0 92 const SkRect& rect,
michael@0 93 const SkMatrix& combinedMatrix,
michael@0 94 const SkRect& devRect,
michael@0 95 bool useVertexCoverage);
michael@0 96
michael@0 97 void shaderFillAARect(GrGpu* gpu,
michael@0 98 GrDrawTarget* target,
michael@0 99 const SkRect& rect,
michael@0 100 const SkMatrix& combinedMatrix);
michael@0 101
michael@0 102 void shaderFillAlignedAARect(GrGpu* gpu,
michael@0 103 GrDrawTarget* target,
michael@0 104 const SkRect& rect,
michael@0 105 const SkMatrix& combinedMatrix);
michael@0 106
michael@0 107 void geometryStrokeAARect(GrGpu* gpu,
michael@0 108 GrDrawTarget* target,
michael@0 109 const SkRect& devOutside,
michael@0 110 const SkRect& devOutsideAssist,
michael@0 111 const SkRect& devInside,
michael@0 112 bool useVertexCoverage,
michael@0 113 bool miterStroke);
michael@0 114
michael@0 115 typedef SkRefCnt INHERITED;
michael@0 116 };
michael@0 117
michael@0 118 #endif // GrAARectRenderer_DEFINED

mercurial