remove redundant GrContext parameter to NewRenderTargetDirect

BUG=skia:
R=bsalomon@google.com

Review URL: https://codereview.chromium.org/151183003

git-svn-id: http://skia.googlecode.com/svn/trunk@13299 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2014-02-04 14:58:30 +00:00
parent 1c9bd55ea3
commit 372b7a4f56
2 changed files with 26 additions and 10 deletions

View File

@ -16,6 +16,8 @@ class SkPaint;
class GrContext; class GrContext;
class GrRenderTarget; class GrRenderTarget;
//#define SK_SUPPORT_LEGACY_NEWRENDERTARGETDIRECT
/** /**
* SkSurface represents the backend/results of drawing to a canvas. For raster * SkSurface represents the backend/results of drawing to a canvas. For raster
* drawing, the surface will be pixels, but (for example) when drawing into * drawing, the surface will be pixels, but (for example) when drawing into
@ -64,11 +66,19 @@ public:
* "replayed" into that canvas. * "replayed" into that canvas.
*/ */
static SkSurface* NewPicture(int width, int height); static SkSurface* NewPicture(int width, int height);
/** /**
* Return a new surface using the specified render target. * Return a new surface using the specified render target.
*/ */
static SkSurface* NewRenderTargetDirect(GrRenderTarget*);
#ifdef SK_SUPPORT_LEGACY_NEWRENDERTARGETDIRECT
/**
* DEPRECATED -- call the single argument version (just rendertarget)
* Return a new surface using the specified render target.
*/
static SkSurface* NewRenderTargetDirect(GrContext*, GrRenderTarget*); static SkSurface* NewRenderTargetDirect(GrContext*, GrRenderTarget*);
#endif
/** /**
* Return a new surface whose contents will be drawn to an offscreen * Return a new surface whose contents will be drawn to an offscreen

View File

@ -15,7 +15,7 @@ public:
SK_DECLARE_INST_COUNT(SkSurface_Gpu) SK_DECLARE_INST_COUNT(SkSurface_Gpu)
SkSurface_Gpu(GrContext*, const SkImageInfo&, int sampleCount); SkSurface_Gpu(GrContext*, const SkImageInfo&, int sampleCount);
SkSurface_Gpu(GrContext*, GrRenderTarget*); SkSurface_Gpu(GrRenderTarget*);
virtual ~SkSurface_Gpu(); virtual ~SkSurface_Gpu();
virtual SkCanvas* onNewCanvas() SK_OVERRIDE; virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
@ -45,9 +45,9 @@ SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, const SkImageInfo& info,
} }
} }
SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, GrRenderTarget* renderTarget) SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget)
: INHERITED(renderTarget->width(), renderTarget->height()) { : INHERITED(renderTarget->width(), renderTarget->height()) {
fDevice = SkNEW_ARGS(SkGpuDevice, (ctx, renderTarget)); fDevice = SkNEW_ARGS(SkGpuDevice, (renderTarget->getContext(), renderTarget));
if (kRGB_565_GrPixelConfig != renderTarget->config()) { if (kRGB_565_GrPixelConfig != renderTarget->config()) {
fDevice->clear(0x0); fDevice->clear(0x0);
@ -102,15 +102,21 @@ void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SkSurface* SkSurface::NewRenderTargetDirect(GrContext* ctx, SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target) {
GrRenderTarget* target) { if (NULL == target) {
if (NULL == ctx || NULL == target) {
return NULL; return NULL;
} }
return SkNEW_ARGS(SkSurface_Gpu, (target));
return SkNEW_ARGS(SkSurface_Gpu, (ctx, target));
} }
#ifdef SK_SUPPORT_LEGACY_NEWRENDERTARGETDIRECT
SkSurface* SkSurface::NewRenderTargetDirect(GrContext* ctx,
GrRenderTarget* target) {
SkASSERT(target->getContext() == ctx);
return SkSurface::NewRenderTargetDirect(target);
}
#endif
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount) { SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount) {
if (NULL == ctx) { if (NULL == ctx) {
return NULL; return NULL;
@ -130,5 +136,5 @@ SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
return NULL; return NULL;
} }
return SkNEW_ARGS(SkSurface_Gpu, (ctx, tex->asRenderTarget())); return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget()));
} }