ccpr: Initialize the atlas size more intelligently
Rather than always starting the atlas at 1024 x 1024, begin with the
first pow2 dimensions whose area is theoretically large enough to
contain the pending paths.
Bug: skia:
Change-Id: I263e77ff6a697e865f6b3b62b9df7002225f9544
Reviewed-on: https://skia-review.googlesource.com/133660
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ccpr/GrCCPerFlushResources.h b/src/gpu/ccpr/GrCCPerFlushResources.h
index bc6b6ed..14e3a1c 100644
--- a/src/gpu/ccpr/GrCCPerFlushResources.h
+++ b/src/gpu/ccpr/GrCCPerFlushResources.h
@@ -15,23 +15,35 @@
#include "ccpr/GrCCPathProcessor.h"
/**
+ * This struct encapsulates the minimum and desired requirements for the GPU resources required by
+ * CCPR in a given flush.
+ */
+struct GrCCPerFlushResourceSpecs {
+ int fNumRenderedPaths = 0;
+ int fNumClipPaths = 0;
+ GrCCPathParser::PathStats fParsingPathStats;
+ GrCCAtlas::Specs fAtlasSpecs;
+
+ bool isEmpty() const { return 0 == fNumRenderedPaths + fNumClipPaths; }
+};
+
+/**
* This class wraps all the GPU resources that CCPR builds at flush time. It is allocated in CCPR's
* preFlush() method, and referenced by all the GrCCPerOpListPaths objects that are being flushed.
* It is deleted in postFlush() once all the flushing GrCCPerOpListPaths objects are deleted.
*/
class GrCCPerFlushResources : public GrNonAtomicRef<GrCCPerFlushResources> {
public:
- GrCCPerFlushResources(GrOnFlushResourceProvider*, int numPathDraws, int numClipPaths,
- const GrCCPathParser::PathStats&);
+ GrCCPerFlushResources(GrOnFlushResourceProvider*, const GrCCPerFlushResourceSpecs&);
bool isMapped() const { return SkToBool(fPathInstanceData); }
- GrCCAtlas* renderPathInAtlas(const GrCaps&, const SkIRect& clipIBounds, const SkMatrix&,
- const SkPath&, SkRect* devBounds, SkRect* devBounds45,
- int16_t* offsetX, int16_t* offsetY);
- GrCCAtlas* renderDeviceSpacePathInAtlas(const GrCaps&, const SkIRect& clipIBounds,
- const SkPath& devPath, const SkIRect& devPathIBounds,
- int16_t* atlasOffsetX, int16_t* atlasOffsetY);
+ GrCCAtlas* renderPathInAtlas(const SkIRect& clipIBounds, const SkMatrix&, const SkPath&,
+ SkRect* devBounds, SkRect* devBounds45, int16_t* offsetX,
+ int16_t* offsetY);
+ GrCCAtlas* renderDeviceSpacePathInAtlas(const SkIRect& clipIBounds, const SkPath& devPath,
+ const SkIRect& devPathIBounds, int16_t* atlasOffsetX,
+ int16_t* atlasOffsetY);
GrCCPathProcessor::Instance& appendDrawPathInstance() {
SkASSERT(this->isMapped());
@@ -47,11 +59,11 @@
GrBuffer* instanceBuffer() const { SkASSERT(!this->isMapped()); return fInstanceBuffer.get(); }
private:
- GrCCAtlas* placeParsedPathInAtlas(const GrCaps&, const SkIRect& clipIBounds,
- const SkIRect& pathIBounds, int16_t* atlasOffsetX,
- int16_t* atlasOffsetY);
+ GrCCAtlas* placeParsedPathInAtlas(const SkIRect& clipIBounds, const SkIRect& pathIBounds,
+ int16_t* atlasOffsetX, int16_t* atlasOffsetY);
const sk_sp<GrCCPathParser> fPathParser;
+ const GrCCAtlas::Specs fAtlasSpecs;
sk_sp<const GrBuffer> fIndexBuffer;
sk_sp<const GrBuffer> fVertexBuffer;