2018-05-09 07:08:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrCCClipPath_DEFINED
|
|
|
|
#define GrCCClipPath_DEFINED
|
|
|
|
|
|
|
|
#include "GrTextureProxy.h"
|
|
|
|
#include "SkPath.h"
|
|
|
|
|
2018-06-13 21:28:19 +00:00
|
|
|
struct GrCCPerFlushResourceSpecs;
|
2018-05-09 07:08:38 +00:00
|
|
|
class GrCCAtlas;
|
|
|
|
class GrCCPerFlushResources;
|
|
|
|
class GrOnFlushResourceProvider;
|
|
|
|
class GrProxyProvider;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* These are keyed by SkPath generation ID, and store which device-space paths are accessed and
|
|
|
|
* where by clip FPs in a given opList. A single GrCCClipPath can be referenced by multiple FPs. At
|
|
|
|
* flush time their coverage count masks are packed into atlas(es) alongside normal DrawPathOps.
|
|
|
|
*/
|
|
|
|
class GrCCClipPath {
|
|
|
|
public:
|
|
|
|
GrCCClipPath() = default;
|
|
|
|
GrCCClipPath(const GrCCClipPath&) = delete;
|
|
|
|
|
|
|
|
~GrCCClipPath() {
|
2018-09-14 06:44:22 +00:00
|
|
|
// Ensure no clip FP exists with a dangling pointer back into this class. This works because
|
|
|
|
// a clip FP will have a ref on the proxy if it exists.
|
|
|
|
//
|
|
|
|
// This assert also guarantees there won't be a lazy proxy callback with a dangling pointer
|
|
|
|
// back into this class, since no proxy will exist after we destruct, if the assert passes.
|
2018-05-09 07:08:38 +00:00
|
|
|
SkASSERT(!fAtlasLazyProxy || fAtlasLazyProxy->isUnique_debugOnly());
|
|
|
|
}
|
|
|
|
|
2018-05-28 17:35:39 +00:00
|
|
|
bool isInitialized() const { return fAtlasLazyProxy != nullptr; }
|
2018-06-16 23:22:59 +00:00
|
|
|
void init(const SkPath& deviceSpacePath, const SkIRect& accessRect, int rtWidth, int rtHeight,
|
|
|
|
const GrCaps&);
|
2018-05-09 07:08:38 +00:00
|
|
|
|
|
|
|
void addAccess(const SkIRect& accessRect) {
|
|
|
|
SkASSERT(this->isInitialized());
|
|
|
|
fAccessRect.join(accessRect);
|
|
|
|
}
|
|
|
|
GrTextureProxy* atlasLazyProxy() const {
|
|
|
|
SkASSERT(this->isInitialized());
|
|
|
|
return fAtlasLazyProxy.get();
|
|
|
|
}
|
|
|
|
const SkPath& deviceSpacePath() const {
|
|
|
|
SkASSERT(this->isInitialized());
|
|
|
|
return fDeviceSpacePath;
|
|
|
|
}
|
|
|
|
const SkIRect& pathDevIBounds() const {
|
|
|
|
SkASSERT(this->isInitialized());
|
|
|
|
return fPathDevIBounds;
|
|
|
|
}
|
|
|
|
|
2018-06-13 21:28:19 +00:00
|
|
|
void accountForOwnPath(GrCCPerFlushResourceSpecs*) const;
|
2018-05-23 23:11:09 +00:00
|
|
|
void renderPathInAtlas(GrCCPerFlushResources*, GrOnFlushResourceProvider*);
|
2018-05-09 07:08:38 +00:00
|
|
|
|
|
|
|
const SkVector& atlasScale() const { SkASSERT(fHasAtlasTransform); return fAtlasScale; }
|
|
|
|
const SkVector& atlasTranslate() const { SkASSERT(fHasAtlasTransform); return fAtlasTranslate; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
sk_sp<GrTextureProxy> fAtlasLazyProxy;
|
|
|
|
SkPath fDeviceSpacePath;
|
|
|
|
SkIRect fPathDevIBounds;
|
|
|
|
SkIRect fAccessRect;
|
|
|
|
|
|
|
|
const GrCCAtlas* fAtlas = nullptr;
|
2018-06-14 16:14:50 +00:00
|
|
|
SkIVector fDevToAtlasOffset; // Translation from device space to location in atlas.
|
2018-05-09 07:08:38 +00:00
|
|
|
SkDEBUGCODE(bool fHasAtlas = false);
|
|
|
|
|
|
|
|
SkVector fAtlasScale;
|
|
|
|
SkVector fAtlasTranslate;
|
|
|
|
SkDEBUGCODE(bool fHasAtlasTransform = false);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|