Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: include/core/SkSurface.h

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase (nasty) Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/core/SkSurface.h
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 1871c676f21e56a9a6e0a66018836fcc7c534ade..e0e60ab7fbc20f7cd7459ed4b4873ae56317a65d 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;
@@ -35,7 +38,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 SkSurfaceProps* = NULL);
/**
* The same as NewRasterDirect, but also accepts a call-back routine, which is invoked
@@ -43,7 +47,7 @@ public:
*/
static SkSurface* NewRasterDirectReleaseProc(const SkImageInfo&, void* pixels, size_t rowBytes,
void (*releaseProc)(void* pixels, void* context),
- void* context);
+ void* context, const SkSurfaceProps* = NULL);
/**
* Return a new surface, with the memory for the pixels automatically
@@ -52,45 +56,36 @@ 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 SkSurfaceProps* = 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 SkSurfaceProps* 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,
- };
-
- /**
* Return a new surface using the specified render target.
- * The pixels in the rendertarget are not cleared or otherwised changed when the surface
- * is created.
*/
- static SkSurface* NewRenderTargetDirect(GrRenderTarget*,
- TextRenderMode trm = kStandard_TextRenderMode);
-
+ static SkSurface* NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProps*);
+
+ static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) {
+ return NewRenderTargetDirect(target, NULL);
+ }
+
/**
* 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* = NULL);
+
+ static SkSurface* NewRenderTarget(GrContext* gr, const SkImageInfo& info) {
bsalomon 2014/09/19 17:58:23 Will we get rid of this one?
reed1 2014/09/19 18:04:49 We previously had this variant, with lots of defau
bsalomon 2014/09/19 18:21:05 Personally, I'd rather have fewer factories at the
reed1 2014/09/19 19:16:33 No problem with that, but that will affect existin
bsalomon 2014/09/19 19:25:22 sgtm
+ return NewRenderTarget(gr, info, 0, NULL);
+ }
/**
* Return a new surface whose contents will be drawn to an offscreen
@@ -104,8 +99,33 @@ public:
* Note: Scratch textures count against the GrContext's cached resource
* budget.
*/
- static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0,
- TextRenderMode trm = kStandard_TextRenderMode);
+ static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
+ const SkSurfaceProps*);
+
+ static SkSurface* NewScratchRenderTarget(GrContext* gr, const SkImageInfo& info) {
bsalomon 2014/09/19 17:58:23 and this one?
+ 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);
+ static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
+ TextRenderMode);
+ static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
+ TextRenderMode);
+#endif
int width() const { return fWidth; }
int height() const { return fHeight; }
@@ -194,9 +214,11 @@ public:
*/
const void* peekPixels(SkImageInfo* info, size_t* rowBytes);
+ const SkSurfaceProps& props() const { return fProps; }
+
protected:
- SkSurface(int width, int height);
- SkSurface(const SkImageInfo&);
+ SkSurface(int width, int height, const SkSurfaceProps*);
+ SkSurface(const SkImageInfo&, const SkSurfaceProps*);
// called by subclass if their contents have changed
void dirtyGenerationID() {
@@ -204,9 +226,10 @@ protected:
}
private:
- const int fWidth;
- const int fHeight;
- uint32_t fGenerationID;
+ const SkSurfaceProps fProps;
+ const int fWidth;
+ const int fHeight;
+ uint32_t fGenerationID;
typedef SkRefCnt INHERITED;
};

Powered by Google App Engine
This is Rietveld 408576698