| OLD | NEW |
| (Empty) |
| 1 #ifndef SkGLDevice_DEFINED | |
| 2 #define SkGLDevice_DEFINED | |
| 3 | |
| 4 #include "SkDevice.h" | |
| 5 #include "SkGL.h" | |
| 6 #include "SkRegion.h" | |
| 7 | |
| 8 struct SkGLDrawProcs; | |
| 9 | |
| 10 class SkGLDevice : public SkDevice { | |
| 11 public: | |
| 12 SkGLDevice(const SkBitmap& bitmap, bool offscreen); | |
| 13 virtual ~SkGLDevice(); | |
| 14 | |
| 15 // used to identify GLTextCache data in the glyphcache | |
| 16 static void GlyphCacheAuxProc(void* data); | |
| 17 | |
| 18 enum TexOrientation { | |
| 19 kNo_TexOrientation, | |
| 20 kTopToBottom_TexOrientation, | |
| 21 kBottomToTop_TexOrientation | |
| 22 }; | |
| 23 | |
| 24 /** Called when this device is no longer a candidate for a render target, | |
| 25 but will instead be used as a texture to be drawn. Be sure to call | |
| 26 the base impl if you override, as it will compute size and max. | |
| 27 */ | |
| 28 virtual TexOrientation bindDeviceAsTexture(); | |
| 29 | |
| 30 // returns true if complex | |
| 31 SkGLClipIter* updateMatrixClip(); | |
| 32 // call to set the clip to the specified rect | |
| 33 void scissor(const SkIRect&); | |
| 34 | |
| 35 // overrides from SkDevice | |
| 36 virtual void gainFocus(SkCanvas*); | |
| 37 virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& clip); | |
| 38 | |
| 39 virtual void drawPaint(const SkDraw&, const SkPaint& paint); | |
| 40 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | |
| 41 const SkPoint[], const SkPaint& paint); | |
| 42 virtual void drawRect(const SkDraw&, const SkRect& r, | |
| 43 const SkPaint& paint); | |
| 44 virtual void drawPath(const SkDraw&, const SkPath& path, | |
| 45 const SkPaint& paint); | |
| 46 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, | |
| 47 const SkMatrix& matrix, const SkPaint& paint); | |
| 48 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, | |
| 49 int x, int y, const SkPaint& paint); | |
| 50 virtual void drawText(const SkDraw&, const void* text, size_t len, | |
| 51 SkScalar x, SkScalar y, const SkPaint& paint); | |
| 52 virtual void drawPosText(const SkDraw&, const void* text, size_t len, | |
| 53 const SkScalar pos[], SkScalar constY, | |
| 54 int scalarsPerPos, const SkPaint& paint); | |
| 55 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, | |
| 56 const SkPath& path, const SkMatrix* matrix, | |
| 57 const SkPaint& paint); | |
| 58 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou
nt, | |
| 59 const SkPoint verts[], const SkPoint texs[], | |
| 60 const SkColor colors[], SkXfermode* xmode, | |
| 61 const uint16_t indices[], int indexCount, | |
| 62 const SkPaint& paint); | |
| 63 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, | |
| 64 const SkPaint&); | |
| 65 | |
| 66 protected: | |
| 67 /** Return the current glmatrix, from a previous call to setMatrixClip */ | |
| 68 const SkMatrix& matrix() const { return fMatrix; } | |
| 69 /** Return the current clip, from a previous call to setMatrixClip */ | |
| 70 const SkRegion& clip() const { return fClip; } | |
| 71 | |
| 72 private: | |
| 73 SkGLMatrix fGLMatrix; | |
| 74 SkMatrix fMatrix; | |
| 75 SkRegion fClip; | |
| 76 bool fDirty; | |
| 77 | |
| 78 SkGLClipIter fClipIter; | |
| 79 SkGLDrawProcs* fDrawProcs; | |
| 80 | |
| 81 void setupForText(SkDraw* draw, const SkPaint& paint); | |
| 82 | |
| 83 // global texture cache methods | |
| 84 class TexCache; | |
| 85 static TexCache* LockTexCache(const SkBitmap&, GLuint* name, | |
| 86 SkPoint* size); | |
| 87 static void UnlockTexCache(TexCache*); | |
| 88 class SkAutoLockTexCache { | |
| 89 public: | |
| 90 SkAutoLockTexCache(const SkBitmap& bitmap, GLuint* name, | |
| 91 SkPoint* size) { | |
| 92 fTex = SkGLDevice::LockTexCache(bitmap, name, size); | |
| 93 } | |
| 94 ~SkAutoLockTexCache() { | |
| 95 if (fTex) { | |
| 96 SkGLDevice::UnlockTexCache(fTex); | |
| 97 } | |
| 98 } | |
| 99 TexCache* get() const { return fTex; } | |
| 100 private: | |
| 101 TexCache* fTex; | |
| 102 }; | |
| 103 friend class SkAutoTexCache; | |
| 104 | |
| 105 // returns cache if the texture is bound for the shader | |
| 106 TexCache* setupGLPaintShader(const SkPaint& paint); | |
| 107 | |
| 108 class AutoPaintShader { | |
| 109 public: | |
| 110 AutoPaintShader(SkGLDevice*, const SkPaint& paint); | |
| 111 ~AutoPaintShader(); | |
| 112 | |
| 113 bool useTex() const { return fTexCache != 0; } | |
| 114 private: | |
| 115 SkGLDevice* fDevice; | |
| 116 TexCache* fTexCache; | |
| 117 }; | |
| 118 friend class AutoPaintShader; | |
| 119 | |
| 120 typedef SkDevice INHERITED; | |
| 121 }; | |
| 122 | |
| 123 #endif | |
| 124 | |
| OLD | NEW |