blob: 4b75d036f3085cedd765bab249f025e5ea616ace [file] [log] [blame]
robertphillips@google.comf4c2c522012-04-27 12:08:47 +00001
2/*
3 * Copyright 2012 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#ifndef GrSoftwarePathRenderer_DEFINED
10#define GrSoftwarePathRenderer_DEFINED
11
12#include "GrPathRenderer.h"
13
robertphillips@google.comb4f06d72012-05-15 12:10:05 +000014#include "SkDraw.h"
15#include "SkRasterClip.h"
16
17class GrContext;
18class GrAutoScratchTexture;
19
20/**
21 * The GrSWMaskHelper helps generate clip masks using the software rendering
22 * path.
23 */
24class GrSWMaskHelper : public GrNoncopyable {
25public:
26 GrSWMaskHelper(GrContext* context)
27 : fContext(context) {
28
29 }
30
31 void draw(const GrRect& clientRect, SkRegion::Op op, bool antiAlias);
32
33 void draw(const SkPath& clientPath, SkRegion::Op op,
34 GrPathFill fill, bool antiAlias);
35
36 bool init(const GrIRect& pathDevBounds, const GrPoint* translate);
37
38 bool getTexture(GrAutoScratchTexture* tex);
39
40 void toTexture(GrTexture* texture);
41
42protected:
43private:
44 GrContext* fContext;
45 GrMatrix fMatrix;
46 SkBitmap fBM;
47 SkDraw fDraw;
48 SkRasterClip fRasterClip;
49
50 typedef GrPathRenderer INHERITED;
51};
52
53/**
54 * This class uses the software side to render a path to an SkBitmap and
55 * then uploads the result to the gpu
56 */
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000057class GrSoftwarePathRenderer : public GrPathRenderer {
58public:
59 GrSoftwarePathRenderer(GrContext* context)
60 : fContext(context) {
61 }
62
63 virtual bool canDrawPath(const SkPath& path,
64 GrPathFill fill,
65 const GrDrawTarget* target,
66 bool antiAlias) const SK_OVERRIDE;
67protected:
68 virtual bool onDrawPath(const SkPath& path,
69 GrPathFill fill,
70 const GrVec* translate,
71 GrDrawTarget* target,
72 GrDrawState::StageMask stageMask,
73 bool antiAlias) SK_OVERRIDE;
74
75private:
76 GrContext* fContext;
77
78 typedef GrPathRenderer INHERITED;
79};
80
81#endif