if (UseSWOnlyPath(this->getContext(), pipelineBuilder, rt, clipToMaskOffset, elements)) {
// The clip geometry is complex enough that it will be more efficient to create it
// entirely in software
- result = CreateSoftwareClipMask(this->getContext(),
+ result = CreateSoftwareClipMask(this->getContext()->textureProvider(),
genID,
initialState,
elements,
////////////////////////////////////////////////////////////////////////////////
sk_sp<GrTexture> GrClipMaskManager::CreateSoftwareClipMask(
- GrContext* context,
+ GrTextureProvider* texProvider,
int32_t elementsGenID,
GrReducedClip::InitialState initialState,
const GrReducedClip::ElementList& elements,
const SkIRect& clipSpaceIBounds) {
GrUniqueKey key;
GetClipMaskKey(elementsGenID, clipSpaceIBounds, &key);
- GrResourceProvider* resourceProvider = context->resourceProvider();
- if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key)) {
+ if (GrTexture* texture = texProvider->findAndRefTextureByUniqueKey(key)) {
return sk_sp<GrTexture>(texture);
}
// the top left corner of the resulting rect to the top left of the texture.
SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpaceIBounds.height());
- GrSWMaskHelper helper(context);
+ GrSWMaskHelper helper(texProvider);
// Set the matrix so that rendered clip elements are transformed to mask space from clip
// space.
desc.fHeight = clipSpaceIBounds.height();
desc.fConfig = kAlpha_8_GrPixelConfig;
- sk_sp<GrTexture> result(context->resourceProvider()->createApproxTexture(desc, 0));
+ sk_sp<GrTexture> result(texProvider->createApproxTexture(desc));
if (!result) {
return nullptr;
}
#include "GrPipelineBuilder.h"
#include "GrReducedClip.h"
-#include "GrTexture.h"
#include "SkClipStack.h"
-#include "SkDeque.h"
-#include "SkPath.h"
-#include "SkRefCnt.h"
-#include "SkTLList.h"
#include "SkTypes.h"
class GrAppliedClip;
class GrPathRendererChain;
class GrResourceProvider;
class GrTexture;
-class SkPath;
+class GrTextureProvider;
/**
* The clip mask creator handles the generation of the clip mask. If anti
const SkIRect& clipSpaceIBounds);
// Similar to createAlphaClipMask but it rasterizes in SW and uploads to the result texture.
- static sk_sp<GrTexture> CreateSoftwareClipMask(GrContext*,
+ static sk_sp<GrTexture> CreateSoftwareClipMask(GrTextureProvider*,
int32_t elementsGenID,
GrReducedClip::InitialState initialState,
const GrReducedClip::ElementList& elements,
GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport);
if (!pr && allowSW) {
if (!fSoftwarePathRenderer) {
- fSoftwarePathRenderer = new GrSoftwarePathRenderer(fContext);
+ fSoftwarePathRenderer = new GrSoftwarePathRenderer(fContext->textureProvider());
}
pr = fSoftwarePathRenderer;
}
desc.fHeight = fPixels.height();
desc.fConfig = kAlpha_8_GrPixelConfig;
- return fContext->textureProvider()->createApproxTexture(desc);
+ return fTexProvider->createApproxTexture(desc);
}
/**
* and uploads the result to a scratch texture. Returns the resulting
* texture on success; nullptr on failure.
*/
-GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
+GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrTextureProvider* texProvider,
const SkPath& path,
const GrStyle& style,
const SkIRect& resultBounds,
bool antiAlias,
const SkMatrix* matrix) {
- GrSWMaskHelper helper(context);
+ GrSWMaskHelper helper(texProvider);
if (!helper.init(resultBounds, matrix)) {
return nullptr;
#include "SkTypes.h"
class GrClip;
-class GrContext;
+class GrTextureProvider;
class GrTexture;
class SkPath;
class SkStrokeRec;
*/
class GrSWMaskHelper : SkNoncopyable {
public:
- GrSWMaskHelper(GrContext* context) : fContext(context) { }
+ GrSWMaskHelper(GrTextureProvider* texProvider) : fTexProvider(texProvider) { }
// set up the internal state in preparation for draws. Since many masks
// may be accumulated in the helper during creation, "resultBounds"
// Canonical usage utility that draws a single path and uploads it
// to the GPU. The result is returned.
- static GrTexture* DrawPathMaskToTexture(GrContext* context,
+ static GrTexture* DrawPathMaskToTexture(GrTextureProvider*,
const SkPath& path,
const GrStyle& style,
const SkIRect& resultBounds,
// result (i.e., right size & format)
GrTexture* createTexture();
- GrContext* fContext;
- SkMatrix fMatrix;
+ GrTextureProvider* fTexProvider;
+ SkMatrix fMatrix;
SkAutoPixmapStorage fPixels;
- SkDraw fDraw;
- SkRasterClip fRasterClip;
+ SkDraw fDraw;
+ SkRasterClip fRasterClip;
typedef SkNoncopyable INHERITED;
};
*/
#include "GrSoftwarePathRenderer.h"
-#include "GrContext.h"
#include "GrSWMaskHelper.h"
+#include "GrTextureProvider.h"
#include "batches/GrRectBatchFactory.h"
////////////////////////////////////////////////////////////////////////////////
bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
- return SkToBool(fContext);
+ return SkToBool(fTexProvider);
}
namespace {
// gets device coord bounds of path (not considering the fill) and clip. The
// path bounds will be a subset of the clip bounds. returns false if
// path bounds would be empty.
-bool get_path_and_clip_bounds(const GrPipelineBuilder* pipelineBuilder,
+bool get_path_and_clip_bounds(int width, int height,
const GrClip& clip,
const SkPath& path,
const SkMatrix& matrix,
SkIRect* devPathBounds,
SkIRect* devClipBounds) {
// compute bounds as intersection of rt size, clip, and path
- const GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
- if (nullptr == rt) {
- return false;
- }
-
- clip.getConservativeBounds(rt->width(), rt->height(), devClipBounds);
+ clip.getConservativeBounds(width, height, devClipBounds);
if (devClipBounds->isEmpty()) {
- *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height());
+ *devPathBounds = SkIRect::MakeWH(width, height);
return false;
}
// return true on success; false on failure
bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrSoftwarePathRenderer::onDrawPath");
- if (nullptr == fContext) {
+ if (!fTexProvider || !args.fPipelineBuilder->getRenderTarget()) {
return false;
}
+ const int width = args.fPipelineBuilder->getRenderTarget()->width();
+ const int height = args.fPipelineBuilder->getRenderTarget()->height();
+
SkIRect devPathBounds, devClipBounds;
- if (!get_path_and_clip_bounds(args.fPipelineBuilder, *args.fClip, *args.fPath,
+ if (!get_path_and_clip_bounds(width, height, *args.fClip, *args.fPath,
*args.fViewMatrix, &devPathBounds, &devClipBounds)) {
if (args.fPath->isInverseFillType()) {
draw_around_inv_path(args.fTarget, args.fPipelineBuilder, *args.fClip, args.fColor,
}
SkAutoTUnref<GrTexture> texture(
- GrSWMaskHelper::DrawPathMaskToTexture(fContext, *args.fPath, *args.fStyle,
+ GrSWMaskHelper::DrawPathMaskToTexture(fTexProvider, *args.fPath, *args.fStyle,
devPathBounds,
args.fAntiAlias, args.fViewMatrix));
if (nullptr == texture) {
#include "GrPathRenderer.h"
-class GrContext;
+class GrTextureProvider;
/**
* This class uses the software side to render a path to an SkBitmap and
*/
class GrSoftwarePathRenderer : public GrPathRenderer {
public:
- GrSoftwarePathRenderer(GrContext* context)
- : fContext(context) {
- }
+ GrSoftwarePathRenderer(GrTextureProvider* texProvider) : fTexProvider(texProvider) { }
+
private:
StencilSupport onGetStencilSupport(const SkPath&) const override {
return GrPathRenderer::kNoSupport_StencilSupport;
bool onDrawPath(const DrawPathArgs&) override;
private:
- GrContext* fContext;
+ GrTextureProvider* fTexProvider;
typedef GrPathRenderer INHERITED;
};