Non-substantive changes
These changes are pulled out of: https://skia-review.googlesource.com/c/skia/+/208227 (Implement alternate method for determining recycle-ability of allocated GrSurfaces) Change-Id: I1126f0e0c149d07f5febb352c4e86a676960409f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209103 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
5b39dc8153
commit
396673870c
@ -52,72 +52,80 @@ protected:
|
||||
blue.setStyle(SkPaint::kStroke_Style);
|
||||
|
||||
int x = 0, y = 0;
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
sk_sp<SkImage> image = (i & 0x01) ? fCheckerboard : fBitmap;
|
||||
SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(image->width()/4),
|
||||
SkIntToScalar(image->height()/4),
|
||||
SkIntToScalar(image->width()/(i+1)),
|
||||
SkIntToScalar(image->height()/(i+1)));
|
||||
SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(i * 8),
|
||||
SkIntToScalar(i * 4),
|
||||
SkIntToScalar(image->width() - i * 12),
|
||||
SkIntToScalar(image->height()) - i * 12);
|
||||
sk_sp<SkImageFilter> tileInput(SkImageSource::Make(image));
|
||||
sk_sp<SkImageFilter> filter(SkTileImageFilter::Make(srcRect,
|
||||
dstRect,
|
||||
std::move(tileInput)));
|
||||
canvas->save();
|
||||
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(std::move(filter));
|
||||
canvas->drawImage(fBitmap.get(), 0, 0, &paint);
|
||||
canvas->drawRect(srcRect, red);
|
||||
canvas->drawRect(dstRect, blue);
|
||||
canvas->restore();
|
||||
x += image->width() + MARGIN;
|
||||
if (x + image->width() > WIDTH) {
|
||||
x = 0;
|
||||
y += image->height() + MARGIN;
|
||||
|
||||
{
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
sk_sp<SkImage> image = (i & 0x01) ? fCheckerboard : fBitmap;
|
||||
SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(image->width()/4),
|
||||
SkIntToScalar(image->height()/4),
|
||||
SkIntToScalar(image->width()/(i+1)),
|
||||
SkIntToScalar(image->height()/(i+1)));
|
||||
SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(i * 8),
|
||||
SkIntToScalar(i * 4),
|
||||
SkIntToScalar(image->width() - i * 12),
|
||||
SkIntToScalar(image->height()) - i * 12);
|
||||
sk_sp<SkImageFilter> tileInput(SkImageSource::Make(image));
|
||||
sk_sp<SkImageFilter> filter(SkTileImageFilter::Make(srcRect,
|
||||
dstRect,
|
||||
std::move(tileInput)));
|
||||
canvas->save();
|
||||
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(std::move(filter));
|
||||
canvas->drawImage(fBitmap.get(), 0, 0, &paint);
|
||||
canvas->drawRect(srcRect, red);
|
||||
canvas->drawRect(dstRect, blue);
|
||||
canvas->restore();
|
||||
x += image->width() + MARGIN;
|
||||
if (x + image->width() > WIDTH) {
|
||||
x = 0;
|
||||
y += image->height() + MARGIN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
|
||||
0, SK_Scalar1, 0, 0, 0,
|
||||
0, 0, SK_Scalar1, 0, 0,
|
||||
0, 0, 0, SK_Scalar1, 0 };
|
||||
{
|
||||
SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
|
||||
0, SK_Scalar1, 0, 0, 0,
|
||||
0, 0, SK_Scalar1, 0, 0,
|
||||
0, 0, 0, SK_Scalar1, 0 };
|
||||
|
||||
SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width()),
|
||||
SkIntToScalar(fBitmap->height()));
|
||||
SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width() * 2),
|
||||
SkIntToScalar(fBitmap->height() * 2));
|
||||
sk_sp<SkImageFilter> tile(SkTileImageFilter::Make(srcRect, dstRect, nullptr));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width()),
|
||||
SkIntToScalar(fBitmap->height()));
|
||||
SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width() * 2),
|
||||
SkIntToScalar(fBitmap->height() * 2));
|
||||
sk_sp<SkImageFilter> tile(SkTileImageFilter::Make(srcRect, dstRect, nullptr));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkColorFilterImageFilter::Make(std::move(cf), std::move(tile)));
|
||||
canvas->save();
|
||||
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
|
||||
canvas->clipRect(dstRect);
|
||||
canvas->saveLayer(&dstRect, &paint);
|
||||
canvas->drawImage(fBitmap.get(), 0, 0);
|
||||
canvas->restore();
|
||||
canvas->drawRect(srcRect, red);
|
||||
canvas->drawRect(dstRect, blue);
|
||||
canvas->restore();
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkColorFilterImageFilter::Make(std::move(cf), std::move(tile)));
|
||||
canvas->save();
|
||||
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
|
||||
canvas->clipRect(dstRect);
|
||||
canvas->saveLayer(&dstRect, &paint);
|
||||
canvas->drawImage(fBitmap.get(), 0, 0);
|
||||
canvas->restore();
|
||||
canvas->drawRect(srcRect, red);
|
||||
canvas->drawRect(dstRect, blue);
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
canvas->translate(0, SkIntToScalar(100));
|
||||
// test that the crop rect properly applies to the tile image filter
|
||||
{
|
||||
canvas->translate(0, SkIntToScalar(100));
|
||||
|
||||
srcRect = SkRect::MakeXYWH(0, 0, 50, 50);
|
||||
dstRect = SkRect::MakeXYWH(0, 0, 100, 100);
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(5, 5, 40, 40));
|
||||
sk_sp<SkColorFilter> greenCF = SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrc);
|
||||
sk_sp<SkImageFilter> green(SkColorFilterImageFilter::Make(std::move(greenCF),
|
||||
nullptr,
|
||||
&cropRect));
|
||||
tile = SkTileImageFilter::Make(srcRect, dstRect, std::move(green));
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setImageFilter(std::move(tile));
|
||||
canvas->drawRect(dstRect, paint);
|
||||
SkRect srcRect = SkRect::MakeXYWH(0, 0, 50, 50);
|
||||
SkRect dstRect = SkRect::MakeXYWH(0, 0, 100, 100);
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(5, 5, 40, 40));
|
||||
sk_sp<SkColorFilter> greenCF = SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrc);
|
||||
sk_sp<SkImageFilter> green(SkColorFilterImageFilter::Make(std::move(greenCF),
|
||||
nullptr,
|
||||
&cropRect));
|
||||
SkPaint paint;
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setImageFilter(SkTileImageFilter::Make(srcRect, dstRect, std::move(green)));
|
||||
canvas->drawRect(dstRect, paint);
|
||||
}
|
||||
}
|
||||
private:
|
||||
sk_sp<SkImage> fBitmap, fCheckerboard;
|
||||
|
@ -285,8 +285,8 @@ protected:
|
||||
}
|
||||
|
||||
GrFragmentProcessor(ClassID classID, OptimizationFlags optimizationFlags)
|
||||
: INHERITED(classID)
|
||||
, fFlags(optimizationFlags) {
|
||||
: INHERITED(classID)
|
||||
, fFlags(optimizationFlags) {
|
||||
SkASSERT((fFlags & ~kAll_OptimizationFlags) == 0);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@ void GrResourceAllocator::Interval::assign(sk_sp<GrSurface> s) {
|
||||
fProxy->priv().assign(std::move(s));
|
||||
}
|
||||
|
||||
|
||||
void GrResourceAllocator::markEndOfOpList(int opListIndex) {
|
||||
SkASSERT(!fAssigned); // We shouldn't be adding any opLists after (or during) assignment
|
||||
|
||||
@ -286,7 +285,7 @@ sk_sp<GrSurface> GrResourceAllocator::findSurfaceFor(const GrSurfaceProxy* proxy
|
||||
}
|
||||
|
||||
// Remove any intervals that end before the current index. Return their GrSurfaces
|
||||
// to the free pool.
|
||||
// to the free pool if possible.
|
||||
void GrResourceAllocator::expire(unsigned int curIndex) {
|
||||
while (!fActiveIntvls.empty() && fActiveIntvls.peekHead()->end() < curIndex) {
|
||||
Interval* temp = fActiveIntvls.popHead();
|
||||
|
@ -120,9 +120,10 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
// Used when recycling an interval
|
||||
void resetTo(GrSurfaceProxy* proxy, unsigned int start, unsigned int end) {
|
||||
SkASSERT(proxy);
|
||||
SkASSERT(!fNext);
|
||||
SkASSERT(!fProxy && !fNext);
|
||||
|
||||
fProxy = proxy;
|
||||
fProxyID = proxy->uniqueID().asUInt();
|
||||
|
@ -111,7 +111,13 @@ public:
|
||||
const char* name() const override { return "LazyProxyTest::Op"; }
|
||||
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
|
||||
GrProcessorSet::Analysis finalize(
|
||||
const GrCaps&, const GrAppliedClip*, GrFSAAType, GrClampType) override {
|
||||
const GrCaps&, const GrAppliedClip* clip, GrFSAAType, GrClampType) override {
|
||||
if (clip) {
|
||||
for (int i = 0; i < clip->numClipCoverageFragmentProcessors(); ++i) {
|
||||
const GrFragmentProcessor* clipFP = clip->clipCoverageFragmentProcessor(i);
|
||||
clipFP->markPendingExecution();
|
||||
}
|
||||
}
|
||||
return GrProcessorSet::EmptySetAnalysis();
|
||||
}
|
||||
void onPrepare(GrOpFlushState*) override {}
|
||||
|
Loading…
Reference in New Issue
Block a user