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

Unified Diff: src/image/SkSurface_Gpu.cpp

Issue 354533004: Begin atlasing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unit test Created 6 years, 6 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: src/image/SkSurface_Gpu.cpp
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index a34b774397b11e9539d5c67264fc24bbe1d4b426..550e197fe50e653b3dc75cc8ce6f99658557a5bf 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -14,7 +14,7 @@ class SkSurface_Gpu : public SkSurface_Base {
public:
SK_DECLARE_INST_COUNT(SkSurface_Gpu)
- SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm);
+ SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm, bool clear);
virtual ~SkSurface_Gpu();
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
@@ -33,14 +33,15 @@ private:
///////////////////////////////////////////////////////////////////////////////
-SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm)
+SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm,
+ bool clear)
: INHERITED(renderTarget->width(), renderTarget->height()) {
int flags = 0;
flags |= cached ? SkGpuDevice::kCached_Flag : 0;
flags |= (kDistanceField_TextRenderMode == trm) ? SkGpuDevice::kDFFonts_Flag : 0;
fDevice = SkGpuDevice::Create(renderTarget, flags);
- if (kRGB_565_GrPixelConfig != renderTarget->config()) {
+ if (kRGB_565_GrPixelConfig != renderTarget->config() && clear) {
fDevice->clear(0x0);
}
}
@@ -101,11 +102,11 @@ void SkSurface_Gpu::onDiscard() {
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm) {
+SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm, bool clear) {
if (NULL == target) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm));
+ return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, clear));
}
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount,
@@ -126,7 +127,7 @@ SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm));
+ return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, true));
}
SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info,
@@ -148,5 +149,5 @@ SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm));
+ return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, true));
}

Powered by Google App Engine
This is Rietveld 408576698