00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef SkDraw_DEFINED
00018 #define SkDraw_DEFINED
00019
00020 #include "SkBitmap.h"
00021 #include "SkCanvas.h"
00022 #include "SkMask.h"
00023 #include "SkMatrix.h"
00024 #include "SkPaint.h"
00025 #include "SkRect.h"
00026 #include "SkAutoKern.h"
00027
00028 class SkBounder;
00029 class SkDevice;
00030 class SkPath;
00031 class SkRegion;
00032 struct SkDrawProcs;
00033
00034 class SkDraw {
00035 public:
00036 SkDraw() : fDevice(NULL), fBounder(NULL), fProcs(NULL) {}
00037 SkDraw(const SkDraw& src);
00038
00039 void drawPaint(const SkPaint&) const;
00040 void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint[],
00041 const SkPaint&) const;
00042 void drawRect(const SkRect&, const SkPaint&) const;
00043
00044
00045
00046 void drawPath(const SkPath& srcPath, const SkPaint&,
00047 const SkMatrix* prePathMatrix, bool pathIsMutable) const;
00048 void drawBitmap(const SkBitmap&, const SkMatrix&, const SkPaint&) const;
00049 void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
00050 void drawText(const char text[], size_t byteLength, SkScalar x,
00051 SkScalar y, const SkPaint& paint) const;
00052 void drawPosText(const char text[], size_t byteLength,
00053 const SkScalar pos[], SkScalar constY,
00054 int scalarsPerPosition, const SkPaint& paint) const;
00055 void drawTextOnPath(const char text[], size_t byteLength,
00056 const SkPath&, const SkMatrix*, const SkPaint&) const;
00057 void drawVertices(SkCanvas::VertexMode mode, int count,
00058 const SkPoint vertices[], const SkPoint textures[],
00059 const SkColor colors[], SkXfermode* xmode,
00060 const uint16_t indices[], int ptCount,
00061 const SkPaint& paint) const;
00062
00063 void drawPath(const SkPath& src, const SkPaint& paint) const {
00064 this->drawPath(src, paint, NULL, false);
00065 }
00066
00072 static bool DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
00073 SkMaskFilter* filter, const SkMatrix* filterMatrix,
00074 SkMask* mask, SkMask::CreateMode mode);
00075
00076 private:
00077 void drawText_asPaths(const char text[], size_t byteLength,
00078 SkScalar x, SkScalar y, const SkPaint&) const;
00079 void drawDevMask(const SkMask& mask, const SkPaint&) const;
00080 void drawBitmapAsMask(const SkBitmap&, const SkPaint&) const;
00081
00082 public:
00083 const SkBitmap* fBitmap;
00084 const SkMatrix* fMatrix;
00085 const SkRegion* fClip;
00086 SkDevice* fDevice;
00087 SkBounder* fBounder;
00088 SkDrawProcs* fProcs;
00089
00090 #ifdef SK_DEBUG
00091 void validate() const;
00092 #endif
00093 };
00094
00095 class SkGlyphCache;
00096
00097 class SkTextToPathIter {
00098 public:
00099 SkTextToPathIter(const char text[], size_t length, const SkPaint&,
00100 bool applyStrokeAndPathEffects, bool forceLinearTextOn);
00101 ~SkTextToPathIter();
00102
00103 const SkPaint& getPaint() const { return fPaint; }
00104 SkScalar getPathScale() const { return fScale; }
00105
00106 const SkPath* next(SkScalar* xpos);
00107
00108 private:
00109 SkGlyphCache* fCache;
00110 SkPaint fPaint;
00111 SkScalar fScale;
00112 SkFixed fPrevAdvance;
00113 const char* fText;
00114 const char* fStop;
00115 SkMeasureCacheProc fGlyphCacheProc;
00116
00117 const SkPath* fPath;
00118 SkScalar fXPos;
00119 SkAutoKern fAutoKern;
00120 };
00121
00122 #endif
00123
00124