robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 1 | |
| 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.com | b4f06d7 | 2012-05-15 12:10:05 +0000 | [diff] [blame^] | 14 | #include "SkDraw.h" |
| 15 | #include "SkRasterClip.h" |
| 16 | |
| 17 | class GrContext; |
| 18 | class GrAutoScratchTexture; |
| 19 | |
| 20 | /** |
| 21 | * The GrSWMaskHelper helps generate clip masks using the software rendering |
| 22 | * path. |
| 23 | */ |
| 24 | class GrSWMaskHelper : public GrNoncopyable { |
| 25 | public: |
| 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 | |
| 42 | protected: |
| 43 | private: |
| 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.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 57 | class GrSoftwarePathRenderer : public GrPathRenderer { |
| 58 | public: |
| 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; |
| 67 | protected: |
| 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 | |
| 75 | private: |
| 76 | GrContext* fContext; |
| 77 | |
| 78 | typedef GrPathRenderer INHERITED; |
| 79 | }; |
| 80 | |
| 81 | #endif |