Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: dm/DMSrcSink.cpp

Issue 1513053004: Revert of DM: fix `--config $VIA-pdf` to not crash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 1728ea8bc252009e60048207d06c14b500189afe..2503dc35cec207602df6e50d9f66a518d108f2d1 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -992,21 +992,19 @@
// passing the Sink draw() arguments, a size, and a function draws into an SkCanvas.
// Several examples below.
-static Error draw_to_canvas(Name name, Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkString* log,
+static Error draw_to_canvas(Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkString* log,
SkISize size, std::function<Error(SkCanvas*)> draw) {
class ProxySrc : public Src {
public:
- ProxySrc(SkISize size, Name name, std::function<Error(SkCanvas*)> draw)
- : fSize(size), fName(name), fDraw(draw) {}
+ ProxySrc(SkISize size, std::function<Error(SkCanvas*)> draw) : fSize(size), fDraw(draw) {}
Error draw(SkCanvas* canvas) const override { return fDraw(canvas); }
- Name name() const override { return fName; }
+ Name name() const override { sk_throw(); return ""; } // Won't be called.
SkISize size() const override { return fSize; }
private:
SkISize fSize;
- Name fName;
std::function<Error(SkCanvas*)> fDraw;
};
- return sink->draw(ProxySrc(size, name, draw), bitmap, stream, log);
+ return sink->draw(ProxySrc(size, draw), bitmap, stream, log);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -1018,13 +1016,12 @@
return SkISize::Make(SkScalarRoundToInt(bounds.width()), SkScalarRoundToInt(bounds.height()));
}
-ViaMatrix::ViaMatrix(Name name, SkMatrix matrix, Sink* sink) : Via(name, sink), fMatrix(matrix) {}
+ViaMatrix::ViaMatrix(SkMatrix matrix, Sink* sink) : Via(sink), fMatrix(matrix) {}
Error ViaMatrix::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
SkMatrix matrix = fMatrix;
SkISize size = auto_compute_translate(&matrix, src.size().width(), src.size().height());
- Name name = this->decorateName(src);
- return draw_to_canvas(name, fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
+ return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
canvas->concat(matrix);
return src.draw(canvas);
});
@@ -1032,7 +1029,7 @@
// Undoes any flip or 90 degree rotate without changing the scale of the bitmap.
// This should be pixel-preserving.
-ViaUpright::ViaUpright(Name name, SkMatrix matrix, Sink* sink) : Via(name, sink), fMatrix(matrix) {}
+ViaUpright::ViaUpright(SkMatrix matrix, Sink* sink) : Via(sink), fMatrix(matrix) {}
Error ViaUpright::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
Error err = fSink->draw(src, bitmap, stream, log);
@@ -1069,8 +1066,7 @@
Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
auto size = src.size();
- Name name = this->decorateName(src);
- return draw_to_canvas(name, fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
+ return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
PipeController controller(canvas, &SkImageDecoder::DecodeMemory);
SkGPipeWriter pipe;
const uint32_t kFlags = 0;
@@ -1079,8 +1075,7 @@
}
Error ViaRemote::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
- Name name = this->decorateName(src);
- return draw_to_canvas(name, fSink, bitmap, stream, log, src.size(), [&](SkCanvas* target) {
+ return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* target) {
SkAutoTDelete<SkRemote::Encoder> decoder(SkRemote::NewDecoder(target));
SkAutoTDelete<SkRemote::Encoder> cache(fCache ? SkRemote::NewCachingEncoder(decoder)
: nullptr);
@@ -1108,9 +1103,8 @@
pic->serialize(&wStream);
SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &lazy_decode_bitmap));
- Name name = this->decorateName(src);
-
- return draw_to_canvas(name, fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
+
+ return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
canvas->drawPicture(deserialized);
return "";
});
@@ -1118,8 +1112,8 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-ViaTiles::ViaTiles(Name name, int w, int h, SkBBHFactory* factory, Sink* sink)
- : Via(name, sink)
+ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
+ : Via(sink)
, fW(w)
, fH(h)
, fFactory(factory) {}
@@ -1134,9 +1128,8 @@
return err;
}
SkAutoTUnref<SkPicture> pic(recorder.endRecordingAsPicture());
- Name name = this->decorateName(src);
-
- return draw_to_canvas(name, fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) {
+
+ return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) {
const int xTiles = (size.width() + fW - 1) / fW,
yTiles = (size.height() + fH - 1) / fH;
SkMultiPictureDraw mpd(xTiles*yTiles);
@@ -1178,8 +1171,7 @@
Error ViaSecondPicture::draw(
const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
auto size = src.size();
- Name name = this->decorateName(src);
- return draw_to_canvas(name, fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+ return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
SkPictureRecorder recorder;
SkAutoTUnref<SkPicture> pic;
for (int i = 0; i < 2; i++) {
@@ -1199,8 +1191,7 @@
// Draw the Src twice. This can help exercise caching.
Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
- Name name = this->decorateName(src);
- return draw_to_canvas(name, fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) -> Error {
+ return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) -> Error {
for (int i = 0; i < 2; i++) {
SkAutoCanvasRestore acr(canvas, true/*save now*/);
canvas->clear(SK_ColorTRANSPARENT);
@@ -1252,8 +1243,7 @@
Error ViaSingletonPictures::draw(
const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
auto size = src.size();
- Name name = this->decorateName(src);
- return draw_to_canvas(name, fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+ return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
// Use low-level (Skia-private) recording APIs so we can read the SkRecord.
SkRecord skr;
SkRecorder recorder(&skr, size.width(), size.height());
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698