robertphillips@google.com | 58b2021 | 2012-06-27 20:44:52 +0000 | [diff] [blame^] | 1 | /* |
| 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 | |
| 19 | class GrAutoScratchTexture; |
| 20 | class GrContext; |
| 21 | class GrTexture; |
| 22 | class SkPath; |
| 23 | |
| 24 | /** |
| 25 | * The GrSWMaskHelper helps generate clip masks using the software rendering |
| 26 | * path. |
| 27 | */ |
| 28 | class GrSWMaskHelper : public GrNoncopyable { |
| 29 | public: |
| 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 | |
| 52 | protected: |
| 53 | private: |
| 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 |