Reland "Remove SkTLList"
This reverts commit 14b1d56a2b2b8f0ffcb62180382b7347673aaa11.
Reason for revert: fix emplace_back() usage
Original change's description:
> Revert "Remove SkTLList"
>
> This reverts commit e1d523d70fec3b3d24fef6da4a823c52092b6c77.
>
> Reason for revert: breaking old stdlib versions (< c17)
>
> Original change's description:
> > Remove SkTLList
> >
> > Change-Id: I198678b5cb298cf51872fbb8d4fd5d705a6b684e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437339
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=brianosman@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: I8e02e4cd2f293e7530f842be783de10f69be2ef4
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438078
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
# Not skipping CQ checks because this is a reland.
Change-Id: Ied33ce81a8312963ff0713c4660cdb8541a02180
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438080
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/gm/aarecteffect.cpp b/gm/aarecteffect.cpp
index b5cdc36..c900cec 100644
--- a/gm/aarecteffect.cpp
+++ b/gm/aarecteffect.cpp
@@ -18,7 +18,6 @@
#include "include/core/SkString.h"
#include "include/private/GrTypesPriv.h"
#include "src/core/SkCanvasPriv.h"
-#include "src/core/SkTLList.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrPaint.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
diff --git a/gm/convexpolyclip.cpp b/gm/convexpolyclip.cpp
index 0267037..90249dd 100644
--- a/gm/convexpolyclip.cpp
+++ b/gm/convexpolyclip.cpp
@@ -25,7 +25,6 @@
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
-#include "src/core/SkTLList.h"
#include "tools/ToolUtils.h"
static sk_sp<SkImage> make_img(int w, int h) {
@@ -112,7 +111,13 @@
}
void onOnceBeforeDraw() override {
- fClips.addToTail()->setPath(SkPath::Polygon({
+ // On < c++17, emplace_back() returns a void :(
+ auto emplace_back = [](std::vector<Clip>& clips) -> Clip& {
+ clips.emplace_back();
+ return clips.back();
+ };
+
+ emplace_back(fClips).setPath(SkPath::Polygon({
{ 5.f, 5.f},
{100.f, 20.f},
{ 15.f, 100.f},
@@ -132,18 +137,18 @@
hexagon.lineTo(point);
}
}
- fClips.addToTail()->setPath(hexagon.snapshot());
+ emplace_back(fClips).setPath(hexagon.snapshot());
SkMatrix scaleM;
scaleM.setScale(1.1f, 0.4f, kRadius, kRadius);
- fClips.addToTail()->setPath(hexagon.detach().makeTransform(scaleM));
+ emplace_back(fClips).setPath(hexagon.detach().makeTransform(scaleM));
- fClips.addToTail()->setRect(SkRect::MakeXYWH(8.3f, 11.6f, 78.2f, 72.6f));
+ emplace_back(fClips).setRect(SkRect::MakeXYWH(8.3f, 11.6f, 78.2f, 72.6f));
SkRect rect = SkRect::MakeLTRB(10.f, 12.f, 80.f, 86.f);
SkMatrix rotM;
rotM.setRotate(23.f, rect.centerX(), rect.centerY());
- fClips.addToTail()->setPath(SkPath::Rect(rect).makeTransform(rotM));
+ emplace_back(fClips).setPath(SkPath::Rect(rect).makeTransform(rotM));
fImg = make_img(100, 100);
}
@@ -167,15 +172,12 @@
SkScalar startX = 0;
int testLayers = kBench_Mode != this->getMode();
for (int doLayer = 0; doLayer <= testLayers; ++doLayer) {
- for (ClipList::Iter iter(fClips, ClipList::Iter::kHead_IterStart);
- iter.get();
- iter.next()) {
- const Clip* clip = iter.get();
+ for (const Clip& clip : fClips) {
SkScalar x = startX;
for (int aa = 0; aa < 2; ++aa) {
if (doLayer) {
SkRect bounds;
- clip->getBounds(&bounds);
+ clip.getBounds(&bounds);
bounds.outset(2, 2);
bounds.offset(x, y);
canvas->saveLayer(&bounds, nullptr);
@@ -183,7 +185,7 @@
canvas->save();
}
canvas->translate(x, y);
- clip->setOnCanvas(canvas, SkClipOp::kIntersect, SkToBool(aa));
+ clip.setOnCanvas(canvas, SkClipOp::kIntersect, SkToBool(aa));
canvas->drawImage(fImg, 0, 0);
canvas->restore();
x += fImg->width() + kMargin;
@@ -198,7 +200,7 @@
if (doLayer) {
SkRect bounds;
- clip->getBounds(&bounds);
+ clip.getBounds(&bounds);
bounds.outset(2, 2);
bounds.offset(x, y);
canvas->saveLayer(&bounds, nullptr);
@@ -206,9 +208,9 @@
canvas->save();
}
canvas->translate(x, y);
- SkPath closedClipPath = clip->asClosedPath();
+ SkPath closedClipPath = clip.asClosedPath();
canvas->drawPath(closedClipPath, clipOutlinePaint);
- clip->setOnCanvas(canvas, SkClipOp::kIntersect, SkToBool(aa));
+ clip.setOnCanvas(canvas, SkClipOp::kIntersect, SkToBool(aa));
canvas->scale(1.f, 1.8f);
canvas->drawSimpleText(kTxt, SK_ARRAY_COUNT(kTxt)-1, SkTextEncoding::kUTF8,
0, 1.5f * font.getSize(), font, txtPaint);
@@ -296,9 +298,8 @@
SkRect fRect;
};
- typedef SkTLList<Clip, 1> ClipList;
- ClipList fClips;
- sk_sp<SkImage> fImg;;
+ std::vector<Clip> fClips;
+ sk_sp<SkImage> fImg;;
using INHERITED = GM;
};
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 7485293..05747dc 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -20,7 +20,6 @@
#include "include/core/SkString.h"
#include "include/private/GrTypesPriv.h"
#include "src/core/SkCanvasPriv.h"
-#include "src/core/SkTLList.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrPaint.h"
#include "src/gpu/effects/GrConvexPolyEffect.h"
@@ -56,11 +55,12 @@
tri.lineTo(100.f, 20.f);
tri.lineTo(15.f, 100.f);
- fPaths.addToTail(tri);
- fPaths.addToTail(SkPath())->reverseAddPath(tri);
+ fPaths.push_back(tri);
+ fPaths.emplace_back();
+ fPaths.back().reverseAddPath(tri);
tri.close();
- fPaths.addToTail(tri);
+ fPaths.push_back(tri);
SkPath ngon;
constexpr SkScalar kRadius = 50.f;
@@ -77,16 +77,16 @@
}
}
- fPaths.addToTail(ngon);
+ fPaths.push_back(ngon);
SkMatrix scaleM;
scaleM.setScale(1.1f, 0.4f);
ngon.transform(scaleM);
- fPaths.addToTail(ngon);
+ fPaths.push_back(ngon);
SkPath linePath;
linePath.moveTo(5.f, 5.f);
linePath.lineTo(6.f, 6.f);
- fPaths.addToTail(linePath);
+ fPaths.push_back(linePath);
}
DrawResult onDraw(GrRecordingContext* rContext, SkCanvas* canvas, SkString* errorMsg) override {
@@ -100,16 +100,13 @@
static constexpr SkScalar kDX = 12.f;
static constexpr SkScalar kOutset = 5.f;
- for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart);
- iter.get();
- iter.next()) {
- const SkPath* path = iter.get();
+ for (const SkPath& path : fPaths) {
SkScalar x = 0;
for (int et = 0; et < kGrClipEdgeTypeCnt; ++et) {
const SkMatrix m = SkMatrix::Translate(x, y);
SkPath p;
- path->transform(m, &p);
+ path.transform(m, &p);
GrClipEdgeType edgeType = (GrClipEdgeType) et;
auto [success, fp] = GrConvexPolyEffect::Make(/*inputFP=*/nullptr, edgeType, p);
@@ -125,28 +122,27 @@
auto op = sk_gpu_test::test_ops::MakeRect(rContext, std::move(grPaint), rect);
sdc->addDrawOp(std::move(op));
- x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
+ x += SkScalarCeilToScalar(path.getBounds().width() + kDX);
}
// Draw AA and non AA paths using normal API for reference.
canvas->save();
canvas->translate(x, y);
SkPaint paint;
- canvas->drawPath(*path, paint);
- canvas->translate(path->getBounds().width() + 10.f, 0);
+ canvas->drawPath(path, paint);
+ canvas->translate(path.getBounds().width() + 10.f, 0);
paint.setAntiAlias(true);
- canvas->drawPath(*path, paint);
+ canvas->drawPath(path, paint);
canvas->restore();
- y += SkScalarCeilToScalar(path->getBounds().height() + 20.f);
+ y += SkScalarCeilToScalar(path.getBounds().height() + 20.f);
}
return DrawResult::kOk;
}
private:
- typedef SkTLList<SkPath, 1> PathList;
- PathList fPaths;
+ std::vector<SkPath> fPaths;
using INHERITED = GM;
};