From 91a3e52552c15751aea09b7a8a896e4edd09d42e Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Fri, 23 Jun 2017 10:58:19 -0400 Subject: Move mock gpu and caps, add Gr prefix, and create via GrContext::Create Change-Id: I02427839f78372e337ed717b071c6baaa8ba4450 Reviewed-on: https://skia-review.googlesource.com/20622 Reviewed-by: Greg Daniel Commit-Queue: Brian Salomon --- src/gpu/GrContext.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/gpu/GrContext.cpp') diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index b0d40f6668..405668d4c4 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -53,14 +53,12 @@ GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext, const GrContextOptions& options) { - GrContext* context = new GrContext; + sk_sp context(new GrContext); - if (context->init(backend, backendContext, options)) { - return context; - } else { - context->unref(); + if (!context->init(backend, backendContext, options)) { return nullptr; } + return context.release(); } static int32_t gNextID = 1; @@ -91,12 +89,6 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext, if (!fGpu) { return false; } - this->initCommon(options); - return true; -} - -void GrContext::initCommon(const GrContextOptions& options) { - ASSERT_SINGLE_OWNER fCaps = SkRef(fGpu->caps()); fResourceCache = new GrResourceCache(fCaps, fUniqueID); @@ -113,6 +105,8 @@ void GrContext::initCommon(const GrContextOptions& options) { fAtlasGlyphCache = new GrAtlasGlyphCache(this, options.fGlyphCacheTextureMaximumBytes); fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this)); + + return true; } GrContext::~GrContext() { -- cgit v1.2.3