Index: include/core/SkSurface.h |
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h |
index cb5133ae003e4d89de0f2f376b749977aee715f4..c3154a40c12501a254ad9b77b668a6710fcfba6b 100644 |
--- a/include/core/SkSurface.h |
+++ b/include/core/SkSurface.h |
@@ -10,6 +10,9 @@ |
#include "SkRefCnt.h" |
#include "SkImage.h" |
+#include "SkSurfaceProps.h" |
+ |
+//#define SK_SUPPORT_LEGACY_TEXTRENDERMODE |
class SkCanvas; |
class SkPaint; |
@@ -28,6 +31,8 @@ class SK_API SkSurface : public SkRefCnt { |
public: |
SK_DECLARE_INST_COUNT(SkSurface) |
+ typedef SkSurfaceProps Props; |
+ |
/** |
* Create a new surface, using the specified pixels/rowbytes as its |
* backend. |
@@ -35,7 +40,8 @@ public: |
* If the requested surface cannot be created, or the request is not a |
* supported configuration, NULL will be returned. |
*/ |
- static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t rowBytes); |
+ static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t rowBytes, |
+ const Props* = NULL); |
/** |
* The same as NewRasterDirect, but also accepts a call-back routine, which is invoked |
@@ -43,7 +49,7 @@ public: |
*/ |
static SkSurface* NewRasterDirectReleaseProc(const SkImageInfo&, void* pixels, size_t rowBytes, |
void (*releaseProc)(void* pixels, void* context), |
- void* context); |
+ void* context, const Props* = NULL); |
/** |
* Return a new surface, with the memory for the pixels automatically |
@@ -52,31 +58,17 @@ public: |
* If the requested surface cannot be created, or the request is not a |
* supported configuration, NULL will be returned. |
*/ |
- static SkSurface* NewRaster(const SkImageInfo&); |
+ static SkSurface* NewRaster(const SkImageInfo&, const Props* = NULL); |
/** |
* Helper version of NewRaster. It creates a SkImageInfo with the |
* specified width and height, and populates the rest of info to match |
* pixels in SkPMColor format. |
*/ |
- static SkSurface* NewRasterPMColor(int width, int height) { |
- return NewRaster(SkImageInfo::MakeN32Premul(width, height)); |
+ static SkSurface* NewRasterPMColor(int width, int height, const Props* props = NULL) { |
+ return NewRaster(SkImageInfo::MakeN32Premul(width, height), props); |
} |
- /** |
- * Text rendering modes that can be passed to NewRenderTarget* |
- */ |
- enum TextRenderMode { |
- /** |
- * This will use the standard text rendering method |
- */ |
- kStandard_TextRenderMode, |
- /** |
- * This will use signed distance fields for text rendering when possible |
- */ |
- kDistanceField_TextRenderMode, |
- }; |
- |
enum RenderTargetFlags { |
kNone_RenderTargetFlag = 0x0, |
/* |
@@ -89,18 +81,26 @@ public: |
/** |
* Return a new surface using the specified render target. |
*/ |
- static SkSurface* NewRenderTargetDirect(GrRenderTarget*, |
- TextRenderMode trm = kStandard_TextRenderMode, |
+ static SkSurface* NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProps*, |
RenderTargetFlags flags = kNone_RenderTargetFlag); |
- |
+ |
+ static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { |
+ return NewRenderTargetDirect(target, NULL, kNone_RenderTargetFlag); |
+ } |
+ |
/** |
* Return a new surface whose contents will be drawn to an offscreen |
* render target, allocated by the surface. |
*/ |
- static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0, |
- TextRenderMode trm = kStandard_TextRenderMode, |
+ static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount, |
+ const SkSurfaceProps*, |
RenderTargetFlags flags = kNone_RenderTargetFlag); |
+ static SkSurface* NewRenderTarget(GrContext* gr, const SkImageInfo& info) { |
+ return NewRenderTarget(gr, info, 0, NULL); |
+ } |
+ |
+ |
/** |
* Return a new surface whose contents will be drawn to an offscreen |
* render target, allocated by the surface from the scratch texture pool |
@@ -113,9 +113,38 @@ public: |
* Note: Scratch textures count against the GrContext's cached resource |
* budget. |
*/ |
+ static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount, |
+ const SkSurfaceProps*, |
+ RenderTargetFlags flags = kNone_RenderTargetFlag); |
+ |
+ static SkSurface* NewScratchRenderTarget(GrContext* gr, const SkImageInfo& info) { |
+ return NewScratchRenderTarget(gr, info, 0, NULL); |
+ } |
+ |
+#ifdef SK_SUPPORT_LEGACY_TEXTRENDERMODE |
+ /** |
+ * Text rendering modes that can be passed to NewRenderTarget* |
+ */ |
+ enum TextRenderMode { |
+ /** |
+ * This will use the standard text rendering method |
+ */ |
+ kStandard_TextRenderMode, |
+ /** |
+ * This will use signed distance fields for text rendering when possible |
+ */ |
+ kDistanceField_TextRenderMode, |
+ }; |
+ static SkSurface* NewRenderTargetDirect(GrRenderTarget*, |
+ TextRenderMode trm = kStandard_TextRenderMode, |
+ RenderTargetFlags flags = kNone_RenderTargetFlag); |
+ static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0, |
+ TextRenderMode trm = kStandard_TextRenderMode, |
+ RenderTargetFlags flags = kNone_RenderTargetFlag); |
static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0, |
TextRenderMode trm = kStandard_TextRenderMode, |
RenderTargetFlags flags = kNone_RenderTargetFlag); |
+#endif |
int width() const { return fWidth; } |
int height() const { return fHeight; } |
@@ -204,9 +233,11 @@ public: |
*/ |
const void* peekPixels(SkImageInfo* info, size_t* rowBytes); |
+ const Props& props() const { return fProps; } |
+ |
protected: |
- SkSurface(int width, int height); |
- SkSurface(const SkImageInfo&); |
+ SkSurface(int width, int height, const Props*); |
+ SkSurface(const SkImageInfo&, const Props*); |
// called by subclass if their contents have changed |
void dirtyGenerationID() { |
@@ -214,6 +245,7 @@ protected: |
} |
private: |
+ const Props fProps; |
const int fWidth; |
const int fHeight; |
uint32_t fGenerationID; |