remove unused (by clients) SkMultiPictureDraw
More cleaning to do if we like this idea...
Change-Id: I608143db085911565dd5f5426f7ee6436ec58cdf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254680
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/bench/SKPAnimationBench.cpp b/bench/SKPAnimationBench.cpp
index ee25f19..8cb9d8d 100644
--- a/bench/SKPAnimationBench.cpp
+++ b/bench/SKPAnimationBench.cpp
@@ -6,7 +6,6 @@
*/
#include "bench/SKPAnimationBench.h"
-#include "include/core/SkMultiPictureDraw.h"
#include "include/core/SkSurface.h"
#include "tools/flags/CommandLineFlags.h"
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index 8543174..9fe11f8 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -6,7 +6,6 @@
*/
#include "bench/SKPBench.h"
-#include "include/core/SkMultiPictureDraw.h"
#include "include/core/SkSurface.h"
#include "tools/flags/CommandLineFlags.h"
@@ -125,17 +124,7 @@
}
void SKPBench::drawMPDPicture() {
- SkMultiPictureDraw mpd;
-
- for (int j = 0; j < fTileRects.count(); ++j) {
- SkMatrix trans;
- trans.setTranslate(-fTileRects[j].fLeft/fScale,
- -fTileRects[j].fTop/fScale);
- mpd.add(fSurfaces[j]->getCanvas(), fPic.get(), &trans);
- }
-
- // We flush after each picture to more closely model how Chrome rasterizes tiles.
- mpd.draw(/*flush = */ true);
+ // TODO: remove me
}
void SKPBench::drawPicture() {
diff --git a/dm/DM.cpp b/dm/DM.cpp
index c3e29ef..6eb307d 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -998,9 +998,6 @@
#endif
VIA("serialize", ViaSerialization, wrapped);
VIA("pic", ViaPicture, wrapped);
- VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped);
- VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
-
VIA("ddl", ViaDDL, 1, 3, wrapped);
VIA("ddl2", ViaDDL, 2, 3, wrapped);
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index b72c830..144227d 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -15,7 +15,6 @@
#include "include/core/SkExecutor.h"
#include "include/core/SkImageGenerator.h"
#include "include/core/SkMallocPixelRef.h"
-#include "include/core/SkMultiPictureDraw.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkStream.h"
#include "include/core/SkSurface.h"
@@ -1865,59 +1864,6 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
- : Via(sink)
- , fW(w)
- , fH(h)
- , fFactory(factory) {}
-
-Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
- auto size = src.size();
- SkPictureRecorder recorder;
- Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
- SkIntToScalar(size.height()),
- fFactory.get()));
- if (!err.isEmpty()) {
- return err;
- }
- sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture());
-
- return draw_to_canvas(fSink.get(), 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);
- SkTArray<sk_sp<SkSurface>> surfaces;
-// surfaces.setReserve(xTiles*yTiles);
-
- SkImageInfo info = canvas->imageInfo().makeWH(fW, fH);
- for (int j = 0; j < yTiles; j++) {
- for (int i = 0; i < xTiles; i++) {
- // This lets our ultimate Sink determine the best kind of surface.
- // E.g., if it's a GpuSink, the surfaces and images are textures.
- auto s = canvas->makeSurface(info);
- if (!s) {
- s = SkSurface::MakeRaster(info); // Some canvases can't create surfaces.
- }
- surfaces.push_back(s);
- SkCanvas* c = s->getCanvas();
- c->translate(SkIntToScalar(-i * fW),
- SkIntToScalar(-j * fH)); // Line up the canvas with this tile.
- mpd.add(c, pic.get());
- }
- }
- mpd.draw();
- for (int j = 0; j < yTiles; j++) {
- for (int i = 0; i < xTiles; i++) {
- sk_sp<SkImage> image(surfaces[i+xTiles*j]->makeImageSnapshot());
- canvas->drawImage(image, SkIntToScalar(i*fW), SkIntToScalar(j*fH));
- }
- }
- return "";
- });
-}
-
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
ViaDDL::ViaDDL(int numReplays, int numDivisions, Sink* sink)
: Via(sink), fNumReplays(numReplays), fNumDivisions(numDivisions) {}
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 5b7338b..63b3f7f 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -525,15 +525,6 @@
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
};
-class ViaTiles : public Via {
-public:
- ViaTiles(int w, int h, SkBBHFactory*, Sink*);
- Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
-private:
- const int fW, fH;
- std::unique_ptr<SkBBHFactory> fFactory;
-};
-
class ViaDDL : public Via {
public:
ViaDDL(int numReplays, int numDivisions, Sink* sink);
diff --git a/gm/multipicturedraw.cpp b/gm/multipicturedraw.cpp
deleted file mode 100644
index 688154e..0000000
--- a/gm/multipicturedraw.cpp
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gm/gm.h"
-#include "include/core/SkBBHFactory.h"
-#include "include/core/SkBlendMode.h"
-#include "include/core/SkCanvas.h"
-#include "include/core/SkColor.h"
-#include "include/core/SkColorFilter.h"
-#include "include/core/SkImageInfo.h"
-#include "include/core/SkMatrix.h"
-#include "include/core/SkMultiPictureDraw.h"
-#include "include/core/SkPaint.h"
-#include "include/core/SkPath.h"
-#include "include/core/SkPicture.h"
-#include "include/core/SkPictureRecorder.h"
-#include "include/core/SkRRect.h"
-#include "include/core/SkRect.h"
-#include "include/core/SkRefCnt.h"
-#include "include/core/SkScalar.h"
-#include "include/core/SkSize.h"
-#include "include/core/SkString.h"
-#include "include/core/SkSurface.h"
-#include "include/core/SkTypes.h"
-#include "include/private/SkTArray.h"
-#include "tools/ToolUtils.h"
-
-constexpr SkScalar kRoot3Over2 = 0.86602545f; // sin(60)
-constexpr SkScalar kRoot3 = 1.73205081f;
-
-constexpr int kHexSide = 30;
-constexpr int kNumHexX = 6;
-constexpr int kNumHexY = 6;
-constexpr int kPicWidth = kNumHexX * kHexSide;
-constexpr int kPicHeight = (int)((kNumHexY - 0.5f) * 2 * kHexSide * kRoot3Over2 + 0.5f);
-constexpr SkScalar kInset = 20.0f;
-constexpr int kNumPictures = 4;
-
-constexpr int kTriSide = 40;
-
-// Create a hexagon centered at (originX, originY)
-static SkPath make_hex_path(SkScalar originX, SkScalar originY) {
- SkPath hex;
- hex.moveTo(originX-kHexSide, originY);
- hex.rLineTo(SkScalarHalf(kHexSide), kRoot3Over2 * kHexSide);
- hex.rLineTo(SkIntToScalar(kHexSide), 0);
- hex.rLineTo(SkScalarHalf(kHexSide), -kHexSide * kRoot3Over2);
- hex.rLineTo(-SkScalarHalf(kHexSide), -kHexSide * kRoot3Over2);
- hex.rLineTo(-SkIntToScalar(kHexSide), 0);
- hex.close();
- return hex;
-}
-
-// Make a picture that is a tiling of the plane with stroked hexagons where
-// each hexagon is in its own layer. The layers are to exercise Ganesh's
-// layer hoisting.
-static sk_sp<SkPicture> make_hex_plane_picture(SkColor fillColor) {
-
- // Create a hexagon with its center at the origin
- SkPath hex = make_hex_path(0, 0);
-
- SkPaint fill;
- fill.setStyle(SkPaint::kFill_Style);
- fill.setColor(fillColor);
-
- SkPaint stroke;
- stroke.setStyle(SkPaint::kStroke_Style);
- stroke.setStrokeWidth(3);
-
- SkPictureRecorder recorder;
- SkRTreeFactory bbhFactory;
-
- SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
- SkIntToScalar(kPicHeight),
- &bbhFactory);
-
- SkScalar xPos, yPos = 0;
-
- for (int y = 0; y < kNumHexY; ++y) {
- xPos = 0;
-
- for (int x = 0; x < kNumHexX; ++x) {
- canvas->saveLayer(nullptr, nullptr);
- canvas->translate(xPos, yPos + ((x % 2) ? kRoot3Over2 * kHexSide : 0));
- canvas->drawPath(hex, fill);
- canvas->drawPath(hex, stroke);
- canvas->restore();
-
- xPos += 1.5f * kHexSide;
- }
-
- yPos += 2 * kHexSide * kRoot3Over2;
- }
-
- return recorder.finishRecordingAsPicture();
-}
-
-// Create a picture that consists of a single large layer that is tiled
-// with hexagons.
-// This is intended to exercise the layer hoisting code's clip handling (in
-// tile mode).
-static sk_sp<SkPicture> make_single_layer_hex_plane_picture() {
-
- // Create a hexagon with its center at the origin
- SkPath hex = make_hex_path(0, 0);
-
- SkPaint whiteFill;
- whiteFill.setStyle(SkPaint::kFill_Style);
- whiteFill.setColor(SK_ColorWHITE);
-
- SkPaint greyFill;
- greyFill.setStyle(SkPaint::kFill_Style);
- greyFill.setColor(SK_ColorLTGRAY);
-
- SkPaint stroke;
- stroke.setStyle(SkPaint::kStroke_Style);
- stroke.setStrokeWidth(3);
-
- SkPictureRecorder recorder;
- SkRTreeFactory bbhFactory;
-
- constexpr SkScalar kBig = 10000.0f;
- SkCanvas* canvas = recorder.beginRecording(kBig, kBig, &bbhFactory);
-
- canvas->saveLayer(nullptr, nullptr);
-
- SkScalar xPos = 0.0f, yPos = 0.0f;
-
- for (int y = 0; yPos < kBig; ++y) {
- xPos = 0;
-
- for (int x = 0; xPos < kBig; ++x) {
- canvas->save();
- canvas->translate(xPos, yPos + ((x % 2) ? kRoot3Over2 * kHexSide : 0));
- // The color of the filled hex is swapped to yield a different
- // pattern in each tile. This allows an error in layer hoisting (e.g.,
- // the clip isn't blocking cache reuse) to cause a visual discrepancy.
- canvas->drawPath(hex, ((x+y) % 3) ? whiteFill : greyFill);
- canvas->drawPath(hex, stroke);
- canvas->restore();
-
- xPos += 1.5f * kHexSide;
- }
-
- yPos += 2 * kHexSide * kRoot3Over2;
- }
-
- canvas->restore();
-
- return recorder.finishRecordingAsPicture();
-}
-
-// Make an equilateral triangle path with its top corner at (originX, originY)
-static SkPath make_tri_path(SkScalar originX, SkScalar originY) {
- SkPath tri;
- tri.moveTo(originX, originY);
- tri.rLineTo(SkScalarHalf(kTriSide), 1.5f * kTriSide / kRoot3);
- tri.rLineTo(-kTriSide, 0);
- tri.close();
- return tri;
-}
-
-static sk_sp<SkPicture> make_tri_picture() {
- SkPath tri = make_tri_path(SkScalarHalf(kTriSide), 0);
-
- SkPaint fill;
- fill.setStyle(SkPaint::kFill_Style);
- fill.setColor(SK_ColorLTGRAY);
-
- SkPaint stroke;
- stroke.setStyle(SkPaint::kStroke_Style);
- stroke.setStrokeWidth(3);
-
- SkPictureRecorder recorder;
- SkRTreeFactory bbhFactory;
-
- SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
- SkIntToScalar(kPicHeight),
- &bbhFactory);
- SkRect r = tri.getBounds();
- r.outset(2.0f, 2.0f); // outset for stroke
- canvas->clipRect(r);
- // The saveLayer/restore block is to exercise layer hoisting
- canvas->saveLayer(nullptr, nullptr);
- canvas->drawPath(tri, fill);
- canvas->drawPath(tri, stroke);
- canvas->restore();
-
- return recorder.finishRecordingAsPicture();
-}
-
-static sk_sp<SkPicture> make_sub_picture(const SkPicture* tri) {
- SkPictureRecorder recorder;
- SkRTreeFactory bbhFactory;
-
- SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
- SkIntToScalar(kPicHeight),
- &bbhFactory);
-
- canvas->scale(1.0f/2.0f, 1.0f/2.0f);
-
- canvas->save();
- canvas->translate(SkScalarHalf(kTriSide), 0);
- canvas->drawPicture(tri);
- canvas->restore();
-
- canvas->save();
- canvas->translate(SkIntToScalar(kTriSide), 1.5f * kTriSide / kRoot3);
- canvas->drawPicture(tri);
- canvas->restore();
-
- canvas->save();
- canvas->translate(0, 1.5f * kTriSide / kRoot3);
- canvas->drawPicture(tri);
- canvas->restore();
-
- return recorder.finishRecordingAsPicture();
-}
-
-// Create a Sierpinkski-like picture that starts with a top row with a picture
-// that just contains a triangle. Subsequent rows take the prior row's picture,
-// shrinks it and replicates it 3 times then draws and appropriate number of
-// copies of it.
-static sk_sp<SkPicture> make_sierpinski_picture() {
- sk_sp<SkPicture> pic(make_tri_picture());
-
- SkPictureRecorder recorder;
- SkRTreeFactory bbhFactory;
-
- SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
- SkIntToScalar(kPicHeight),
- &bbhFactory);
-
- constexpr int kNumLevels = 4;
- for (int i = 0; i < kNumLevels; ++i) {
- canvas->save();
- canvas->translate(kPicWidth/2 - (i+1) * (kTriSide/2.0f), 0.0f);
- for (int j = 0; j < i+1; ++j) {
- canvas->drawPicture(pic);
- canvas->translate(SkIntToScalar(kTriSide), 0);
- }
- canvas->restore();
-
- pic = make_sub_picture(pic.get());
-
- canvas->translate(0, 1.5f * kTriSide / kRoot3);
- }
-
- return recorder.finishRecordingAsPicture();
-}
-
-static sk_sp<SkSurface> create_compat_surface(SkCanvas* canvas, int width, int height) {
- SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
-
- return ToolUtils::makeSurface(canvas, info);
-}
-
-// This class stores the information required to compose all the result
-// fragments potentially generated by the MultiPictureDraw object
-class ComposeStep {
-public:
- ComposeStep() : fX(0.0f), fY(0.0f), fPaint(nullptr) { }
- ~ComposeStep() {
- delete fPaint;
- }
-
- sk_sp<SkSurface> fSurf;
- SkScalar fX;
- SkScalar fY;
- SkPaint* fPaint;
-};
-
-typedef void (*PFContentMtd)(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]);
-
-// Just a single picture with no clip
-static void no_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
- canvas->drawPicture(pictures[0]);
-}
-
-// Two pictures with a rect clip on the second one
-static void rect_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
- canvas->drawPicture(pictures[0]);
-
- SkRect rect = pictures[0]->cullRect();
- rect.inset(kInset, kInset);
-
- canvas->clipRect(rect);
-
- canvas->drawPicture(pictures[1]);
-}
-
-// Two pictures with a round rect clip on the second one
-static void rrect_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
- canvas->drawPicture(pictures[0]);
-
- SkRect rect = pictures[0]->cullRect();
- rect.inset(kInset, kInset);
-
- SkRRect rrect;
- rrect.setRectXY(rect, kInset, kInset);
-
- canvas->clipRRect(rrect);
-
- canvas->drawPicture(pictures[1]);
-}
-
-// Two pictures with a clip path on the second one
-static void path_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
- canvas->drawPicture(pictures[0]);
-
- // Create a hexagon centered on the middle of the hex grid
- SkPath hex = make_hex_path((kNumHexX / 2.0f) * kHexSide, kNumHexY * kHexSide * kRoot3Over2);
-
- canvas->clipPath(hex);
-
- canvas->drawPicture(pictures[1]);
-}
-
-// Two pictures with an inverse clip path on the second one
-static void invpath_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
- canvas->drawPicture(pictures[0]);
-
- // Create a hexagon centered on the middle of the hex grid
- SkPath hex = make_hex_path((kNumHexX / 2.0f) * kHexSide, kNumHexY * kHexSide * kRoot3Over2);
- hex.setFillType(SkPath::kInverseEvenOdd_FillType);
-
- canvas->clipPath(hex);
-
- canvas->drawPicture(pictures[1]);
-}
-
-// Reuse a single base (triangular) picture a _lot_ (rotated, scaled and translated).
-static void sierpinski(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
- canvas->save();
- canvas->drawPicture(pictures[2]);
-
- canvas->rotate(180.0f);
- canvas->translate(-SkIntToScalar(kPicWidth), -SkIntToScalar(kPicHeight));
- canvas->drawPicture(pictures[2]);
- canvas->restore();
-}
-
-static void big_layer(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
- canvas->drawPicture(pictures[3]);
-}
-
-constexpr PFContentMtd gContentMthds[] = {
- no_clip,
- rect_clip,
- rrect_clip,
- path_clip,
- invpath_clip,
- sierpinski,
- big_layer,
-};
-
-static void create_content(SkMultiPictureDraw* mpd, PFContentMtd pfGen,
- const SkPicture* pictures[kNumPictures],
- SkCanvas* dest, const SkMatrix& xform) {
- sk_sp<SkPicture> composite;
-
- {
- SkPictureRecorder recorder;
- SkRTreeFactory bbhFactory;
-
- SkCanvas* pictureCanvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
- SkIntToScalar(kPicHeight),
- &bbhFactory);
-
- (*pfGen)(pictureCanvas, pictures);
-
- composite = recorder.finishRecordingAsPicture();
- }
-
- mpd->add(dest, composite.get(), &xform);
-}
-
-typedef void(*PFLayoutMtd)(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd,
- PFContentMtd pfGen, const SkPicture* pictures[kNumPictures],
- SkTArray<ComposeStep>* composeSteps);
-
-// Draw the content into a single canvas
-static void simple(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd,
- PFContentMtd pfGen,
- const SkPicture* pictures[kNumPictures],
- SkTArray<ComposeStep> *composeSteps) {
-
- ComposeStep& step = composeSteps->push_back();
-
- step.fSurf = create_compat_surface(finalCanvas, kPicWidth, kPicHeight);
-
- SkCanvas* subCanvas = step.fSurf->getCanvas();
-
- create_content(mpd, pfGen, pictures, subCanvas, SkMatrix::I());
-}
-
-// Draw the content into multiple canvases/tiles
-static void tiled(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd,
- PFContentMtd pfGen,
- const SkPicture* pictures[kNumPictures],
- SkTArray<ComposeStep> *composeSteps) {
- const int kNumTilesX = 2;
- const int kNumTilesY = 2;
- const int kTileWidth = kPicWidth / kNumTilesX;
- const int kTileHeight = kPicHeight / kNumTilesY;
-
- SkASSERT(kPicWidth == kNumTilesX * kTileWidth);
- SkASSERT(kPicHeight == kNumTilesY * kTileHeight);
-
- const SkColor colors[kNumTilesX][kNumTilesY] = {
- { SK_ColorCYAN, SK_ColorMAGENTA },
- { SK_ColorYELLOW, SK_ColorGREEN }
- };
-
- for (int y = 0; y < kNumTilesY; ++y) {
- for (int x = 0; x < kNumTilesX; ++x) {
- ComposeStep& step = composeSteps->push_back();
-
- step.fX = SkIntToScalar(x*kTileWidth);
- step.fY = SkIntToScalar(y*kTileHeight);
- step.fPaint = new SkPaint;
- step.fPaint->setColorFilter(
- SkColorFilters::Blend(colors[x][y], SkBlendMode::kModulate));
-
- step.fSurf = create_compat_surface(finalCanvas, kTileWidth, kTileHeight);
-
- SkCanvas* subCanvas = step.fSurf->getCanvas();
-
- const SkMatrix trans = SkMatrix::MakeTrans(-SkIntToScalar(x*kTileWidth),
- -SkIntToScalar(y*kTileHeight));
-
- create_content(mpd, pfGen, pictures, subCanvas, trans);
- }
- }
-}
-
-constexpr PFLayoutMtd gLayoutMthds[] = { simple, tiled };
-
-namespace skiagm {
- /**
- * This GM exercises the SkMultiPictureDraw object. It tests the
- * cross product of:
- * tiled vs. all-at-once rendering (e.g., into many or just 1 canvas)
- * different clips (e.g., none, rect, rrect)
- * single vs. multiple pictures (e.g., normal vs. picture-pile-style content)
- */
- class MultiPictureDraw : public GM {
- public:
- enum Content {
- kNoClipSingle_Content,
- kRectClipMulti_Content,
- kRRectClipMulti_Content,
- kPathClipMulti_Content,
- kInvPathClipMulti_Content,
- kSierpinski_Content,
- kBigLayer_Content,
-
- kLast_Content = kBigLayer_Content
- };
-
- const int kContentCnt = kLast_Content + 1;
-
- enum Layout {
- kSimple_Layout,
- kTiled_Layout,
-
- kLast_Layout = kTiled_Layout
- };
-
- const int kLayoutCnt = kLast_Layout + 1;
-
- MultiPictureDraw(Content content, Layout layout) : fContent(content), fLayout(layout) {
- SkASSERT(SK_ARRAY_COUNT(gLayoutMthds) == kLayoutCnt);
- SkASSERT(SK_ARRAY_COUNT(gContentMthds) == kContentCnt);
-
- for (int i = 0; i < kNumPictures; ++i) {
- fPictures[i] = nullptr;
- }
- }
-
- ~MultiPictureDraw() override {
- for (int i = 0; i < kNumPictures; ++i) {
- SkSafeUnref(fPictures[i]);
- }
- }
-
- protected:
- Content fContent;
- Layout fLayout;
- const SkPicture* fPictures[kNumPictures];
-
- void onOnceBeforeDraw() override {
- fPictures[0] = make_hex_plane_picture(SK_ColorWHITE).release();
- fPictures[1] = make_hex_plane_picture(SK_ColorGRAY).release();
- fPictures[2] = make_sierpinski_picture().release();
- fPictures[3] = make_single_layer_hex_plane_picture().release();
- }
-
- void onDraw(SkCanvas* canvas) override {
- SkMultiPictureDraw mpd;
- SkTArray<ComposeStep> composeSteps;
-
- // Fill up the MultiPictureDraw
- (*gLayoutMthds[fLayout])(canvas, &mpd,
- gContentMthds[fContent],
- fPictures, &composeSteps);
-
- mpd.draw();
-
- // Compose all the drawn canvases into the final canvas
- for (int i = 0; i < composeSteps.count(); ++i) {
- const ComposeStep& step = composeSteps[i];
-
- canvas->drawImage(step.fSurf->makeImageSnapshot().get(),
- step.fX, step.fY, step.fPaint);
- }
- }
-
- SkISize onISize() override { return SkISize::Make(kPicWidth, kPicHeight); }
-
- SkString onShortName() override {
- const char* gContentNames[] = {
- "noclip", "rectclip", "rrectclip", "pathclip",
- "invpathclip", "sierpinski", "biglayer"
- };
- const char* gLayoutNames[] = { "simple", "tiled" };
-
- SkASSERT(SK_ARRAY_COUNT(gLayoutNames) == kLayoutCnt);
- SkASSERT(SK_ARRAY_COUNT(gContentNames) == kContentCnt);
-
- SkString name("multipicturedraw_");
-
- name.append(gContentNames[fContent]);
- name.append("_");
- name.append(gLayoutNames[fLayout]);
- return name;
- }
-
- bool runAsBench() const override { return true; }
-
- private:
- typedef GM INHERITED;
- };
-
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kNoClipSingle_Content,
- MultiPictureDraw::kSimple_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRectClipMulti_Content,
- MultiPictureDraw::kSimple_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRRectClipMulti_Content,
- MultiPictureDraw::kSimple_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content,
- MultiPictureDraw::kSimple_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Content,
- MultiPictureDraw::kSimple_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content,
- MultiPictureDraw::kSimple_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content,
- MultiPictureDraw::kSimple_Layout);)
-
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kNoClipSingle_Content,
- MultiPictureDraw::kTiled_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRectClipMulti_Content,
- MultiPictureDraw::kTiled_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRRectClipMulti_Content,
- MultiPictureDraw::kTiled_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content,
- MultiPictureDraw::kTiled_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Content,
- MultiPictureDraw::kTiled_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content,
- MultiPictureDraw::kTiled_Layout);)
- DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content,
- MultiPictureDraw::kTiled_Layout);)
-}
diff --git a/gn/core.gni b/gn/core.gni
index 8d374d7..030ca4b 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -550,17 +550,14 @@
]
skia_skpicture_public = [
- "$_include/core/SkMultiPictureDraw.h",
"$_include/core/SkPicture.h",
"$_include/core/SkPictureRecorder.h",
]
skia_skpicture_sources = [
- "$_include/core/SkMultiPictureDraw.h",
"$_include/core/SkPicture.h",
"$_include/core/SkPictureRecorder.h",
"$_src/core/SkBigPicture.cpp",
- "$_src/core/SkMultiPictureDraw.cpp",
"$_src/core/SkPicture.cpp",
"$_src/core/SkPictureCommon.h",
"$_src/core/SkPictureData.cpp",
diff --git a/gn/gm.gni b/gn/gm.gni
index ea720f5..b8b1f19 100644
--- a/gn/gm.gni
+++ b/gn/gm.gni
@@ -246,7 +246,6 @@
"$_gm/mixercolorfilter.cpp",
"$_gm/modecolorfilters.cpp",
"$_gm/morphology.cpp",
- "$_gm/multipicturedraw.cpp",
"$_gm/nested.cpp",
"$_gm/ninepatchstretch.cpp",
"$_gm/nonclosedpaths.cpp",
diff --git a/include/core/SkMultiPictureDraw.h b/include/core/SkMultiPictureDraw.h
deleted file mode 100644
index 70c4e16..0000000
--- a/include/core/SkMultiPictureDraw.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkMultiPictureDraw_DEFINED
-#define SkMultiPictureDraw_DEFINED
-
-#include "include/core/SkMatrix.h"
-#include "include/private/SkTDArray.h"
-
-class SkCanvas;
-class SkPaint;
-class SkPicture;
-
-/** \class SkMultiPictureDraw
-
- The MultiPictureDraw object accepts several picture/canvas pairs and
- then attempts to optimally draw the pictures into the canvases, sharing
- as many resources as possible.
-*/
-class SK_API SkMultiPictureDraw {
-public:
- /**
- * Create an object to optimize the drawing of multiple pictures.
- * @param reserve Hint for the number of add calls expected to be issued
- */
- SkMultiPictureDraw(int reserve = 0);
- ~SkMultiPictureDraw() { this->reset(); }
-
- /**
- * Add a canvas/picture pair for later rendering.
- * @param canvas the canvas in which to draw picture
- * @param picture the picture to draw into canvas
- * @param matrix if non-NULL, applied to the CTM when drawing
- * @param paint if non-NULL, draw picture to a temporary buffer
- * and then apply the paint when the result is drawn
- */
- void add(SkCanvas* canvas,
- const SkPicture* picture,
- const SkMatrix* matrix = nullptr,
- const SkPaint* paint = nullptr);
-
- /**
- * Perform all the previously added draws. This will reset the state
- * of this object. If flush is true, all canvases are flushed after
- * draw.
- */
- void draw(bool flush = false);
-
- /**
- * Abandon all buffered draws and reset to the initial state.
- */
- void reset();
-
-private:
- struct DrawData {
- SkCanvas* fCanvas;
- const SkPicture* fPicture; // reffed
- SkMatrix fMatrix;
- SkPaint* fPaint; // owned
-
- void init(SkCanvas*, const SkPicture*, const SkMatrix*, const SkPaint*);
- void draw();
-
- static void Reset(SkTDArray<DrawData>&);
- };
-
- SkTDArray<DrawData> fThreadSafeDrawData;
- SkTDArray<DrawData> fGPUDrawData;
-};
-
-#endif
diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json
index 070f57c..2716abd 100644
--- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json
+++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json
@@ -208,7 +208,6 @@
"g8",
"565",
"pic-8888",
- "tiles_rt-8888",
"serialize-8888",
"f16",
"srgb",
@@ -610,14 +609,6 @@
"gm",
"_",
"blurrect_compare",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_bw",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_aa",
"--nonativeFonts",
"--verbose"
],
diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-BonusConfigs.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-BonusConfigs.json
index beb65c9..ab0f2ca 100644
--- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-BonusConfigs.json
+++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-BonusConfigs.json
@@ -289,7 +289,6 @@
"g8",
"565",
"pic-8888",
- "tiles_rt-8888",
"serialize-8888",
"f16",
"srgb",
@@ -686,14 +685,6 @@
"gm",
"_",
"blurrect_compare",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_bw",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_aa",
"--nonativeFonts",
"--verbose"
],
diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json
index fb2fcdf..a100472 100644
--- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json
+++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json
@@ -207,7 +207,6 @@
"g8",
"565",
"pic-8888",
- "tiles_rt-8888",
"serialize-8888",
"f16",
"srgb",
@@ -604,14 +603,6 @@
"gm",
"_",
"blurrect_compare",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_bw",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_aa",
"--match",
"~Once",
"~Shared",
diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json
index 4094064..f65e34a 100644
--- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json
+++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json
@@ -208,7 +208,6 @@
"g8",
"565",
"pic-8888",
- "tiles_rt-8888",
"serialize-8888",
"f16",
"srgb",
@@ -605,14 +604,6 @@
"gm",
"_",
"blurrect_compare",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_bw",
- "tiles_rt-8888",
- "gm",
- "_",
- "complexclip4_aa",
"--match",
"~ReadWriteAlpha",
"~RGBA4444TextureTest",
diff --git a/infra/bots/recipes/test.py b/infra/bots/recipes/test.py
index 6f4fa20..0643453 100644
--- a/infra/bots/recipes/test.py
+++ b/infra/bots/recipes/test.py
@@ -110,7 +110,7 @@
configs.extend([
'pdf',
'g8', '565',
- 'pic-8888', 'tiles_rt-8888', 'serialize-8888',
+ 'pic-8888', 'serialize-8888',
'f16', 'srgb', 'esrgb', 'narrow', 'enarrow',
'p3', 'ep3', 'rec2020', 'erec2020'])
@@ -602,10 +602,6 @@
blacklist([ 'pic-8888', 'gm', '_', "blurrect_compare"])
blacklist(['serialize-8888', 'gm', '_', "blurrect_compare"])
- # GM that not support tiles_rt
- for test in ['complexclip4_bw', 'complexclip4_aa']:
- blacklist([ 'tiles_rt-8888', 'gm', '_', test])
-
# Extensions for RAW images
r = ['arw', 'cr2', 'dng', 'nef', 'nrw', 'orf', 'raf', 'rw2', 'pef', 'srw',
'ARW', 'CR2', 'DNG', 'NEF', 'NRW', 'ORF', 'RAF', 'RW2', 'PEF', 'SRW']
diff --git a/src/core/SkMultiPictureDraw.cpp b/src/core/SkMultiPictureDraw.cpp
deleted file mode 100644
index 837aa60..0000000
--- a/src/core/SkMultiPictureDraw.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014 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/SkCanvas.h"
-#include "include/core/SkMultiPictureDraw.h"
-#include "include/core/SkPicture.h"
-#include "src/core/SkCanvasPriv.h"
-#include "src/core/SkTaskGroup.h"
-
-void SkMultiPictureDraw::DrawData::draw() {
- fCanvas->drawPicture(fPicture, &fMatrix, fPaint);
-}
-
-void SkMultiPictureDraw::DrawData::init(SkCanvas* canvas, const SkPicture* picture,
- const SkMatrix* matrix, const SkPaint* paint) {
- fPicture = SkRef(picture);
- fCanvas = canvas;
- if (matrix) {
- fMatrix = *matrix;
- } else {
- fMatrix.setIdentity();
- }
- if (paint) {
- fPaint = new SkPaint(*paint);
- } else {
- fPaint = nullptr;
- }
-}
-
-void SkMultiPictureDraw::DrawData::Reset(SkTDArray<DrawData>& data) {
- for (int i = 0; i < data.count(); ++i) {
- data[i].fPicture->unref();
- delete data[i].fPaint;
- }
- data.rewind();
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-
-SkMultiPictureDraw::SkMultiPictureDraw(int reserve) {
- if (reserve > 0) {
- fGPUDrawData.setReserve(reserve);
- fThreadSafeDrawData.setReserve(reserve);
- }
-}
-
-void SkMultiPictureDraw::reset() {
- DrawData::Reset(fGPUDrawData);
- DrawData::Reset(fThreadSafeDrawData);
-}
-
-void SkMultiPictureDraw::add(SkCanvas* canvas,
- const SkPicture* picture,
- const SkMatrix* matrix,
- const SkPaint* paint) {
- if (nullptr == canvas || nullptr == picture) {
- SkDEBUGFAIL("parameters to SkMultiPictureDraw::add should be non-nullptr");
- return;
- }
-
- SkTDArray<DrawData>& array = canvas->getGrContext() ? fGPUDrawData : fThreadSafeDrawData;
- array.append()->init(canvas, picture, matrix, paint);
-}
-
-class AutoMPDReset : SkNoncopyable {
- SkMultiPictureDraw* fMPD;
-public:
- AutoMPDReset(SkMultiPictureDraw* mpd) : fMPD(mpd) {}
- ~AutoMPDReset() { fMPD->reset(); }
-};
-
-//#define FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
-
-void SkMultiPictureDraw::draw(bool flush) {
- AutoMPDReset mpdreset(this);
-
-#ifdef FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
- for (int i = 0; i < fThreadSafeDrawData.count(); ++i) {
- fThreadSafeDrawData[i].draw();
- }
-#else
- SkTaskGroup().batch(fThreadSafeDrawData.count(), [&](int i) {
- fThreadSafeDrawData[i].draw();
- });
-#endif
-
- // N.B. we could get going on any GPU work from this main thread while the CPU work runs.
- // But in practice, we've either got GPU work or CPU work, not both.
-
- const int count = fGPUDrawData.count();
- if (0 == count) {
- return;
- }
-
- for (int i = 0; i < count; ++i) {
- const DrawData& data = fGPUDrawData[i];
- SkCanvas* canvas = data.fCanvas;
- const SkPicture* picture = data.fPicture;
-
- canvas->drawPicture(picture, &data.fMatrix, data.fPaint);
- if (flush) {
- canvas->flush();
- }
- }
-}