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

Unified Diff: src/gpu/GrStencilAndCoverPathRenderer.cpp

Issue 1155593002: Move GrPath(Range) creation to ResourceProvider. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « src/gpu/GrStencilAndCoverPathRenderer.h ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrStencilAndCoverPathRenderer.cpp
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index 97b20773a7e0e6797d1e7f60d38937fe1d749c86..cfab836297a7b8de974c569eed33c3ed38801753 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -10,10 +10,8 @@
#include "GrStencilAndCoverPathRenderer.h"
#include "GrContext.h"
#include "GrDrawTargetCaps.h"
-#include "GrGpu.h"
#include "GrPath.h"
#include "GrRenderTarget.h"
-#include "GrRenderTargetPriv.h"
#include "GrResourceProvider.h"
#include "GrStrokeInfo.h"
@@ -33,24 +31,17 @@ static GrPathRendering::FillType convert_skpath_filltype(SkPath::FillType fill)
}
}
-GrPathRenderer* GrStencilAndCoverPathRenderer::Create(GrContext* context) {
- SkASSERT(context);
- SkASSERT(context->getGpu());
- if (context->getGpu()->caps()->shaderCaps()->pathRenderingSupport()) {
- return SkNEW_ARGS(GrStencilAndCoverPathRenderer, (context->getGpu()));
+GrPathRenderer* GrStencilAndCoverPathRenderer::Create(GrResourceProvider* resourceProvider,
+ const GrCaps& caps) {
+ if (caps.shaderCaps()->pathRenderingSupport()) {
+ return SkNEW_ARGS(GrStencilAndCoverPathRenderer, (resourceProvider));
} else {
return NULL;
}
}
-GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrGpu* gpu) {
- SkASSERT(gpu->caps()->shaderCaps()->pathRenderingSupport());
- fGpu = gpu;
- gpu->ref();
-}
-
-GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() {
- fGpu->unref();
+GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider* resourceProvider)
+ : fResourceProvider(resourceProvider) {
}
bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target,
@@ -72,17 +63,17 @@ GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*,
return GrPathRenderer::kStencilOnly_StencilSupport;
}
-static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo& stroke) {
- GrContext* ctx = gpu->getContext();
+static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const SkPath& skPath,
+ const GrStrokeInfo& stroke) {
GrUniqueKey key;
bool isVolatile;
GrPath::ComputeKey(skPath, stroke, &key, &isVolatile);
SkAutoTUnref<GrPath> path(
- static_cast<GrPath*>(ctx->resourceProvider()->findAndRefResourceByUniqueKey(key)));
- if (NULL == path) {
- path.reset(gpu->pathRendering()->createPath(skPath, stroke));
+ static_cast<GrPath*>(resourceProvider->findAndRefResourceByUniqueKey(key)));
+ if (!path) {
+ path.reset(resourceProvider->createPath(skPath, stroke));
if (!isVolatile) {
- ctx->resourceProvider()->assignUniqueKeyToResource(key, path);
+ resourceProvider->assignUniqueKeyToResource(key, path);
}
} else {
SkASSERT(path->isEqualTo(skPath, stroke));
@@ -97,7 +88,7 @@ void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target,
const GrStrokeInfo& stroke) {
SkASSERT(!path.isInverseFillType());
SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, viewMatrix));
- SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
+ SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, stroke));
target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
}
@@ -112,7 +103,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
SkASSERT(!stroke.isHairlineStyle());
SkASSERT(pipelineBuilder->getStencil().isDisabled());
- SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
+ SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, stroke));
if (path.isInverseFillType()) {
GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass,
« no previous file with comments | « src/gpu/GrStencilAndCoverPathRenderer.h ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698