2015-03-25 14:11:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
#ifndef DMSrcSink_DEFINED
|
|
|
|
#define DMSrcSink_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
|
|
|
#include "include/core/SkBBHFactory.h"
|
|
|
|
#include "include/core/SkBitmap.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkData.h"
|
|
|
|
#include "include/core/SkPicture.h"
|
|
|
|
#include "src/utils/SkMultiPictureDocument.h"
|
|
|
|
#include "tools/flags/CommonFlagsConfig.h"
|
2019-06-27 20:43:27 +00:00
|
|
|
#include "tools/gpu/MemoryCache.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2019-09-06 18:42:43 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2017-02-18 21:50:45 +00:00
|
|
|
//#define TEST_VIA_SVG
|
|
|
|
|
2020-02-04 21:09:08 +00:00
|
|
|
namespace skiagm {
|
|
|
|
namespace verifiers {
|
|
|
|
class VerifierList;
|
2020-08-06 18:11:56 +00:00
|
|
|
} // namespace verifiers
|
|
|
|
} // namespace skiagm
|
2020-02-04 21:09:08 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
// This is just convenience. It lets you use either return "foo" or return SkStringPrintf(...).
|
|
|
|
struct ImplicitString : public SkString {
|
|
|
|
template <typename T>
|
|
|
|
ImplicitString(const T& s) : SkString(s) {}
|
2015-09-01 21:57:57 +00:00
|
|
|
ImplicitString() : SkString("") {}
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
typedef ImplicitString Name;
|
2015-01-30 19:42:31 +00:00
|
|
|
typedef ImplicitString Path;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
class Result {
|
2015-03-05 16:40:28 +00:00
|
|
|
public:
|
2020-02-12 16:18:46 +00:00
|
|
|
enum class Status : int { Ok, Fatal, Skip };
|
|
|
|
Result(Status status, const SkString& s) : fMsg(s), fStatus(status) {}
|
|
|
|
Result(Status status, const char* s) : fMsg(s), fStatus(status) {}
|
|
|
|
template <typename... Args> Result (Status status, const char* s, Args... args)
|
|
|
|
: fMsg(SkStringPrintf(s, args...)), fStatus(status) {}
|
2015-03-05 16:40:28 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result(const Result&) = default;
|
|
|
|
Result& operator=(const Result&) = default;
|
2015-03-05 16:40:28 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
static Result Ok() { return Result(Status::Ok, nullptr); }
|
|
|
|
|
|
|
|
static Result Fatal(const SkString& s) { return Result(Status::Fatal, s); }
|
|
|
|
static Result Fatal(const char* s) { return Result(Status::Fatal, s); }
|
|
|
|
template <typename... Args> static Result Fatal(const char* s, Args... args) {
|
|
|
|
return Result(Status::Fatal, s, args...);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Result Skip(const SkString& s) { return Result(Status::Skip, s); }
|
|
|
|
static Result Skip(const char* s) { return Result(Status::Skip, s); }
|
|
|
|
template <typename... Args> static Result Skip(const char* s, Args... args) {
|
|
|
|
return Result(Status::Skip, s, args...);
|
2015-03-05 16:40:28 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
bool isOk() { return fStatus == Status::Ok; }
|
|
|
|
bool isFatal() { return fStatus == Status::Fatal; }
|
|
|
|
bool isSkip() { return fStatus == Status::Skip; }
|
|
|
|
|
2015-03-05 16:40:28 +00:00
|
|
|
const char* c_str() const { return fMsg.c_str(); }
|
2020-02-12 16:18:46 +00:00
|
|
|
Status status() const { return fStatus; }
|
2015-03-05 16:40:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkString fMsg;
|
2020-02-12 16:18:46 +00:00
|
|
|
Status fStatus;
|
2015-03-05 16:40:28 +00:00
|
|
|
};
|
|
|
|
|
2015-07-31 13:43:04 +00:00
|
|
|
struct SinkFlags {
|
2017-03-07 14:08:36 +00:00
|
|
|
enum Type { kNull, kGPU, kVector, kRaster } type;
|
|
|
|
enum Approach { kDirect, kIndirect } approach;
|
|
|
|
enum Multisampled { kNotMultisampled, kMultisampled } multisampled;
|
|
|
|
SinkFlags(Type t, Approach a, Multisampled ms = kNotMultisampled)
|
|
|
|
: type(t), approach(a), multisampled(ms) {}
|
2015-07-31 13:43:04 +00:00
|
|
|
};
|
2015-07-29 13:37:28 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
struct Src {
|
|
|
|
virtual ~Src() {}
|
2021-07-20 16:50:40 +00:00
|
|
|
virtual Result SK_WARN_UNUSED_RESULT draw(GrDirectContext* context, SkCanvas* canvas) const = 0;
|
2015-01-15 18:56:12 +00:00
|
|
|
virtual SkISize size() const = 0;
|
|
|
|
virtual Name name() const = 0;
|
2015-05-27 20:23:23 +00:00
|
|
|
virtual void modifyGrContextOptions(GrContextOptions* options) const {}
|
2015-07-31 13:43:04 +00:00
|
|
|
virtual bool veto(SinkFlags) const { return false; }
|
2016-02-08 20:39:59 +00:00
|
|
|
|
2016-06-02 19:41:14 +00:00
|
|
|
virtual int pageCount() const { return 1; }
|
2021-07-20 16:50:40 +00:00
|
|
|
virtual Result SK_WARN_UNUSED_RESULT draw([[maybe_unused]] int page, GrDirectContext* context,
|
2020-07-01 18:45:24 +00:00
|
|
|
SkCanvas* canvas) const {
|
2020-06-16 15:11:33 +00:00
|
|
|
return this->draw(context, canvas);
|
2016-06-02 19:41:14 +00:00
|
|
|
}
|
2021-07-20 16:50:40 +00:00
|
|
|
virtual SkISize size([[maybe_unused]] int page) const { return this->size(); }
|
2016-02-08 20:39:59 +00:00
|
|
|
// Force Tasks using this Src to run on the main thread?
|
|
|
|
virtual bool serial() const { return false; }
|
2020-02-04 21:09:08 +00:00
|
|
|
|
|
|
|
/** Return a list of verifiers for the src, or null if no verifiers should be run .*/
|
|
|
|
virtual std::unique_ptr<skiagm::verifiers::VerifierList> getVerifiers() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Sink {
|
|
|
|
virtual ~Sink() {}
|
2015-02-03 02:26:03 +00:00
|
|
|
// You may write to either the bitmap or stream. If you write to log, we'll print that out.
|
2020-02-12 16:18:46 +00:00
|
|
|
virtual Result SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log)
|
2015-02-03 02:26:03 +00:00
|
|
|
const = 0;
|
2016-02-08 20:39:59 +00:00
|
|
|
|
2021-08-11 21:06:42 +00:00
|
|
|
// Override the color space of this Sink, after creation
|
|
|
|
virtual void setColorSpace(sk_sp<SkColorSpace>) {}
|
|
|
|
|
2016-02-08 20:39:59 +00:00
|
|
|
// Force Tasks using this Sink to run on the main thread?
|
|
|
|
virtual bool serial() const { return false; }
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
// File extension for the content draw() outputs, e.g. "png", "pdf".
|
|
|
|
virtual const char* fileExtension() const = 0;
|
2015-07-31 13:43:04 +00:00
|
|
|
|
|
|
|
virtual SinkFlags flags() const = 0;
|
2020-02-04 21:09:08 +00:00
|
|
|
|
|
|
|
/** Returns the color type and space used by the sink. */
|
|
|
|
virtual SkColorInfo colorInfo() const { return SkColorInfo(); }
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
|
|
|
class GMSrc : public Src {
|
|
|
|
public:
|
2018-07-30 21:07:07 +00:00
|
|
|
explicit GMSrc(skiagm::GMFactory);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
2015-05-27 20:23:23 +00:00
|
|
|
void modifyGrContextOptions(GrContextOptions* options) const override;
|
|
|
|
|
2020-02-04 21:09:08 +00:00
|
|
|
std::unique_ptr<skiagm::verifiers::VerifierList> getVerifiers() const override;
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
private:
|
2018-07-30 21:07:07 +00:00
|
|
|
skiagm::GMFactory fFactory;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2015-03-19 13:03:39 +00:00
|
|
|
class CodecSrc : public Src {
|
|
|
|
public:
|
2015-03-25 20:48:49 +00:00
|
|
|
enum Mode {
|
2015-09-01 21:57:57 +00:00
|
|
|
kCodec_Mode,
|
2016-01-13 17:31:39 +00:00
|
|
|
// We choose to test only one mode with zero initialized memory.
|
|
|
|
// This will exercise all of the interesting cases in SkSwizzler
|
|
|
|
// without doubling the size of our test suite.
|
|
|
|
kCodecZeroInit_Mode,
|
2015-03-25 20:48:49 +00:00
|
|
|
kScanline_Mode,
|
2015-06-11 21:27:27 +00:00
|
|
|
kStripe_Mode, // Tests the skipping of scanlines
|
2016-02-22 20:27:46 +00:00
|
|
|
kCroppedScanline_Mode, // Tests (jpeg) cropped scanline optimization
|
2015-07-22 14:16:20 +00:00
|
|
|
kSubset_Mode, // For codecs that support subsets directly.
|
Add support for multiple frames in SkCodec
Add an interface to decode frames beyond the first in SkCodec, and
add an implementation for SkGifCodec.
Add getFrameData to SkCodec. This method reads ahead in the stream
to return a vector containing meta data about each frame in the image.
This is not required in order to decode frames beyond the first, but
it allows a client to learn extra information:
- how long the frame should be displayed
- whether a frame should be blended with a prior frame, allowing the
client to provide the prior frame to speed up decoding
Add a new fields to SkCodec::Options:
- fFrameIndex
- fHasPriorFrame
The API is designed so that SkCodec never caches frames. If a
client wants a frame beyond the first, they specify the frame in
Options.fFrameIndex. If the client does not have the
frame's required frame (the frame that this frame must be blended on
top of) cached, they pass false for
Options.fHasPriorFrame. Unless the frame is
independent, the codec will then recursively decode all frames
necessary to decode fFrameIndex. If the client has the required frame
cached, they can put it in the dst they pass to the codec, and the
codec will only draw fFrameIndex onto it.
Replace SkGifCodec's scanline decoding support with progressive
decoding, and update the tests accordingly.
Implement new APIs in SkGifCodec. Instead of using gif_lib, use
GIFImageReader, imported from Chromium (along with its copyright
headers) with the following changes:
- SkGifCodec is now the client
- Replace blink types
- Combine GIFColorMap::buildTable and ::getTable into a method that
creates and returns an SkColorTable
- Input comes from an SkStream, instead of a SegmentReader. Add
SkStreamBuffer, which buffers the (potentially partial) stream in
order to decode progressively.
(FIXME: This requires copying data that previously was read directly
from the SegmentReader. Does this hurt performance? If so, can we
fix it?)
- Remove UMA code
- Instead of reporting screen width and height to the client, allow the
client to query for it
- Fail earlier if the first frame AND screen have size of zero
- Compute required previous frame when adding a new one
- Move GIFParseQuery from GIFImageDecoder to GIFImageReader
- Allow parsing up to a specific frame (to skip parsing the rest of the
stream if a client only wants the first frame)
- Compute whether the first frame has alpha and supports index 8, to
create the SkImageInfo. This happens before reporting that the size
has been decoded.
Add GIFImageDecoder::haveDecodedRow to SkGifCodec, imported from
Chromium (along with its copyright header), with the following changes:
- Add support for sampling
- Use the swizzler
- Keep track of the rows decoded
- Do *not* keep track of whether we've seen alpha
Remove SkCodec::kOutOfOrder_SkScanlineOrder, which was only used by GIF
scanline decoding.
Call onRewind even if there is no stream (SkGifCodec needs to clear its
decoded state so it will decode from the beginning).
Add a method to SkSwizzler to access the offset into the dst, taking
subsetting into account.
Add a GM that animates a GIF.
Add tests for the new APIs.
*** Behavior changes:
* Previously, we reported that an image with a subset frame and no transparent
index was opaque and used the background index (if present) to fill the
background. This is necessary in order to support index 8, but it does not
match viewers/browsers I have seen. Examples:
- Chromium and Gimp render the background transparent
- Firefox, Safari, Linux Image Viewer, Safari Preview clip to the frame (for
a single frame image)
This CL matches Chromium's behavior and renders the background transparent.
This allows us to have consistent behavior across products and simplifies
the code (relative to what we would have to do to continue the old behavior
on Android). It also means that we will no longer support index 8 for some
GIFs.
* Stop checking for GIFSTAMP - all GIFs should be either 89a or 87a.
This matches Chromium. I suspect that bugs would have been reported if valid
GIFs started with "GIFVER" instead of "GIF89a" or "GIF87a" (but did not decode
in Chromium).
*** Future work not included in this CL:
* Move some checks out of haveDecodedRow, since they are the same for the
entire frame e.g.
- intersecting the frameRect with the full image size
- whether there is a color table
* Change when we write transparent pixels
- In some cases, Chromium deemed this unnecessary, but I suspect it is slower
than the fallback case. There will continue to be cases where we should
*not* write them, but for e.g. the first pass where we have already
cleared to transparent (which we may also be able to skip) writing the
transparent pixels will not make anything incorrect.
* Report color type and alpha type per frame
- Depending on alpha values, disposal methods, frame rects, etc, subsequent
frames may have different properties than the first.
* Skip copies of the encoded data
- We copy the encoded data in case the stream is one that cannot be rewound,
so we can parse and then decode (possibly not immediately). For some input
streams, this is unnecessary.
- I was concerned this cause a performance regression, but on average the
new code is faster than the old for the images I tested [1].
- It may cause a performance regression for Chromium, though, where we can
always move back in the stream, so this should be addressed.
Design doc:
https://docs.google.com/a/google.com/document/d/12Qhf9T92MWfdWujQwCIjhCO3sw6pTJB5pJBwDM1T7Kc/
[1] https://docs.google.com/a/google.com/spreadsheets/d/19V-t9BfbFw5eiwBTKA1qOBkZbchjlTC5EIz6HFy-6RI/
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=2045293002
Review-Url: https://codereview.chromium.org/2045293002
2016-10-24 16:03:26 +00:00
|
|
|
kAnimated_Mode, // For codecs that support animation.
|
2015-03-25 20:48:49 +00:00
|
|
|
};
|
2015-04-09 19:43:10 +00:00
|
|
|
enum DstColorType {
|
|
|
|
kGetFromCanvas_DstColorType,
|
|
|
|
kGrayscale_Always_DstColorType,
|
2016-04-22 23:27:24 +00:00
|
|
|
kNonNative8888_Always_DstColorType,
|
2015-04-09 19:43:10 +00:00
|
|
|
};
|
2016-02-03 17:42:42 +00:00
|
|
|
CodecSrc(Path, Mode, DstColorType, SkAlphaType, float);
|
2015-03-19 13:03:39 +00:00
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
2015-07-31 13:43:04 +00:00
|
|
|
bool veto(SinkFlags) const override;
|
2016-02-08 23:09:48 +00:00
|
|
|
bool serial() const override { return fRunSerially; }
|
2015-03-19 13:03:39 +00:00
|
|
|
private:
|
2015-09-01 21:57:57 +00:00
|
|
|
Path fPath;
|
|
|
|
Mode fMode;
|
|
|
|
DstColorType fDstColorType;
|
2016-02-03 17:42:42 +00:00
|
|
|
SkAlphaType fDstAlphaType;
|
2015-09-01 21:57:57 +00:00
|
|
|
float fScale;
|
2016-02-08 23:09:48 +00:00
|
|
|
bool fRunSerially;
|
2015-03-19 13:03:39 +00:00
|
|
|
};
|
|
|
|
|
2015-10-21 17:27:10 +00:00
|
|
|
class AndroidCodecSrc : public Src {
|
|
|
|
public:
|
2016-05-16 16:04:13 +00:00
|
|
|
AndroidCodecSrc(Path, CodecSrc::DstColorType, SkAlphaType, int sampleSize);
|
2015-10-21 17:27:10 +00:00
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2015-10-21 17:27:10 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
2016-02-08 23:09:48 +00:00
|
|
|
bool serial() const override { return fRunSerially; }
|
2015-10-21 17:27:10 +00:00
|
|
|
private:
|
|
|
|
Path fPath;
|
|
|
|
CodecSrc::DstColorType fDstColorType;
|
2016-02-03 17:42:42 +00:00
|
|
|
SkAlphaType fDstAlphaType;
|
2015-10-21 17:27:10 +00:00
|
|
|
int fSampleSize;
|
2016-02-08 23:09:48 +00:00
|
|
|
bool fRunSerially;
|
2015-10-21 17:27:10 +00:00
|
|
|
};
|
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
#ifdef SK_ENABLE_ANDROID_UTILS
|
2015-09-08 22:35:32 +00:00
|
|
|
// Allows for testing of various implementations of Android's BitmapRegionDecoder
|
|
|
|
class BRDSrc : public Src {
|
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
// Decode the entire image as one region.
|
|
|
|
kFullImage_Mode,
|
|
|
|
// Splits the image into multiple regions using a divisor and decodes the regions
|
|
|
|
// separately. Also, this test adds a border of a few pixels to each of the regions
|
|
|
|
// that it is decoding. This tests the behavior when a client asks for a region that
|
|
|
|
// does not fully fit in the image.
|
|
|
|
kDivisor_Mode,
|
|
|
|
};
|
|
|
|
|
2016-05-18 13:23:57 +00:00
|
|
|
BRDSrc(Path, Mode, CodecSrc::DstColorType, uint32_t);
|
2015-09-08 22:35:32 +00:00
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2015-09-08 22:35:32 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
|
|
|
private:
|
|
|
|
Path fPath;
|
|
|
|
Mode fMode;
|
|
|
|
CodecSrc::DstColorType fDstColorType;
|
|
|
|
uint32_t fSampleSize;
|
|
|
|
};
|
2020-05-04 14:02:45 +00:00
|
|
|
#endif
|
2015-03-19 13:03:39 +00:00
|
|
|
|
2016-03-09 22:20:58 +00:00
|
|
|
class ImageGenSrc : public Src {
|
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
kCodec_Mode, // Use CodecImageGenerator
|
|
|
|
kPlatform_Mode, // Uses CG or WIC
|
|
|
|
};
|
|
|
|
ImageGenSrc(Path, Mode, SkAlphaType, bool);
|
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2016-03-09 22:20:58 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
|
|
|
bool serial() const override { return fRunSerially; }
|
|
|
|
private:
|
|
|
|
Path fPath;
|
|
|
|
Mode fMode;
|
|
|
|
SkAlphaType fDstAlphaType;
|
|
|
|
bool fIsGpu;
|
|
|
|
bool fRunSerially;
|
|
|
|
};
|
|
|
|
|
2016-04-29 16:38:40 +00:00
|
|
|
class ColorCodecSrc : public Src {
|
|
|
|
public:
|
2019-03-06 16:56:04 +00:00
|
|
|
ColorCodecSrc(Path, bool decode_to_dst);
|
2016-04-29 16:38:40 +00:00
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2016-04-29 16:38:40 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
|
|
|
private:
|
2019-03-06 16:56:04 +00:00
|
|
|
Path fPath;
|
|
|
|
bool fDecodeToDst;
|
2016-04-29 16:38:40 +00:00
|
|
|
};
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
class SKPSrc : public Src {
|
|
|
|
public:
|
2015-01-30 19:42:31 +00:00
|
|
|
explicit SKPSrc(Path path);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
2015-01-15 18:56:12 +00:00
|
|
|
private:
|
2015-01-30 19:42:31 +00:00
|
|
|
Path fPath;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2018-09-28 17:27:39 +00:00
|
|
|
// This class extracts all the paths from an SKP and then removes unwanted paths according to the
|
|
|
|
// provided l/r trail. It then just draws the remaining paths. (Non-path draws are thrown out.) It
|
|
|
|
// is useful for finding a reduced repo case for path drawing bugs.
|
|
|
|
class BisectSrc : public SKPSrc {
|
|
|
|
public:
|
|
|
|
explicit BisectSrc(Path path, const char* trail);
|
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2018-09-28 17:27:39 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkString fTrail;
|
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = SKPSrc;
|
2018-09-28 17:27:39 +00:00
|
|
|
};
|
|
|
|
|
2018-05-04 16:23:24 +00:00
|
|
|
#if defined(SK_ENABLE_SKOTTIE)
|
2018-01-16 22:04:30 +00:00
|
|
|
class SkottieSrc final : public Src {
|
2017-12-31 16:08:42 +00:00
|
|
|
public:
|
2018-01-16 22:04:30 +00:00
|
|
|
explicit SkottieSrc(Path path);
|
2017-12-31 16:08:42 +00:00
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2017-12-31 16:08:42 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Generates a kTileCount x kTileCount filmstrip with evenly distributed frames.
|
2021-10-08 22:48:26 +00:00
|
|
|
inline static constexpr int kTileCount = 5;
|
2017-12-31 16:08:42 +00:00
|
|
|
|
2018-07-30 19:49:20 +00:00
|
|
|
// Fit kTileCount x kTileCount frames to a 1000x1000 film strip.
|
2021-10-08 22:48:26 +00:00
|
|
|
inline static constexpr SkScalar kTargetSize = 1000;
|
|
|
|
inline static constexpr SkScalar kTileSize = kTargetSize / kTileCount;
|
2018-07-30 19:49:20 +00:00
|
|
|
|
|
|
|
Path fPath;
|
2017-12-31 16:08:42 +00:00
|
|
|
};
|
2017-12-31 22:02:26 +00:00
|
|
|
#endif
|
2017-12-31 16:08:42 +00:00
|
|
|
|
2020-06-25 17:33:17 +00:00
|
|
|
#if defined(SK_ENABLE_SKRIVE)
|
|
|
|
class SkRiveSrc final : public Src {
|
|
|
|
public:
|
|
|
|
explicit SkRiveSrc(Path path);
|
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2020-06-25 17:33:17 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Generates a kTileCount x kTileCount filmstrip with evenly distributed frames.
|
2021-10-08 22:48:26 +00:00
|
|
|
inline static constexpr int kTileCount = 5;
|
2020-06-25 17:33:17 +00:00
|
|
|
|
|
|
|
// Fit kTileCount x kTileCount frames to a 1000x1000 film strip.
|
2021-10-08 22:48:26 +00:00
|
|
|
inline static constexpr SkScalar kTargetSize = 1000;
|
|
|
|
inline static constexpr SkScalar kTileSize = kTargetSize / kTileCount;
|
2020-06-25 17:33:17 +00:00
|
|
|
|
|
|
|
const Path fPath;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2021-09-01 16:47:01 +00:00
|
|
|
#if defined(SK_ENABLE_SVG)
|
2016-09-17 14:26:26 +00:00
|
|
|
} // namespace DM
|
|
|
|
|
|
|
|
class SkSVGDOM;
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2016-08-04 02:53:36 +00:00
|
|
|
class SVGSrc : public Src {
|
|
|
|
public:
|
|
|
|
explicit SVGSrc(Path path);
|
|
|
|
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas*) const override;
|
2016-08-04 02:53:36 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
2016-08-16 21:23:29 +00:00
|
|
|
bool veto(SinkFlags) const override;
|
2016-08-04 02:53:36 +00:00
|
|
|
|
|
|
|
private:
|
2016-11-08 15:13:45 +00:00
|
|
|
Name fName;
|
|
|
|
sk_sp<SkSVGDOM> fDom;
|
|
|
|
SkScalar fScale;
|
2016-08-04 02:53:36 +00:00
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = Src;
|
2016-08-04 02:53:36 +00:00
|
|
|
};
|
2021-09-01 16:47:01 +00:00
|
|
|
#endif // SK_ENABLE_SVG
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2016-06-02 19:41:14 +00:00
|
|
|
class MSKPSrc : public Src {
|
|
|
|
public:
|
|
|
|
explicit MSKPSrc(Path path);
|
|
|
|
|
|
|
|
int pageCount() const override;
|
2020-07-01 18:45:24 +00:00
|
|
|
Result draw(GrDirectContext*, SkCanvas* c) const override;
|
|
|
|
Result draw(int, GrDirectContext*, SkCanvas*) const override;
|
2016-06-02 19:41:14 +00:00
|
|
|
SkISize size() const override;
|
|
|
|
SkISize size(int) const override;
|
|
|
|
Name name() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Path fPath;
|
2017-04-03 20:06:42 +00:00
|
|
|
mutable SkTArray<SkDocumentPage> fPages;
|
2016-06-02 19:41:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2015-02-13 23:11:10 +00:00
|
|
|
class NullSink : public Sink {
|
|
|
|
public:
|
|
|
|
NullSink() {}
|
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return ""; }
|
2015-07-31 13:43:04 +00:00
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkFlags::kDirect }; }
|
2015-02-13 23:11:10 +00:00
|
|
|
};
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
class GPUSink : public Sink {
|
|
|
|
public:
|
2019-09-09 17:46:52 +00:00
|
|
|
GPUSink(const SkCommandLineConfigGpu*, const GrContextOptions&);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
Result onDraw(const Src&, SkBitmap*, SkWStream*, SkString*,
|
|
|
|
const GrContextOptions& baseOptions,
|
2020-08-13 19:58:29 +00:00
|
|
|
std::function<void(GrDirectContext*)> initContext = nullptr) const;
|
2017-08-30 14:02:10 +00:00
|
|
|
|
2018-03-09 18:17:30 +00:00
|
|
|
sk_gpu_test::GrContextFactory::ContextType contextType() const { return fContextType; }
|
2020-02-13 20:51:59 +00:00
|
|
|
const sk_gpu_test::GrContextFactory::ContextOverrides& contextOverrides() const {
|
2018-03-09 18:17:30 +00:00
|
|
|
return fContextOverrides;
|
|
|
|
}
|
|
|
|
SkCommandLineConfigGpu::SurfType surfType() const { return fSurfType; }
|
2019-09-09 17:46:52 +00:00
|
|
|
bool serial() const override { return true; }
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return "png"; }
|
2017-03-07 14:08:36 +00:00
|
|
|
SinkFlags flags() const override {
|
2018-02-03 01:32:49 +00:00
|
|
|
SinkFlags::Multisampled ms = fSampleCount > 1 ? SinkFlags::kMultisampled
|
2017-03-08 16:38:45 +00:00
|
|
|
: SinkFlags::kNotMultisampled;
|
|
|
|
return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect, ms };
|
2017-03-07 14:08:36 +00:00
|
|
|
}
|
2017-08-30 14:02:10 +00:00
|
|
|
const GrContextOptions& baseContextOptions() const { return fBaseContextOptions; }
|
2021-08-11 21:06:42 +00:00
|
|
|
void setColorSpace(sk_sp<SkColorSpace> colorSpace) override { fColorSpace = colorSpace; }
|
2020-02-04 21:09:08 +00:00
|
|
|
SkColorInfo colorInfo() const override {
|
|
|
|
return SkColorInfo(fColorType, fAlphaType, fColorSpace);
|
|
|
|
}
|
2017-08-30 14:02:10 +00:00
|
|
|
|
2020-02-13 20:51:59 +00:00
|
|
|
protected:
|
2020-10-08 20:00:14 +00:00
|
|
|
sk_sp<SkSurface> createDstSurface(GrDirectContext*, SkISize size) const;
|
2020-02-13 20:51:59 +00:00
|
|
|
bool readBack(SkSurface*, SkBitmap* dst) const;
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
private:
|
2017-02-21 19:36:05 +00:00
|
|
|
sk_gpu_test::GrContextFactory::ContextType fContextType;
|
|
|
|
sk_gpu_test::GrContextFactory::ContextOverrides fContextOverrides;
|
2018-03-09 14:01:53 +00:00
|
|
|
SkCommandLineConfigGpu::SurfType fSurfType;
|
2017-02-21 19:36:05 +00:00
|
|
|
int fSampleCount;
|
2021-03-17 02:49:15 +00:00
|
|
|
uint32_t fSurfaceFlags;
|
2017-02-21 19:36:05 +00:00
|
|
|
SkColorType fColorType;
|
2017-07-17 15:31:31 +00:00
|
|
|
SkAlphaType fAlphaType;
|
2017-02-21 19:36:05 +00:00
|
|
|
sk_sp<SkColorSpace> fColorSpace;
|
2017-08-21 20:48:46 +00:00
|
|
|
GrContextOptions fBaseContextOptions;
|
2019-06-27 20:43:27 +00:00
|
|
|
sk_gpu_test::MemoryCache fMemoryCache;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2017-08-30 14:02:10 +00:00
|
|
|
class GPUThreadTestingSink : public GPUSink {
|
|
|
|
public:
|
2019-09-09 17:46:52 +00:00
|
|
|
GPUThreadTestingSink(const SkCommandLineConfigGpu*, const GrContextOptions&);
|
2017-08-30 14:02:10 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2017-08-30 14:02:10 +00:00
|
|
|
|
2017-08-30 18:50:22 +00:00
|
|
|
const char* fileExtension() const override {
|
|
|
|
// Suppress writing out results from this config - we just want to do our matching test
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-30 14:02:10 +00:00
|
|
|
private:
|
|
|
|
std::unique_ptr<SkExecutor> fExecutor;
|
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GPUSink;
|
2017-08-30 14:02:10 +00:00
|
|
|
};
|
|
|
|
|
2018-07-11 19:32:05 +00:00
|
|
|
class GPUPersistentCacheTestingSink : public GPUSink {
|
|
|
|
public:
|
2019-09-09 17:46:52 +00:00
|
|
|
GPUPersistentCacheTestingSink(const SkCommandLineConfigGpu*, const GrContextOptions&);
|
2018-07-11 19:32:05 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2018-07-11 19:32:05 +00:00
|
|
|
|
|
|
|
const char* fileExtension() const override {
|
|
|
|
// Suppress writing out results from this config - we just want to do our matching test
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-04-03 17:04:16 +00:00
|
|
|
int fCacheType;
|
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GPUSink;
|
2018-07-11 19:32:05 +00:00
|
|
|
};
|
|
|
|
|
2019-09-06 18:42:43 +00:00
|
|
|
class GPUPrecompileTestingSink : public GPUSink {
|
|
|
|
public:
|
2019-09-09 17:46:52 +00:00
|
|
|
GPUPrecompileTestingSink(const SkCommandLineConfigGpu*, const GrContextOptions&);
|
2019-09-06 18:42:43 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2019-09-06 18:42:43 +00:00
|
|
|
|
|
|
|
const char* fileExtension() const override {
|
|
|
|
// Suppress writing out results from this config - we just want to do our matching test
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GPUSink;
|
2019-09-06 18:42:43 +00:00
|
|
|
};
|
|
|
|
|
2020-06-15 17:12:32 +00:00
|
|
|
// This sink attempts to emulate Chrome's OOP-R behavior. It:
|
|
|
|
// doesn't use promise images
|
|
|
|
// uses only a single thread for both DDL creation & drawing
|
|
|
|
class GPUOOPRSink : public GPUSink {
|
|
|
|
public:
|
|
|
|
GPUOOPRSink(const SkCommandLineConfigGpu*, const GrContextOptions&);
|
|
|
|
|
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
|
|
|
|
private:
|
2020-07-01 18:45:24 +00:00
|
|
|
Result ooprDraw(const Src&, sk_sp<SkSurface> dstSurface, GrDirectContext*) const;
|
2020-06-15 17:12:32 +00:00
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GPUSink;
|
2020-06-15 17:12:32 +00:00
|
|
|
};
|
|
|
|
|
2020-02-19 19:14:47 +00:00
|
|
|
// This sink attempts to better simulate the Chrome DDL use-case. It:
|
|
|
|
// creates the DDLs on separate recording threads
|
|
|
|
// performs all the GPU work on a separate GPU thread
|
|
|
|
// In the future this should be expanded to:
|
|
|
|
// upload on a utility thread w/ access to a shared context
|
|
|
|
// compile the programs on the utility thread
|
|
|
|
// perform fine grained scheduling of gpu tasks based on their image and program prerequisites
|
|
|
|
// create a single "compositing" DDL that is replayed last
|
|
|
|
class GPUDDLSink : public GPUSink {
|
|
|
|
public:
|
|
|
|
GPUDDLSink(const SkCommandLineConfigGpu*, const GrContextOptions&);
|
|
|
|
|
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Result ddlDraw(const Src&,
|
|
|
|
sk_sp<SkSurface> dstSurface,
|
|
|
|
SkTaskGroup* recordingTaskGroup,
|
|
|
|
SkTaskGroup* gpuTaskGroup,
|
2020-02-26 15:27:07 +00:00
|
|
|
sk_gpu_test::TestContext* gpuTestCtx,
|
2020-07-01 18:45:24 +00:00
|
|
|
GrDirectContext* gpuThreadCtx) const;
|
2020-02-19 19:14:47 +00:00
|
|
|
|
2020-06-15 17:12:32 +00:00
|
|
|
std::unique_ptr<SkExecutor> fRecordingExecutor;
|
|
|
|
std::unique_ptr<SkExecutor> fGPUExecutor;
|
2020-02-19 19:14:47 +00:00
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GPUSink;
|
2020-02-19 19:14:47 +00:00
|
|
|
};
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
class PDFSink : public Sink {
|
|
|
|
public:
|
2017-07-20 19:36:00 +00:00
|
|
|
PDFSink(bool pdfa, SkScalar rasterDpi) : fPDFA(pdfa), fRasterDpi(rasterDpi) {}
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return "pdf"; }
|
2015-07-31 13:43:04 +00:00
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
|
2016-04-27 14:45:18 +00:00
|
|
|
bool fPDFA;
|
2017-07-20 19:36:00 +00:00
|
|
|
SkScalar fRasterDpi;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2015-03-03 17:13:09 +00:00
|
|
|
class XPSSink : public Sink {
|
|
|
|
public:
|
|
|
|
XPSSink();
|
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return "xps"; }
|
2015-07-31 13:43:04 +00:00
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
|
2015-03-03 17:13:09 +00:00
|
|
|
};
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
class RasterSink : public Sink {
|
|
|
|
public:
|
2021-08-12 14:51:48 +00:00
|
|
|
explicit RasterSink(SkColorType);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return "png"; }
|
2015-07-31 13:43:04 +00:00
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, SinkFlags::kDirect }; }
|
2021-08-11 21:06:42 +00:00
|
|
|
void setColorSpace(sk_sp<SkColorSpace> colorSpace) override { fColorSpace = colorSpace; }
|
2018-02-23 06:13:36 +00:00
|
|
|
|
2018-07-25 17:28:44 +00:00
|
|
|
private:
|
2016-06-16 20:03:24 +00:00
|
|
|
SkColorType fColorType;
|
|
|
|
sk_sp<SkColorSpace> fColorSpace;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2015-01-28 19:35:18 +00:00
|
|
|
class SKPSink : public Sink {
|
|
|
|
public:
|
|
|
|
SKPSink();
|
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return "skp"; }
|
2015-07-31 13:43:04 +00:00
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
|
2015-01-28 19:35:18 +00:00
|
|
|
};
|
|
|
|
|
2016-10-25 14:33:27 +00:00
|
|
|
class DebugSink : public Sink {
|
|
|
|
public:
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2016-10-25 14:33:27 +00:00
|
|
|
const char* fileExtension() const override { return "json"; }
|
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
|
|
|
|
};
|
|
|
|
|
2015-02-01 04:00:58 +00:00
|
|
|
class SVGSink : public Sink {
|
|
|
|
public:
|
2018-03-02 21:54:21 +00:00
|
|
|
SVGSink(int pageIndex = 0);
|
2015-02-01 04:00:58 +00:00
|
|
|
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return "svg"; }
|
2015-07-31 13:43:04 +00:00
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
|
2018-03-02 21:54:21 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int fPageIndex;
|
2015-02-01 04:00:58 +00:00
|
|
|
};
|
|
|
|
|
2021-10-13 14:37:36 +00:00
|
|
|
#ifdef SK_GRAPHITE_ENABLED
|
|
|
|
|
2021-09-21 15:59:57 +00:00
|
|
|
class GraphiteSink : public Sink {
|
2021-09-21 13:57:43 +00:00
|
|
|
public:
|
2021-10-13 14:37:36 +00:00
|
|
|
using ContextType = skiatest::graphite::ContextFactory::ContextType;
|
|
|
|
|
|
|
|
GraphiteSink(const SkCommandLineConfigGraphite*);
|
2021-09-21 13:57:43 +00:00
|
|
|
|
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2021-09-22 20:07:30 +00:00
|
|
|
const char* fileExtension() const override { return "png"; }
|
|
|
|
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; }
|
2021-10-13 14:37:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ContextType fContextType;
|
|
|
|
SkColorType fColorType;
|
|
|
|
SkAlphaType fAlphaType;
|
|
|
|
bool fTestPrecompile;
|
2021-09-21 13:57:43 +00:00
|
|
|
};
|
2015-02-01 04:00:58 +00:00
|
|
|
|
2021-10-13 14:37:36 +00:00
|
|
|
#endif
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2015-05-06 14:54:07 +00:00
|
|
|
class Via : public Sink {
|
2015-01-15 18:56:12 +00:00
|
|
|
public:
|
2015-12-10 23:14:27 +00:00
|
|
|
explicit Via(Sink* sink) : fSink(sink) {}
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* fileExtension() const override { return fSink->fileExtension(); }
|
2016-02-08 20:39:59 +00:00
|
|
|
bool serial() const override { return fSink->serial(); }
|
2015-07-31 13:43:04 +00:00
|
|
|
SinkFlags flags() const override {
|
|
|
|
SinkFlags flags = fSink->flags();
|
|
|
|
flags.approach = SinkFlags::kIndirect;
|
|
|
|
return flags;
|
|
|
|
}
|
2021-08-11 21:06:42 +00:00
|
|
|
void setColorSpace(sk_sp<SkColorSpace> colorSpace) override {
|
|
|
|
fSink->setColorSpace(colorSpace);
|
|
|
|
}
|
2015-05-06 14:54:07 +00:00
|
|
|
protected:
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<Sink> fSink;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2015-05-06 14:54:07 +00:00
|
|
|
class ViaMatrix : public Via {
|
2015-02-17 19:13:33 +00:00
|
|
|
public:
|
2015-12-10 23:14:27 +00:00
|
|
|
ViaMatrix(SkMatrix, Sink*);
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-02-17 19:13:33 +00:00
|
|
|
private:
|
2015-05-06 14:54:07 +00:00
|
|
|
const SkMatrix fMatrix;
|
2015-02-17 19:13:33 +00:00
|
|
|
};
|
|
|
|
|
2015-05-06 14:54:07 +00:00
|
|
|
class ViaUpright : public Via {
|
2015-01-15 18:56:12 +00:00
|
|
|
public:
|
2015-12-10 23:14:27 +00:00
|
|
|
ViaUpright(SkMatrix, Sink*);
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-01-15 18:56:12 +00:00
|
|
|
private:
|
2015-05-06 14:54:07 +00:00
|
|
|
const SkMatrix fMatrix;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2015-05-06 14:54:07 +00:00
|
|
|
class ViaSerialization : public Via {
|
|
|
|
public:
|
2015-12-10 23:14:27 +00:00
|
|
|
explicit ViaSerialization(Sink* sink) : Via(sink) {}
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
|
|
|
|
2016-01-08 18:19:35 +00:00
|
|
|
class ViaPicture : public Via {
|
|
|
|
public:
|
|
|
|
explicit ViaPicture(Sink* sink) : Via(sink) {}
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2016-07-08 15:43:27 +00:00
|
|
|
};
|
|
|
|
|
2021-07-20 16:53:54 +00:00
|
|
|
class ViaRuntimeBlend : public Via {
|
|
|
|
public:
|
|
|
|
explicit ViaRuntimeBlend(Sink* sink) : Via(sink) {}
|
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
};
|
|
|
|
|
2017-02-17 22:06:11 +00:00
|
|
|
class ViaSVG : public Via {
|
|
|
|
public:
|
|
|
|
explicit ViaSVG(Sink* sink) : Via(sink) {}
|
2020-02-12 16:18:46 +00:00
|
|
|
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2017-02-17 22:06:11 +00:00
|
|
|
};
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
} // namespace DM
|
|
|
|
|
|
|
|
#endif//DMSrcSink_DEFINED
|