aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-06-29 15:08:31 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-29 15:08:31 -0700
commit55e61f0ef4e5c8c34ac107deaadc9b4ffef3111b (patch)
treea4338959e2934648d4ef1793017c96a786bac632 /src/image
parentd92f5b814d01c474a0fb52e32e10a997b2c9b5bf (diff)
Begin atlasing
This CL makes it possible for pulled-forward-layers to be atlased. It currently has a couple glaring limitations (which is why it is disabled): 1) the atlased layers cannot be purged nor aged out 2) the texture backing the atlas is not pulled from (or returned to) the resource cache #1 is on hold until we have a recycling rectanizer A separate major limitation (the non-atlased layers aren't cached) is blocked until we can transmute entries in the resource cache from scratch to non-scratch while potentially preserving their contents. R=bsalomon@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/354533004
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkSurface_Gpu.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index a34b774397..fab130cdde 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -14,7 +14,8 @@ 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,
+ SkSurface::RenderTargetFlags flags);
virtual ~SkSurface_Gpu();
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
@@ -33,14 +34,16 @@ private:
///////////////////////////////////////////////////////////////////////////////
-SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm)
+SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm,
+ SkSurface::RenderTargetFlags flags)
: 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);
+ 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()) {
+ if (kRGB_565_GrPixelConfig != renderTarget->config() &&
+ !(flags & kDontClear_RenderTargetFlag)) {
fDevice->clear(0x0);
}
}
@@ -101,15 +104,16 @@ void SkSurface_Gpu::onDiscard() {
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm) {
+SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm,
+ RenderTargetFlags flags) {
if (NULL == target) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm));
+ return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, flags));
}
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount,
- TextRenderMode trm) {
+ TextRenderMode trm, RenderTargetFlags flags) {
if (NULL == ctx) {
return NULL;
}
@@ -126,11 +130,12 @@ 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, flags));
}
SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info,
- int sampleCount, TextRenderMode trm) {
+ int sampleCount, TextRenderMode trm,
+ RenderTargetFlags flags) {
if (NULL == ctx) {
return NULL;
}
@@ -148,5 +153,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, flags));
}