skia2/tests/GrCCPRTest.cpp

911 lines
38 KiB
C++
Raw Normal View History

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "include/core/SkTypes.h"
#include "tests/Test.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "src/core/SkPathPriv.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrDrawingManager.h"
#include "src/gpu/GrPaint.h"
#include "src/gpu/GrPathRenderer.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrRenderTargetContextPriv.h"
Reland "Move GrGpuResource GrSurface and GrTexture into src." This reverts commit f6ed96d1c23b79130ca7344c984b07ef9d94fb7b. Reason for revert: google3 change landed Original change's description: > Revert "Move GrGpuResource GrSurface and GrTexture into src." > > This reverts commit e5a06ce678aad7640411f99f70f220f82ad49908. > > Reason for revert: Need to make change in google3 first > > Original change's description: > > Move GrGpuResource GrSurface and GrTexture into src. > > > > Must land https://chromium-review.googlesource.com/c/chromium/src/+/2087980 > > before this can land. > > > > Bug: skia:7966 > > Change-Id: I60bbb1765bfbb2c96b2bc0c9826b6b9d57eb2a03 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275077 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com > > Change-Id: Id39e0a351e49a87209de88a6ad9fadb0219db72c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:7966 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275216 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com Change-Id: I746ce739cb084cefc46f9dab24ef773e7c3cc621 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7966 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275436 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-03-05 19:14:18 +00:00
#include "src/gpu/GrTexture.h"
#include "src/gpu/ccpr/GrCCPathCache.h"
#include "src/gpu/ccpr/GrCoverageCountingPathRenderer.h"
Reland "Rename GrShape to GrStyledShape" This reverts commit 73b86c1ade1c002cfa4da66c33c25514737e2416. Reason for revert: wasn't the problem, relanding Original change's description: > Revert "Rename GrShape to GrStyledShape" > > This reverts commit f3f08af010eebdb9c1501bdf1b3d8e715298b05f. > > Reason for revert: maybe this is breaking the ios perf bot; it is the first CL that caused the bot to fail, but I can't really say why this would break them. > > Original change's description: > > Rename GrShape to GrStyledShape > > > > Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036 > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Change-Id: I2e5adbfc820811fbbde9cb57af28f86a7ba40bd9 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284231 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Ifdd52f8bacb5d66a7bf58efd328675c4c443ac8a No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284376 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-17 20:21:37 +00:00
#include "src/gpu/geometry/GrStyledShape.h"
#include "tools/ToolUtils.h"
#include <cmath>
static constexpr int kCanvasSize = 100;
enum class DoCoverageCount { kNo = false, kYes };
enum class DoStroke { kNo = false, kYes };
class CCPRClip : public GrClip {
public:
CCPRClip(GrCoverageCountingPathRenderer* ccpr, const SkPath& path) : fCCPR(ccpr), fPath(path) {}
private:
SkIRect getConservativeBounds() const final { return fPath.getBounds().roundOut(); }
Effect apply(GrRecordingContext* context, GrRenderTargetContext* rtc, GrAAType,
Reland "Simplify GrClip API" This is a reland of 9716414e93f7b279e547595fab08b68235c4b2be Original change's description: > Simplify GrClip API > > Removes quickContains(SkRect), quickContains(SkRRect), and isRRect(). > Replaces these three functions with preApply() that conservatively > determines the clip effect up to a single rrect intersection. The major > motivation for this is the new GrClipStack implementation. preApply() > and apply() will be able to reuse much more code compared to separating > the preApply functionality across the older three functions that were > removed. Additionally, preApply is able to convey more information for > less work, since it can usually determine being skipped or unclipped while > determining if the clip is a single rrect. > > As part of using this API, the attemptQuadOptimiziation and the equivalent > rrect optimization are overhauled. Hopefully legibility is improved, and > the rrect case is now applied outside of the android framework (but with > tighter AA requirements). > > Bug: skia:10205 > Change-Id: I33249dd75a28a611495f87b211cb7ec74ebb7ba4 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298506 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Reviewed-by: Chris Dalton <csmartdalton@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> Bug: skia:10205, 10456 Change-Id: I500eeda36ea50e95eb8cb658b36aa2373d5166c0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298823 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-06-30 15:12:46 +00:00
bool hasUserStencilSettings, GrAppliedClip* out,
SkRect* bounds) const override {
out->addCoverageFP(fCCPR->makeClipProcessor(/*inputFP=*/nullptr,
rtc->priv().testingOnly_getOpsTaskID(), fPath,
SkIRect::MakeWH(rtc->width(), rtc->height()),
*context->priv().caps()));
Reland "Simplify GrClip API" This is a reland of 9716414e93f7b279e547595fab08b68235c4b2be Original change's description: > Simplify GrClip API > > Removes quickContains(SkRect), quickContains(SkRRect), and isRRect(). > Replaces these three functions with preApply() that conservatively > determines the clip effect up to a single rrect intersection. The major > motivation for this is the new GrClipStack implementation. preApply() > and apply() will be able to reuse much more code compared to separating > the preApply functionality across the older three functions that were > removed. Additionally, preApply is able to convey more information for > less work, since it can usually determine being skipped or unclipped while > determining if the clip is a single rrect. > > As part of using this API, the attemptQuadOptimiziation and the equivalent > rrect optimization are overhauled. Hopefully legibility is improved, and > the rrect case is now applied outside of the android framework (but with > tighter AA requirements). > > Bug: skia:10205 > Change-Id: I33249dd75a28a611495f87b211cb7ec74ebb7ba4 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298506 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Reviewed-by: Chris Dalton <csmartdalton@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> Bug: skia:10205, 10456 Change-Id: I500eeda36ea50e95eb8cb658b36aa2373d5166c0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298823 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-06-30 15:12:46 +00:00
return Effect::kClipped;
}
GrCoverageCountingPathRenderer* const fCCPR;
const SkPath fPath;
};
class CCPRPathDrawer {
public:
CCPRPathDrawer(sk_sp<GrDirectContext> dContext, skiatest::Reporter* reporter, DoStroke doStroke)
: fDContext(dContext)
, fCCPR(fDContext->priv().drawingManager()->getCoverageCountingPathRenderer())
, fRTC(GrRenderTargetContext::Make(
fDContext.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kCanvasSize, kCanvasSize}))
, fDoStroke(DoStroke::kYes == doStroke) {
if (!fCCPR) {
ERRORF(reporter, "ccpr not enabled in GrDirectContext for ccpr tests");
}
if (!fRTC) {
ERRORF(reporter, "failed to create GrRenderTargetContext for ccpr tests");
}
}
GrDirectContext* dContext() const { return fDContext.get(); }
GrCoverageCountingPathRenderer* ccpr() const { return fCCPR; }
bool valid() const { return fCCPR && fRTC; }
Reland "Simplify GrRTC::clean APIs" This reverts commit 4730f29993783fc9e96e45098d7e708fe08f1f26. Reason for revert: Fix WIP Original change's description: > Revert "Simplify GrRTC::clean APIs" > > This reverts commit 6cbd7c2e57af9c499f7e99feb215b890fdd3a10a. > > Reason for revert: mac/generated files failures > > Original change's description: > > Simplify GrRTC::clean APIs > > > > The CanClearFullscreen enum type is removed. Most usages of clear() had > > kYes because a null scissor rect was provided, or had kNo because the > > scissor was really critical to the behavior. A few places did provide a > > scissor and kYes (e.g. for initializing the target). > > > > To simplify this, the public GrRTC has two variants of clear(). One with > > only a color (for fullscreen clears), and one with a rect for partial > > clears. The private API also adds a clearAtLeast() function that replaces > > the several cases where we'd have a scissor but could expand to fullscreen. > > > > I find the current control flow in internalClear() to be hard to > > follow (albeit I was the one to make it that way...), but later CLs > > will improve it. > > > > Bug: skia:10205 > > Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com > > Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10205 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> # Not skipping CQ checks because this is a reland. Bug: skia:10205 Change-Id: Id5db153d7c2500279cca8478818b66f67a53e143 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291844 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-26 20:57:38 +00:00
void clear() const { fRTC->clear(SK_PMColor4fTRANSPARENT); }
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
void destroyGrContext() {
SkASSERT(fDContext->unique());
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
fRTC.reset();
fCCPR = nullptr;
fDContext.reset();
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
}
void drawPath(const SkPath& path, const SkMatrix& matrix = SkMatrix::I()) const {
SkASSERT(this->valid());
GrPaint paint;
paint.setColor4f({ 0, 1, 0, 1 });
SkIRect clipBounds = SkIRect::MakeWH(kCanvasSize, kCanvasSize);
Reland "Rename GrShape to GrStyledShape" This reverts commit 73b86c1ade1c002cfa4da66c33c25514737e2416. Reason for revert: wasn't the problem, relanding Original change's description: > Revert "Rename GrShape to GrStyledShape" > > This reverts commit f3f08af010eebdb9c1501bdf1b3d8e715298b05f. > > Reason for revert: maybe this is breaking the ios perf bot; it is the first CL that caused the bot to fail, but I can't really say why this would break them. > > Original change's description: > > Rename GrShape to GrStyledShape > > > > Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036 > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Change-Id: I2e5adbfc820811fbbde9cb57af28f86a7ba40bd9 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284231 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Ifdd52f8bacb5d66a7bf58efd328675c4c443ac8a No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284376 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-17 20:21:37 +00:00
GrStyledShape shape;
if (!fDoStroke) {
Reland "Rename GrShape to GrStyledShape" This reverts commit 73b86c1ade1c002cfa4da66c33c25514737e2416. Reason for revert: wasn't the problem, relanding Original change's description: > Revert "Rename GrShape to GrStyledShape" > > This reverts commit f3f08af010eebdb9c1501bdf1b3d8e715298b05f. > > Reason for revert: maybe this is breaking the ios perf bot; it is the first CL that caused the bot to fail, but I can't really say why this would break them. > > Original change's description: > > Rename GrShape to GrStyledShape > > > > Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036 > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Change-Id: I2e5adbfc820811fbbde9cb57af28f86a7ba40bd9 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284231 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Ifdd52f8bacb5d66a7bf58efd328675c4c443ac8a No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284376 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-17 20:21:37 +00:00
shape = GrStyledShape(path);
} else {
// Use hairlines for now, since they are the only stroke type that doesn't require a
// rigid-body transform. The CCPR stroke code makes no distinction between hairlines
// and regular strokes other than how it decides the device-space stroke width.
SkStrokeRec stroke(SkStrokeRec::kHairline_InitStyle);
stroke.setStrokeParams(SkPaint::kRound_Cap, SkPaint::kMiter_Join, 4);
Reland "Rename GrShape to GrStyledShape" This reverts commit 73b86c1ade1c002cfa4da66c33c25514737e2416. Reason for revert: wasn't the problem, relanding Original change's description: > Revert "Rename GrShape to GrStyledShape" > > This reverts commit f3f08af010eebdb9c1501bdf1b3d8e715298b05f. > > Reason for revert: maybe this is breaking the ios perf bot; it is the first CL that caused the bot to fail, but I can't really say why this would break them. > > Original change's description: > > Rename GrShape to GrStyledShape > > > > Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036 > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Change-Id: I2e5adbfc820811fbbde9cb57af28f86a7ba40bd9 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284231 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Ifdd52f8bacb5d66a7bf58efd328675c4c443ac8a No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284376 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-17 20:21:37 +00:00
shape = GrStyledShape(path, GrStyle(stroke, nullptr));
}
fCCPR->testingOnly_drawPathDirectly({
fDContext.get(), std::move(paint), &GrUserStencilSettings::kUnused, fRTC.get(),
nullptr, &clipBounds, &matrix, &shape, GrAAType::kCoverage, false});
}
void clipFullscreenRect(SkPath clipPath, SkPMColor4f color = { 0, 1, 0, 1 }) {
SkASSERT(this->valid());
GrPaint paint;
paint.setColor4f(color);
Reland "GrClips provided as pointers to GrRTC" This reverts commit 074414fed53efcab7f33b06454958707419e37d8. Reason for revert: updated to guard against nullptr before calling quickContains(rrect). Original change's description: > Revert "GrClips provided as pointers to GrRTC" > > This reverts commit 226b689471a0fbb7400bc166032458278957541b. > > Reason for revert: Breaks Android roller > > Original change's description: > > GrClips provided as pointers to GrRTC > > > > A null clip represents no high-level clipping is necessary (the implicit > > clip to the render target's logical dimensions is fine). > > > > This also removes GrNoClip and GrFixedClip::Disabled() since they are > > replaced with just nullptr. > > > > By allowing nullptr to represent no intended clipping, it makes it easier > > to require GrClip and GrAppliedClip objects to know about the dimensions > > of the device. If we required a non-null clip object to represent no > > clipping, we'd have to have an instance for each device based on its > > size and that just became cumbersome. > > > > Bug: skia:10205 > > Change-Id: Ie30cc71820b92d99356d393a4c98c8677082e761 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290539 > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com > > Change-Id: I42c4828bcf016ee3d30d5c20b771be96e125817b > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10205 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292856 > Reviewed-by: Weston Tracey <westont@google.com> > Commit-Queue: Weston Tracey <westont@google.com> TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com,westont@google.com # Not skipping CQ checks because this is a reland. Bug: skia:10205 Change-Id: I5715a4de3b7c8847b73020dc4937d3816d879803 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292876 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-29 13:54:07 +00:00
CCPRClip clip(fCCPR, clipPath);
fRTC->drawRect(&clip, std::move(paint), GrAA::kYes, SkMatrix::I(),
SkRect::MakeIWH(kCanvasSize, kCanvasSize));
}
void flush() const {
SkASSERT(this->valid());
fDContext->flushAndSubmit();
}
private:
sk_sp<GrDirectContext> fDContext;
GrCoverageCountingPathRenderer* fCCPR;
std::unique_ptr<GrRenderTargetContext> fRTC;
const bool fDoStroke;
};
class CCPRTest {
public:
void run(skiatest::Reporter* reporter, DoCoverageCount doCoverageCount, DoStroke doStroke) {
GrMockOptions mockOptions;
mockOptions.fDrawInstancedSupport = true;
mockOptions.fHalfFloatVertexAttributeSupport = true;
mockOptions.fMapBufferFlags = GrCaps::kCanMap_MapFlag;
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fRenderability =
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fTexturable = true;
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fRenderability =
GrMockOptions::ConfigOptions::Renderability::kMSAA;
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fTexturable = true;
mockOptions.fGeometryShaderSupport = true;
mockOptions.fIntegerSupport = true;
mockOptions.fFlatInterpolationSupport = true;
GrContextOptions ctxOptions;
ctxOptions.fDisableCoverageCountingPaths = (DoCoverageCount::kNo == doCoverageCount);
ctxOptions.fAllowPathMaskCaching = false;
ctxOptions.fGpuPathRenderers = GpuPathRenderers::kCoverageCounting;
this->customizeOptions(&mockOptions, &ctxOptions);
sk_sp<GrDirectContext> mockContext = GrDirectContext::MakeMock(&mockOptions, ctxOptions);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
if (!mockContext) {
ERRORF(reporter, "could not create mock context");
return;
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
if (!mockContext->unique()) {
ERRORF(reporter, "mock context is not unique");
return;
}
CCPRPathDrawer ccpr(std::exchange(mockContext, nullptr), reporter, doStroke);
if (!ccpr.valid()) {
return;
}
fPath.moveTo(0, 0);
fPath.cubicTo(50, 50, 0, 50, 50, 0);
this->onRun(reporter, ccpr);
}
virtual ~CCPRTest() {}
protected:
virtual void customizeOptions(GrMockOptions*, GrContextOptions*) {}
virtual void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) = 0;
SkPath fPath;
};
#define DEF_CCPR_TEST(name) \
DEF_GPUTEST(name, reporter, /* options */) { \
name test; \
test.run(reporter, DoCoverageCount::kYes, DoStroke::kNo); \
test.run(reporter, DoCoverageCount::kYes, DoStroke::kYes); \
test.run(reporter, DoCoverageCount::kNo, DoStroke::kNo); \
/* FIXME: test.run(reporter, (DoCoverageCount::kNo, DoStroke::kYes) once supported. */ \
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
class CCPR_cleanup : public CCPRTest {
protected:
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
// Ensure paths get unreffed.
for (int i = 0; i < 10; ++i) {
ccpr.drawPath(fPath);
}
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
ccpr.flush();
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
// Ensure clip paths get unreffed.
for (int i = 0; i < 10; ++i) {
ccpr.clipFullscreenRect(fPath);
}
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
ccpr.flush();
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
// Ensure paths get unreffed when we delete the context without flushing.
for (int i = 0; i < 10; ++i) {
ccpr.drawPath(fPath);
ccpr.clipFullscreenRect(fPath);
}
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
ccpr.destroyGrContext();
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
}
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
DEF_CCPR_TEST(CCPR_cleanup)
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
class CCPR_cleanupWithTexAllocFail : public CCPR_cleanup {
void customizeOptions(GrMockOptions* mockOptions, GrContextOptions*) override {
mockOptions->fFailTextureAllocations = true;
}
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
((GrRecordingContext*)ccpr.dContext())->priv().incrSuppressWarningMessages();
this->CCPR_cleanup::onRun(reporter, ccpr);
}
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
DEF_CCPR_TEST(CCPR_cleanupWithTexAllocFail)
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
class CCPR_unregisterCulledOps : public CCPRTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
// Ensure Ops get unregistered from CCPR when culled early.
ccpr.drawPath(fPath);
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
ccpr.clear(); // Clear should delete the CCPR Op.
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
ccpr.flush(); // Should not crash (DrawPathsOp should have unregistered itself).
// Ensure Op unregisters work when we delete the context without flushing.
ccpr.drawPath(fPath);
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
ccpr.clear(); // Clear should delete the CCPR DrawPathsOp.
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
ccpr.destroyGrContext(); // Should not crash (DrawPathsOp should have unregistered itself).
}
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
DEF_CCPR_TEST(CCPR_unregisterCulledOps)
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
class CCPR_parseEmptyPath : public CCPRTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
// Make a path large enough that ccpr chooses to crop it by the RT bounds, and ends up with
// an empty path.
SkPath largeOutsidePath = SkPath::Polygon({
{-1e30f, -1e30f},
{-1e30f, +1e30f},
{-1e10f, +1e30f},
}, false);
ccpr.drawPath(largeOutsidePath);
// Normally an empty path is culled before reaching ccpr, however we use a back door for
// testing so this path will make it.
SkPath emptyPath;
SkASSERT(emptyPath.isEmpty());
ccpr.drawPath(emptyPath);
// This is the test. It will exercise various internal asserts and verify we do not crash.
ccpr.flush();
// Now try again with clips.
ccpr.clipFullscreenRect(largeOutsidePath);
ccpr.clipFullscreenRect(emptyPath);
ccpr.flush();
// ... and both.
ccpr.drawPath(largeOutsidePath);
ccpr.clipFullscreenRect(largeOutsidePath);
ccpr.drawPath(emptyPath);
ccpr.clipFullscreenRect(emptyPath);
ccpr.flush();
}
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
DEF_CCPR_TEST(CCPR_parseEmptyPath)
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
static int get_mock_texture_id(const GrTexture* texture) {
const GrBackendTexture& backingTexture = texture->getBackendTexture();
SkASSERT(GrBackendApi::kMock == backingTexture.backend());
if (!backingTexture.isValid()) {
return 0;
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
GrMockTextureInfo info;
backingTexture.getMockTextureInfo(&info);
return info.id();
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
}
// Base class for cache path unit tests.
class CCPRCacheTest : public CCPRTest {
protected:
// Registers as an onFlush callback in order to snag the CCPR per-flush resources and note the
// texture IDs.
class RecordLastMockAtlasIDs : public GrOnFlushCallbackObject {
public:
RecordLastMockAtlasIDs(sk_sp<GrCoverageCountingPathRenderer> ccpr) : fCCPR(ccpr) {}
int lastCopyAtlasID() const { return fLastCopyAtlasID; }
int lastRenderedAtlasID() const { return fLastRenderedAtlasID; }
void preFlush(GrOnFlushResourceProvider*, const uint32_t* opsTaskIDs,
int numOpsTaskIDs) override {
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
fLastRenderedAtlasID = fLastCopyAtlasID = 0;
const GrCCPerFlushResources* resources = fCCPR->testingOnly_getCurrentFlushResources();
if (!resources) {
return;
}
if (const GrTexture* tex = resources->testingOnly_frontCopyAtlasTexture()) {
fLastCopyAtlasID = get_mock_texture_id(tex);
}
if (const GrTexture* tex = resources->testingOnly_frontRenderedAtlasTexture()) {
fLastRenderedAtlasID = get_mock_texture_id(tex);
}
}
void postFlush(GrDeferredUploadToken, const uint32_t*, int) override {}
private:
sk_sp<GrCoverageCountingPathRenderer> fCCPR;
int fLastCopyAtlasID = 0;
int fLastRenderedAtlasID = 0;
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
CCPRCacheTest() {
static constexpr int primes[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
SkRandom rand;
for (size_t i = 0; i < SK_ARRAY_COUNT(fPaths); ++i) {
Reland "Rename GrShape to GrStyledShape" This reverts commit 73b86c1ade1c002cfa4da66c33c25514737e2416. Reason for revert: wasn't the problem, relanding Original change's description: > Revert "Rename GrShape to GrStyledShape" > > This reverts commit f3f08af010eebdb9c1501bdf1b3d8e715298b05f. > > Reason for revert: maybe this is breaking the ios perf bot; it is the first CL that caused the bot to fail, but I can't really say why this would break them. > > Original change's description: > > Rename GrShape to GrStyledShape > > > > Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036 > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Change-Id: I2e5adbfc820811fbbde9cb57af28f86a7ba40bd9 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284231 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Ifdd52f8bacb5d66a7bf58efd328675c4c443ac8a No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284376 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-17 20:21:37 +00:00
int numPts = rand.nextRangeU(GrStyledShape::kMaxKeyFromDataVerbCnt + 1,
GrStyledShape::kMaxKeyFromDataVerbCnt * 2);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
int step;
do {
step = primes[rand.nextU() % SK_ARRAY_COUNT(primes)];
} while (step == numPts);
fPaths[i] = ToolUtils::make_star(SkRect::MakeLTRB(0, 0, 1, 1), numPts, step);
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
void drawPathsAndFlush(CCPRPathDrawer& ccpr, const SkMatrix& m) {
this->drawPathsAndFlush(ccpr, &m, 1);
}
void drawPathsAndFlush(CCPRPathDrawer& ccpr, const SkMatrix* matrices, int numMatrices) {
// Draw all the paths.
for (size_t i = 0; i < SK_ARRAY_COUNT(fPaths); ++i) {
ccpr.drawPath(fPaths[i], matrices[i % numMatrices]);
}
// Re-draw a few paths, to test the case where a cache entry is hit more than once in a
// single flush.
SkRandom rand;
int duplicateIndices[10];
for (size_t i = 0; i < SK_ARRAY_COUNT(duplicateIndices); ++i) {
duplicateIndices[i] = rand.nextULessThan(SK_ARRAY_COUNT(fPaths));
}
for (size_t i = 0; i < SK_ARRAY_COUNT(duplicateIndices); ++i) {
for (size_t j = 0; j <= i; ++j) {
int idx = duplicateIndices[j];
ccpr.drawPath(fPaths[idx], matrices[idx % numMatrices]);
}
}
ccpr.flush();
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
private:
void customizeOptions(GrMockOptions*, GrContextOptions* ctxOptions) override {
ctxOptions->fAllowPathMaskCaching = true;
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) final {
RecordLastMockAtlasIDs atlasIDRecorder(sk_ref_sp(ccpr.ccpr()));
ccpr.dContext()->priv().addOnFlushCallbackObject(&atlasIDRecorder);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
this->onRun(reporter, ccpr, atlasIDRecorder);
ccpr.dContext()->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&atlasIDRecorder);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
}
virtual void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs&) = 0;
protected:
SkPath fPaths[350];
};
// Ensures ccpr always reuses the same atlas texture in the animation use case.
class CCPR_cache_animationAtlasReuse : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix m = SkMatrix::Translate(kCanvasSize/2, kCanvasSize/2);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
m.preScale(80, 80);
m.preTranslate(-.5,-.5);
this->drawPathsAndFlush(ccpr, m);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
const int atlasID = atlasIDRecorder.lastRenderedAtlasID();
// Ensures we always reuse the same atlas texture in the animation use case.
for (int i = 0; i < 12; ++i) {
// 59 is prime, so we will hit every integer modulo 360 before repeating.
m.preRotate(59, .5, .5);
// Go twice. Paths have to get drawn twice with the same matrix before we cache their
// atlas. This makes sure that on the subsequent draw, after an atlas has been cached
// and is then invalidated since the matrix will change, that the same underlying
// texture object is still reused for the next atlas.
for (int j = 0; j < 2; ++j) {
this->drawPathsAndFlush(ccpr, m);
// Nothing should be copied to an 8-bit atlas after just two draws.
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, atlasIDRecorder.lastRenderedAtlasID() == atlasID);
}
}
// Do the last draw again. (On draw 3 they should get copied to an 8-bit atlas.)
this->drawPathsAndFlush(ccpr, m);
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
// Now double-check that everything continues to hit the cache as expected when the matrix
// doesn't change.
for (int i = 0; i < 10; ++i) {
this->drawPathsAndFlush(ccpr, m);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
}
}
};
DEF_CCPR_TEST(CCPR_cache_animationAtlasReuse)
class CCPR_cache_recycleEntries : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix m = SkMatrix::Translate(kCanvasSize/2, kCanvasSize/2);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
m.preScale(80, 80);
m.preTranslate(-.5,-.5);
auto cache = ccpr.ccpr()->testingOnly_getPathCache();
REPORTER_ASSERT(reporter, cache);
const auto& lru = cache->testingOnly_getLRU();
SkTArray<const void*> expectedPtrs;
// Ensures we always reuse the same atlas texture in the animation use case.
for (int i = 0; i < 5; ++i) {
// 59 is prime, so we will hit every integer modulo 360 before repeating.
m.preRotate(59, .5, .5);
// Go twice. Paths have to get drawn twice with the same matrix before we cache their
// atlas.
for (int j = 0; j < 2; ++j) {
this->drawPathsAndFlush(ccpr, m);
// Nothing should be copied to an 8-bit atlas after just two draws.
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
}
int idx = 0;
for (const GrCCPathCacheEntry* entry : lru) {
if (0 == i) {
expectedPtrs.push_back(entry);
} else {
// The same pointer should have been recycled for the new matrix.
REPORTER_ASSERT(reporter, entry == expectedPtrs[idx]);
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
++idx;
}
}
}
};
DEF_CCPR_TEST(CCPR_cache_recycleEntries)
// Ensures mostly-visible paths get their full mask cached.
class CCPR_cache_mostlyVisible : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix matrices[3] = {
SkMatrix::Scale(kCanvasSize/2, kCanvasSize/2), // Fully visible.
SkMatrix::Scale(kCanvasSize * 1.25, kCanvasSize * 1.25), // Mostly visible.
SkMatrix::Scale(kCanvasSize * 1.5, kCanvasSize * 1.5), // Mostly NOT visible.
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
for (int i = 0; i < 10; ++i) {
this->drawPathsAndFlush(ccpr, matrices, 3);
if (2 == i) {
// The mostly-visible paths should still get cached.
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
} else {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
}
// Ensure mostly NOT-visible paths never get cached.
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
}
// Clear the path cache.
this->drawPathsAndFlush(ccpr, SkMatrix::I());
// Now only draw the fully/mostly visible ones.
for (int i = 0; i < 2; ++i) {
this->drawPathsAndFlush(ccpr, matrices, 2);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
}
// On draw 3 they should get copied to an 8-bit atlas.
this->drawPathsAndFlush(ccpr, matrices, 2);
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
for (int i = 0; i < 10; ++i) {
this->drawPathsAndFlush(ccpr, matrices, 2);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
}
// Draw a different part of the path to ensure the full mask was cached.
matrices[1].postTranslate(SkScalarFloorToInt(kCanvasSize * -.25f),
SkScalarFloorToInt(kCanvasSize * -.25f));
for (int i = 0; i < 10; ++i) {
this->drawPathsAndFlush(ccpr, matrices, 2);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
}
}
};
DEF_CCPR_TEST(CCPR_cache_mostlyVisible)
// Ensures GrDirectContext::performDeferredCleanup works.
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
class CCPR_cache_deferredCleanup : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix m = SkMatrix::Scale(20, 20);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
int lastRenderedAtlasID = 0;
for (int i = 0; i < 5; ++i) {
this->drawPathsAndFlush(ccpr, m);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
int renderedAtlasID = atlasIDRecorder.lastRenderedAtlasID();
REPORTER_ASSERT(reporter, renderedAtlasID != lastRenderedAtlasID);
lastRenderedAtlasID = renderedAtlasID;
this->drawPathsAndFlush(ccpr, m);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, lastRenderedAtlasID == atlasIDRecorder.lastRenderedAtlasID());
// On draw 3 they should get copied to an 8-bit atlas.
this->drawPathsAndFlush(ccpr, m);
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
for (int i = 0; i < 10; ++i) {
this->drawPathsAndFlush(ccpr, m);
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
Revert "ccpr: Rework the path cache to support sporadic flushing" This reverts commit d6fa45472cb82b7d8e58d0437f7723c672488b8b. Reason for revert: Assertion failures Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,csmartdalton@google.com Change-Id: Iad74a14fcb09da12f32b9b78f803b8472a5d60ae No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:8462 Reviewed-on: https://skia-review.googlesource.com/c/181444 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-04 22:14:27 +00:00
}
ccpr.dContext()->performDeferredCleanup(std::chrono::milliseconds(0));
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
}
}
};
DEF_CCPR_TEST(CCPR_cache_deferredCleanup)
// Verifies the cache/hash table internals.
class CCPR_cache_hashTable : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
using CoverageType = GrCCAtlas::CoverageType;
SkMatrix m = SkMatrix::Scale(20, 20);
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
for (int i = 0; i < 5; ++i) {
this->drawPathsAndFlush(ccpr, m);
if (2 == i) {
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
} else {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
}
if (i < 2) {
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
} else {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
}
auto cache = ccpr.ccpr()->testingOnly_getPathCache();
REPORTER_ASSERT(reporter, cache);
const auto& hash = cache->testingOnly_getHashTable();
const auto& lru = cache->testingOnly_getLRU();
int count = 0;
for (GrCCPathCacheEntry* entry : lru) {
auto* node = hash.find(entry->cacheKey());
REPORTER_ASSERT(reporter, node);
REPORTER_ASSERT(reporter, node->entry() == entry);
REPORTER_ASSERT(reporter, 0 == entry->testingOnly_peekOnFlushRefCnt());
REPORTER_ASSERT(reporter, entry->unique());
if (0 == i) {
REPORTER_ASSERT(reporter, !entry->cachedAtlas());
} else {
const GrCCCachedAtlas* cachedAtlas = entry->cachedAtlas();
REPORTER_ASSERT(reporter, cachedAtlas);
if (1 == i) {
REPORTER_ASSERT(reporter, ccpr.ccpr()->coverageType()
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
== cachedAtlas->coverageType());
} else {
REPORTER_ASSERT(reporter, CoverageType::kA8_LiteralCoverage
== cachedAtlas->coverageType());
}
REPORTER_ASSERT(reporter, cachedAtlas->textureKey().isValid());
// The actual proxy should not be held past the end of a flush.
REPORTER_ASSERT(reporter, !cachedAtlas->getOnFlushProxy());
REPORTER_ASSERT(reporter, 0 == cachedAtlas->testingOnly_peekOnFlushRefCnt());
}
++count;
}
REPORTER_ASSERT(reporter, hash.count() == count);
}
}
};
DEF_CCPR_TEST(CCPR_cache_hashTable)
// Ensures paths get cached even when using a sporadic flushing pattern and drawing out of order
// (a la Chrome tiles).
class CCPR_cache_multiFlush : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
static constexpr int kNumPaths = SK_ARRAY_COUNT(fPaths);
static constexpr int kBigPrimes[] = {
9323, 11059, 22993, 38749, 45127, 53147, 64853, 77969, 83269, 99989};
SkRandom rand;
SkMatrix m = SkMatrix::I();
for (size_t i = 0; i < SK_ARRAY_COUNT(kBigPrimes); ++i) {
int prime = kBigPrimes[i];
int endPathIdx = (int)rand.nextULessThan(kNumPaths);
int pathIdx = endPathIdx;
int nextFlush = rand.nextRangeU(1, 47);
for (int j = 0; j < kNumPaths; ++j) {
pathIdx = (pathIdx + prime) % kNumPaths;
int repeat = rand.nextRangeU(1, 3);
for (int k = 0; k < repeat; ++k) {
ccpr.drawPath(fPaths[pathIdx], m);
}
if (nextFlush == j) {
ccpr.flush();
// The paths are small enough that we should never copy to an A8 atlas.
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
if (i < 2) {
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
} else {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
}
nextFlush = std::min(j + (int)rand.nextRangeU(1, 29), kNumPaths - 1);
}
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
SkASSERT(endPathIdx == pathIdx % kNumPaths);
}
}
};
DEF_CCPR_TEST(CCPR_cache_multiFlush)
// Ensures a path drawn over mutiple tiles gets cached.
class CCPR_cache_multiTileCache : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
// Make sure a path drawn over 9 tiles gets cached (1 tile out of 9 is >10% visibility).
const SkMatrix m0 = SkMatrix::Scale(kCanvasSize*3, kCanvasSize*3);
const SkPath p0 = fPaths[0];
for (int i = 0; i < 9; ++i) {
static constexpr int kRowOrder[9] = {0,1,1,0,2,2,2,1,0};
static constexpr int kColumnOrder[9] = {0,0,1,1,0,1,2,2,2};
SkMatrix tileM = m0;
tileM.postTranslate(-kCanvasSize * kColumnOrder[i], -kCanvasSize * kRowOrder[i]);
ccpr.drawPath(p0, tileM);
ccpr.flush();
if (i < 5) {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
} else if (5 == i) {
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
} else {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
}
}
// Now make sure paths don't get cached when visibility is <10% for every draw (12 tiles).
const SkMatrix m1 = SkMatrix::Scale(kCanvasSize*4, kCanvasSize*3);
const SkPath p1 = fPaths[1];
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 4; ++col) {
SkMatrix tileM = m1;
tileM.postTranslate(-kCanvasSize * col, -kCanvasSize * row);
ccpr.drawPath(p1, tileM);
ccpr.flush();
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
}
}
// Double-check the cache is still intact.
ccpr.drawPath(p0, m0);
ccpr.flush();
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
ccpr.drawPath(p1, m1);
ccpr.flush();
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastRenderedAtlasID());
}
};
DEF_CCPR_TEST(CCPR_cache_multiTileCache)
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
// This test exercises CCPR's cache capabilities by drawing many paths with two different
// transformation matrices. We then vary the matrices independently by whole and partial pixels,
// and verify the caching behaved as expected.
class CCPR_cache_partialInvalidate : public CCPRCacheTest {
void customizeOptions(GrMockOptions*, GrContextOptions* ctxOptions) override {
ctxOptions->fAllowPathMaskCaching = true;
}
static constexpr int kPathSize = 4;
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix matrices[2] = {
SkMatrix::Translate(5, 5),
SkMatrix::Translate(kCanvasSize - kPathSize - 5, kCanvasSize - kPathSize - 5)
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
};
matrices[0].preScale(kPathSize, kPathSize);
matrices[1].preScale(kPathSize, kPathSize);
int firstAtlasID = 0;
for (int iterIdx = 0; iterIdx < 4*3*2; ++iterIdx) {
this->drawPathsAndFlush(ccpr, matrices, 2);
if (0 == iterIdx) {
// First iteration: just note the ID of the stashed atlas and continue.
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
firstAtlasID = atlasIDRecorder.lastRenderedAtlasID();
REPORTER_ASSERT(reporter, 0 != firstAtlasID);
continue;
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
int testIdx = (iterIdx/2) % 3;
int repetitionIdx = iterIdx % 2;
switch (testIdx) {
case 0:
if (0 == repetitionIdx) {
// This is the big test. New paths were drawn twice last round. On hit 2
// (last time), 'firstAtlasID' was cached as a 16-bit atlas. Now, on hit 3,
// these paths should be copied out of 'firstAtlasID', and into an A8 atlas.
// THEN: we should recycle 'firstAtlasID' and reuse that same texture to
// render the new masks.
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
REPORTER_ASSERT(reporter,
atlasIDRecorder.lastRenderedAtlasID() == firstAtlasID);
} else {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
// This is hit 2 for the new masks. Next time they will be copied to an A8
// atlas.
REPORTER_ASSERT(reporter,
atlasIDRecorder.lastRenderedAtlasID() == firstAtlasID);
}
if (1 == repetitionIdx) {
// Integer translates: all path masks stay valid.
matrices[0].preTranslate(-1, -1);
matrices[1].preTranslate(1, 1);
}
break;
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
case 1:
if (0 == repetitionIdx) {
// New paths were drawn twice last round. The third hit (now) they should be
// copied to an A8 atlas.
REPORTER_ASSERT(reporter, 0 != atlasIDRecorder.lastCopyAtlasID());
} else {
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
}
Revert "ccpr: Rework the path cache to support sporadic flushing" This reverts commit d6fa45472cb82b7d8e58d0437f7723c672488b8b. Reason for revert: Assertion failures Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,csmartdalton@google.com Change-Id: Iad74a14fcb09da12f32b9b78f803b8472a5d60ae No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:8462 Reviewed-on: https://skia-review.googlesource.com/c/181444 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-04 22:14:27 +00:00
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
// This draw should have gotten 100% cache hits; we only did integer translates
// last time (or none if it was the first flush). Therefore, everything should
// have been cached.
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
if (1 == repetitionIdx) {
// Invalidate even path masks.
matrices[0].preTranslate(1.6f, 1.4f);
}
Revert "ccpr: Rework the path cache to support sporadic flushing" This reverts commit d6fa45472cb82b7d8e58d0437f7723c672488b8b. Reason for revert: Assertion failures Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,csmartdalton@google.com Change-Id: Iad74a14fcb09da12f32b9b78f803b8472a5d60ae No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:8462 Reviewed-on: https://skia-review.googlesource.com/c/181444 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-04 22:14:27 +00:00
break;
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
case 2:
// No new masks to copy from last time; it had 100% cache hits.
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastCopyAtlasID());
// Even path masks were invalidated last iteration by a subpixel translate.
// They should have been re-rendered this time in the original 'firstAtlasID'
// texture.
REPORTER_ASSERT(reporter,
atlasIDRecorder.lastRenderedAtlasID() == firstAtlasID);
if (1 == repetitionIdx) {
// Invalidate odd path masks.
matrices[1].preTranslate(-1.4f, -1.6f);
}
break;
}
}
}
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
DEF_CCPR_TEST(CCPR_cache_partialInvalidate)
class CCPR_unrefPerOpsTaskPathsBeforeOps : public CCPRTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
for (int i = 0; i < 10000; ++i) {
// Draw enough paths to make the arena allocator hit the heap.
ccpr.drawPath(fPath);
}
// Unref the GrCCPerOpsTaskPaths object.
auto perOpsTaskPathsMap = ccpr.ccpr()->detachPendingPaths();
perOpsTaskPathsMap.clear();
// Now delete the Op and all its draws.
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
ccpr.flush();
REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
}
};
DEF_CCPR_TEST(CCPR_unrefPerOpsTaskPathsBeforeOps)
class CCPRRenderingTest {
public:
void run(skiatest::Reporter* reporter, GrDirectContext* dContext, DoStroke doStroke) const {
if (auto ccpr = dContext->priv().drawingManager()->getCoverageCountingPathRenderer()) {
if (DoStroke::kYes == doStroke &&
GrCCAtlas::CoverageType::kA8_Multisample == ccpr->coverageType()) {
return; // Stroking is not yet supported for multisample.
}
CCPRPathDrawer drawer(sk_ref_sp(dContext), reporter, doStroke);
if (!drawer.valid()) {
return;
}
this->onRun(reporter, drawer);
}
}
virtual ~CCPRRenderingTest() {}
protected:
virtual void onRun(skiatest::Reporter* reporter, const CCPRPathDrawer& ccpr) const = 0;
};
#define DEF_CCPR_RENDERING_TEST(name) \
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, ctxInfo) { \
name test; \
test.run(reporter, ctxInfo.directContext(), DoStroke::kNo); \
test.run(reporter, ctxInfo.directContext(), DoStroke::kYes); \
}
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
class CCPR_busyPath : public CCPRRenderingTest {
void onRun(skiatest::Reporter* reporter, const CCPRPathDrawer& ccpr) const override {
static constexpr int kNumBusyVerbs = 1 << 17;
ccpr.clear();
SkPath busyPath;
busyPath.moveTo(0, 0); // top left
busyPath.lineTo(kCanvasSize, kCanvasSize); // bottom right
for (int i = 2; i < kNumBusyVerbs; ++i) {
float offset = i * ((float)kCanvasSize / kNumBusyVerbs);
busyPath.lineTo(kCanvasSize - offset, kCanvasSize + offset); // offscreen
}
ccpr.drawPath(busyPath);
ccpr.flush(); // If this doesn't crash, the test passed.
// If it does, maybe fiddle with fMaxInstancesPerDrawArraysWithoutCrashing in
// your platform's GrGLCaps.
}
};
Reland "ccpr: Rework the path cache to support sporadic flushing" This is a reland of d6fa45472cb82b7d8e58d0437f7723c672488b8b Original change's description: > ccpr: Rework the path cache to support sporadic flushing > > Removes the notion of a stashed atlas that we store from the previous > flush. Now we just cache every atlas we ever render. Cached atlases > can either be 16-bit or 8-bit. > > The "reuse" and "animation" cases should both behave exactly the same > as before: Where before we would copy from the stashed atlas to 8-bit > atlases, we now copy from a cached 16-bit atlas and then invalidate > it. Where before we would recycle the stashed atlas's backing texture > object, we now recycle this same texture object from an invalidated > 16-bit cached atlas. > > The main difference is that cases like tiled rendering now work. If > you draw your whole scene in one flush, you still get one big 16-bit > cached atlas, just like the "stashed atlas" implementation. But if you > draw your scene in tiles, you now get lots of little cached 16-bit > atlases, which can be reused and eventually copied to 8-bit atlases. > > Bug: skia:8462 > Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18 > Reviewed-on: https://skia-review.googlesource.com/c/179991 > Commit-Queue: Chris Dalton <csmartdalton@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: skia:8462 Change-Id: I2f64b0c37e2cd644a202dfc786366dda5d238391 Reviewed-on: https://skia-review.googlesource.com/c/181450 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-01-07 05:51:00 +00:00
DEF_CCPR_RENDERING_TEST(CCPR_busyPath)