blob: b789f991319a151ff60c46d4ca3e5061c173fd25 [file] [log] [blame]
robertphillips@google.com58b20212012-06-27 20:44:52 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrSWMaskHelper_DEFINED
9#define GrSWMaskHelper_DEFINED
10
11#include "GrColor.h"
12#include "GrMatrix.h"
13#include "GrNoncopyable.h"
14#include "SkBitmap.h"
15#include "SkDraw.h"
16#include "SkRasterClip.h"
17#include "SkRegion.h"
18
19class GrAutoScratchTexture;
20class GrContext;
21class GrTexture;
22class SkPath;
23
24/**
25 * The GrSWMaskHelper helps generate clip masks using the software rendering
26 * path.
27 */
28class GrSWMaskHelper : public GrNoncopyable {
29public:
30 GrSWMaskHelper(GrContext* context)
31 : fContext(context) {
32 }
33
34 void draw(const GrRect& clientRect, SkRegion::Op op,
35 bool antiAlias, GrColor color);
36
37 void draw(const SkPath& clientPath, SkRegion::Op op,
38 GrPathFill fill, bool antiAlias, GrColor color);
39
40 bool init(const GrIRect& pathDevBounds,
41 const GrPoint* translate,
42 bool useMatrix);
43
44 bool getTexture(GrAutoScratchTexture* tex);
45
46 void toTexture(GrTexture* texture, bool clearToWhite);
47
48 void clear(GrColor color) {
49 fBM.eraseColor(color);
50 }
51
52protected:
53private:
54 GrContext* fContext;
55 GrMatrix fMatrix;
56 SkBitmap fBM;
57 SkDraw fDraw;
58 SkRasterClip fRasterClip;
59
60 typedef GrNoncopyable INHERITED;
61};
62
63#endif GrSWMaskHelper_DEFINED