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/android/SkBitmapRegionDecoder.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/core/SkBBoxHierarchy.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
|
|
|
|
|
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
|
|
|
|
2015-03-05 16:40:28 +00:00
|
|
|
class Error {
|
|
|
|
public:
|
|
|
|
Error(const SkString& s) : fMsg(s), fFatal(!this->isEmpty()) {}
|
|
|
|
Error(const char* s) : fMsg(s), fFatal(!this->isEmpty()) {}
|
|
|
|
|
|
|
|
Error(const Error&) = default;
|
|
|
|
Error& operator=(const Error&) = default;
|
|
|
|
|
|
|
|
static Error Nonfatal(const SkString& s) { return Nonfatal(s.c_str()); }
|
|
|
|
static Error Nonfatal(const char* s) {
|
|
|
|
Error e(s);
|
|
|
|
e.fFatal = false;
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* c_str() const { return fMsg.c_str(); }
|
|
|
|
bool isEmpty() const { return fMsg.isEmpty(); }
|
|
|
|
bool isFatal() const { return fFatal; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkString fMsg;
|
|
|
|
bool fFatal;
|
|
|
|
};
|
|
|
|
|
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() {}
|
|
|
|
virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0;
|
|
|
|
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; }
|
|
|
|
virtual Error SK_WARN_UNUSED_RESULT draw(int, SkCanvas* canvas) const {
|
|
|
|
return this->draw(canvas);
|
|
|
|
}
|
|
|
|
virtual SkISize size(int) 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; }
|
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.
|
|
|
|
virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log)
|
|
|
|
const = 0;
|
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;
|
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
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
2015-05-27 20:23:23 +00:00
|
|
|
void modifyGrContextOptions(GrContextOptions* options) 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
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
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
|
|
|
|
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
|
|
|
private:
|
|
|
|
Path fPath;
|
|
|
|
Mode fMode;
|
|
|
|
CodecSrc::DstColorType fDstColorType;
|
|
|
|
uint32_t fSampleSize;
|
|
|
|
};
|
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);
|
|
|
|
|
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
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
|
|
|
|
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
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
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
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);
|
|
|
|
|
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkString fTrail;
|
|
|
|
|
|
|
|
typedef SKPSrc INHERITED;
|
|
|
|
};
|
|
|
|
|
2017-08-30 16:06:35 +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
|
|
|
|
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
SkISize size() const override;
|
|
|
|
Name name() const override;
|
|
|
|
bool veto(SinkFlags) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Generates a kTileCount x kTileCount filmstrip with evenly distributed frames.
|
2018-02-23 16:10:22 +00:00
|
|
|
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.
|
|
|
|
static constexpr SkScalar kTargetSize = 1000;
|
|
|
|
static constexpr SkScalar kTileSize = kTargetSize / kTileCount;
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-08-04 02:53:36 +00:00
|
|
|
#if defined(SK_XML)
|
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);
|
|
|
|
|
|
|
|
Error draw(SkCanvas*) const override;
|
|
|
|
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
|
|
|
|
|
|
|
typedef Src INHERITED;
|
|
|
|
};
|
|
|
|
#endif // SK_XML
|
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;
|
|
|
|
Error draw(SkCanvas* c) const override;
|
|
|
|
Error draw(int, SkCanvas*) const override;
|
|
|
|
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() {}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
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
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2017-08-30 14:02:10 +00:00
|
|
|
Error onDraw(const Src&, SkBitmap*, SkWStream*, SkString*,
|
2019-09-06 18:42:43 +00:00
|
|
|
const GrContextOptions& baseOptions,
|
|
|
|
std::function<void(GrContext*)> 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; }
|
|
|
|
const sk_gpu_test::GrContextFactory::ContextOverrides& contextOverrides() {
|
|
|
|
return fContextOverrides;
|
|
|
|
}
|
|
|
|
SkCommandLineConfigGpu::SurfType surfType() const { return fSurfType; }
|
|
|
|
bool useDIText() const { return fUseDIText; }
|
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; }
|
|
|
|
|
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;
|
|
|
|
bool fUseDIText;
|
|
|
|
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
|
|
|
|
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
typedef GPUSink INHERITED;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-07-11 19:32:05 +00:00
|
|
|
typedef GPUSink INHERITED;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
|
|
|
|
const char* fileExtension() const override {
|
|
|
|
// Suppress writing out results from this config - we just want to do our matching test
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef GPUSink INHERITED;
|
|
|
|
};
|
|
|
|
|
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) {}
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
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();
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
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:
|
2016-06-16 20:03:24 +00:00
|
|
|
explicit RasterSink(SkColorType, sk_sp<SkColorSpace> = nullptr);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
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 }; }
|
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
|
|
|
};
|
|
|
|
|
2018-02-23 06:13:36 +00:00
|
|
|
class ThreadedSink : public RasterSink {
|
|
|
|
public:
|
|
|
|
explicit ThreadedSink(SkColorType, sk_sp<SkColorSpace> = nullptr);
|
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
};
|
|
|
|
|
2015-01-28 19:35:18 +00:00
|
|
|
class SKPSink : public Sink {
|
|
|
|
public:
|
|
|
|
SKPSink();
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
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:
|
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
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
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
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*);
|
2015-03-26 01:17:31 +00:00
|
|
|
Error 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*);
|
2015-03-26 01:17:31 +00:00
|
|
|
Error 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) {}
|
2015-03-26 01:17:31 +00:00
|
|
|
Error 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) {}
|
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
2016-07-08 15:43:27 +00:00
|
|
|
};
|
|
|
|
|
2018-03-27 12:06:57 +00:00
|
|
|
class ViaDDL : public Via {
|
|
|
|
public:
|
2018-12-17 19:45:00 +00:00
|
|
|
ViaDDL(int numReplays, int numDivisions, Sink* sink);
|
2018-03-27 12:06:57 +00:00
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
private:
|
2018-12-17 19:45:00 +00:00
|
|
|
const int fNumReplays;
|
2018-03-27 12:06:57 +00:00
|
|
|
const int fNumDivisions;
|
|
|
|
};
|
|
|
|
|
2017-02-17 22:06:11 +00:00
|
|
|
class ViaSVG : public Via {
|
|
|
|
public:
|
|
|
|
explicit ViaSVG(Sink* sink) : Via(sink) {}
|
|
|
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
|
|
|
};
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
} // namespace DM
|
|
|
|
|
|
|
|
#endif//DMSrcSink_DEFINED
|