kDistanceField_TextRenderMode,
};
- enum RenderTargetFlags {
- kNone_RenderTargetFlag = 0x0,
- /*
- * By default a RenderTarget-based surface will be cleared on creation.
- * Pass in this flag to prevent the clear from happening.
- */
- kDontClear_RenderTargetFlag = 0x01,
- };
-
/**
* 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,
- RenderTargetFlags flags = kNone_RenderTargetFlag);
+ TextRenderMode trm = kStandard_TextRenderMode);
/**
* 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,
- RenderTargetFlags flags = kNone_RenderTargetFlag);
+ TextRenderMode trm = kStandard_TextRenderMode);
/**
* Return a new surface whose contents will be drawn to an offscreen
* budget.
*/
static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0,
- TextRenderMode trm = kStandard_TextRenderMode,
- RenderTargetFlags flags = kNone_RenderTargetFlag);
+ TextRenderMode trm = kStandard_TextRenderMode);
int width() const { return fWidth; }
int height() const { return fHeight; }
// All the atlased layers are rendered into the same GrTexture
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
atlased[0]->texture()->asRenderTarget(),
- SkSurface::kStandard_TextRenderMode,
- SkSurface::kDontClear_RenderTargetFlag));
+ SkSurface::kStandard_TextRenderMode));
SkCanvas* atlasCanvas = surface->getCanvas();
// Each non-atlased layer has its own GrTexture
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
layer->texture()->asRenderTarget(),
- SkSurface::kStandard_TextRenderMode,
- SkSurface::kDontClear_RenderTargetFlag));
+ SkSurface::kStandard_TextRenderMode));
SkCanvas* layerCanvas = surface->getCanvas();
public:
SK_DECLARE_INST_COUNT(SkSurface_Gpu)
- SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm,
- SkSurface::RenderTargetFlags flags);
+ SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm, bool doClear);
virtual ~SkSurface_Gpu();
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
///////////////////////////////////////////////////////////////////////////////
SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm,
- SkSurface::RenderTargetFlags flags)
+ bool doClear)
: INHERITED(renderTarget->width(), renderTarget->height()) {
int deviceFlags = 0;
deviceFlags |= cached ? SkGpuDevice::kCached_Flag : 0;
deviceFlags |= (kDistanceField_TextRenderMode == trm) ? SkGpuDevice::kDFFonts_Flag : 0;
fDevice = SkGpuDevice::Create(renderTarget, deviceFlags);
- if (kRGB_565_GrPixelConfig != renderTarget->config() &&
- !(flags & kDontClear_RenderTargetFlag)) {
+ if (kRGB_565_GrPixelConfig != renderTarget->config() && doClear) {
fDevice->clear(0x0);
}
}
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm,
- RenderTargetFlags flags) {
+SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm) {
if (NULL == target) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, flags));
+ return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, false));
}
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount,
- TextRenderMode trm, RenderTargetFlags flags) {
+ TextRenderMode trm) {
if (NULL == ctx) {
return NULL;
}
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, flags));
+ return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, true));
}
SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info,
- int sampleCount, TextRenderMode trm,
- RenderTargetFlags flags) {
+ int sampleCount, TextRenderMode trm) {
if (NULL == ctx) {
return NULL;
}
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, flags));
+ return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, true));
}