2015-03-25 14:11:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-03-20 17:01:47 +00:00
|
|
|
#include "ChromeTracingTracer.h"
|
2019-03-20 15:50:33 +00:00
|
|
|
#include "CommonFlags.h"
|
|
|
|
#include "CommonFlagsConfig.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "DMJsonWriter.h"
|
|
|
|
#include "DMSrcSink.h"
|
2019-03-20 17:01:47 +00:00
|
|
|
#include "EventTracingPriv.h"
|
FM, a dumber new testing tool
FM's a bit like DM, and a bit like the old GM tool, maybe closer to GM.
FM always does one serial run through of a list of GM, image, or .skp
sources (-s/--sources) into one drawing configuration, set at a high
level with -b/--backend, fine-tuned by flags like --ct, --at, --gamut,
--samples, etc.
FM prints all available GMs when run with no arguments, part of
how it integrates well with external parallelization like xargs:
out/fm | time xargs -n4 -P32 out/fm -b cpu ... -s
out/fm | time xargs -n32 -P8 out/fm -b gl ... -s
ls *.skp | xargs ... out/fm ... -s
...
TODO later:
vector backends: --backend pdf, svg, xps, skp
--source *.svg, *.json (Skottie)
Create/update a dm.json file
Change-Id: Idacbd2785deaf6f1d33674c66c4d984fa91dbd85
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203520
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-25 17:57:58 +00:00
|
|
|
#include "HashAndEncode.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "ProcStats.h"
|
2016-02-25 01:59:16 +00:00
|
|
|
#include "Resources.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "SkBBHFactory.h"
|
2015-01-27 22:46:26 +00:00
|
|
|
#include "SkChecksum.h"
|
2015-08-14 15:32:46 +00:00
|
|
|
#include "SkCodec.h"
|
2016-02-26 22:43:21 +00:00
|
|
|
#include "SkColorPriv.h"
|
2016-05-23 17:21:17 +00:00
|
|
|
#include "SkColorSpace.h"
|
2017-03-18 15:36:52 +00:00
|
|
|
#include "SkColorSpacePriv.h"
|
2016-04-19 16:18:11 +00:00
|
|
|
#include "SkData.h"
|
2017-07-19 14:53:20 +00:00
|
|
|
#include "SkDebugfTracer.h"
|
2017-12-11 22:46:26 +00:00
|
|
|
#include "SkDocument.h"
|
2015-06-10 16:31:09 +00:00
|
|
|
#include "SkFontMgr.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "SkGraphics.h"
|
2016-02-26 22:43:21 +00:00
|
|
|
#include "SkHalf.h"
|
2016-06-08 00:21:10 +00:00
|
|
|
#include "SkLeanWindows.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "SkMD5.h"
|
2015-07-07 19:21:21 +00:00
|
|
|
#include "SkMutex.h"
|
Start to rework DM JSON handling.
DM's striking off into its own JSON world. This gets strawman implementations
in place for writing and reading a JSON file mapping test name to hashes.
For what it's worth, I basically want to change _all_ these pieces,
- MD5 is slow and we can replace it with something faster,
- JSON schema needs room to grow more data,
- it'd be nice to hash once instead of twice when reading and writing,
- this code wants lots of refactoring,
but this gives us a starting platform to work on these bits at our leisure.
E.x. file for now:
mtklein@mtklein ~/skia (dm)> cat good/dm.json
{
"3x3bitmaprect_565" : "fc70d985fbfbe70e3a3c9dc626d4f5bc",
"3x3bitmaprect_8888" : "df1591dde35907399734ea19feb76663",
"3x3bitmaprect_gpu" : "df1591dde35907399734ea19feb76663",
"aaclip_565" : "1862798689b838a7ab0dc0652b9ace3a",
"aaclip_8888" : "47bb314329f0ce243f1d83fd583decb7",
"aaclip_gpu" : "75f72412d0ef4815770202d297246e7d",
...
BUG=skia:
R=jcgregorio@google.com, stephana@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/546873002
2014-09-08 15:05:18 +00:00
|
|
|
#include "SkOSFile.h"
|
2016-11-07 23:05:29 +00:00
|
|
|
#include "SkOSPath.h"
|
2016-02-23 18:39:36 +00:00
|
|
|
#include "SkSpinlock.h"
|
2015-02-20 20:30:19 +00:00
|
|
|
#include "SkTHash.h"
|
SkThreadPool ~~> SkTaskGroup
SkTaskGroup is like SkThreadPool except the threads stay in
one global pool. Each SkTaskGroup itself is tiny (4 bytes)
and its wait() method applies only to tasks add()ed to that
instance, not the whole thread pool.
This means we don't need to bring up new thread pools when
tests themselves want to use multithreading (e.g. pathops,
quilt). We just create a new SkTaskGroup and wait for that
to complete. This should be more efficient, and allow us
to expand where we use threads to really latency sensitive
places. E.g. we can probably now use these in nanobench
for CPU .skp rendering.
Now that all threads are sharing the same pool, I think we
can remove most of the custom mechanism pathops tests use
to control threading. They'll just ride on the global pool
with all other tests now.
This (temporarily?) removes the GPU multithreading feature
from DM, which we don't use.
On my desktop, DM runs a little faster (57s -> 55s) in
Debug, and a lot faster in Release (36s -> 24s). The bots
show speedups of similar proportions, cutting more than a
minute off the N4/Release and Win7/Debug runtimes.
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/9c7207b5dc71dc5a96a2eb107d401133333d5b6f
R=caryclark@google.com, bsalomon@google.com, bungeman@google.com, mtklein@google.com, reed@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/531653002
2014-09-03 22:34:37 +00:00
|
|
|
#include "SkTaskGroup.h"
|
2017-11-13 17:40:46 +00:00
|
|
|
#include "SkTypeface_win.h"
|
2014-02-26 16:31:22 +00:00
|
|
|
#include "Test.h"
|
2019-03-20 16:12:10 +00:00
|
|
|
#include "ToolUtils.h"
|
2017-02-06 14:26:14 +00:00
|
|
|
#include "ios_utils.h"
|
2014-06-03 20:57:14 +00:00
|
|
|
|
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
|
|
|
#include <vector>
|
|
|
|
|
2015-08-26 12:15:46 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2018-01-24 17:42:55 +00:00
|
|
|
#ifndef SK_BUILD_FOR_WIN
|
2015-10-28 15:56:41 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2018-02-16 18:55:21 +00:00
|
|
|
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_HAS_HEIF_LIBRARY)
|
|
|
|
#include <binder/IPCThreadState.h>
|
|
|
|
#endif
|
|
|
|
|
2017-07-05 19:45:52 +00:00
|
|
|
extern bool gSkForceRasterPipelineBlitter;
|
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(src, "tests gm skp image", "Source types to test.");
|
|
|
|
static DEFINE_bool(nameByHash, false,
|
|
|
|
"If true, write to FLAGS_writePath[0]/<hash>.png instead of "
|
|
|
|
"to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.png");
|
|
|
|
static DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
|
|
|
|
static DEFINE_string(matrix, "1 0 0 1",
|
|
|
|
"2x2 scale+skew matrix to apply or upright when using "
|
|
|
|
"'matrix' or 'upright' in config.");
|
|
|
|
static DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
|
|
|
|
|
|
|
|
static DEFINE_string(blacklist, "",
|
2017-08-15 21:43:08 +00:00
|
|
|
"Space-separated config/src/srcOptions/name quadruples to blacklist. "
|
|
|
|
"'_' matches anything. '~' negates the match. E.g. \n"
|
2015-04-03 14:24:48 +00:00
|
|
|
"'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu config.\n"
|
2017-08-15 21:43:08 +00:00
|
|
|
"'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aarects GM on 8888.\n"
|
|
|
|
"'--blacklist ~8888 svg _ svgparse_' blocks non-8888 SVGs that contain \"svgparse_\" in "
|
|
|
|
"the name.");
|
2015-01-15 21:44:22 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string2(readPath, r, "",
|
|
|
|
"If set check for equality with golden results in this directory.");
|
2019-03-25 15:54:59 +00:00
|
|
|
DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
|
|
|
|
|
2019-01-25 18:02:59 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(uninterestingHashesFile, "",
|
2015-04-03 21:15:33 +00:00
|
|
|
"File containing a list of uninteresting hashes. If a result hashes to something in "
|
|
|
|
"this list, no image is written for that result.");
|
|
|
|
|
2019-03-21 16:42:21 +00:00
|
|
|
static DEFINE_int(shards, 1, "We're splitting source data into this many shards.");
|
|
|
|
static DEFINE_int(shard, 0, "Which shard do I run?");
|
2015-04-27 15:45:01 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.");
|
|
|
|
static DEFINE_bool(forceRasterPipeline, false, "sets gSkForceRasterPipelineBlitter");
|
2016-06-02 19:41:14 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(bisect, "",
|
2018-09-28 17:27:39 +00:00
|
|
|
"Pair of: SKP file to bisect, followed by an l/r bisect trail string (e.g., 'lrll'). The "
|
|
|
|
"l/r trail specifies which half to keep at each step of a binary search through the SKP's "
|
|
|
|
"paths. An empty string performs no bisect. Only the SkPaths are bisected; all other draws "
|
|
|
|
"are thrown out. This is useful for finding a reduced repo case for path drawing bugs.");
|
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_bool(ignoreSigInt, false, "ignore SIGINT signals during test execution");
|
2017-07-19 19:25:24 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(dont_write, "", "File extensions to skip writing to --writePath."); // See skia:6821
|
2017-07-24 14:37:19 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_bool(checkF16, false, "Ensure that F16Norm pixels are clamped.");
|
2019-03-11 15:20:55 +00:00
|
|
|
|
2019-03-21 18:08:08 +00:00
|
|
|
static DEFINE_string(colorImages, "",
|
|
|
|
"List of images and/or directories to decode with color correction. "
|
|
|
|
"A directory with no images is treated as a fatal error.");
|
|
|
|
|
2019-03-22 18:15:11 +00:00
|
|
|
static DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
|
|
|
|
|
2019-03-22 19:55:19 +00:00
|
|
|
static DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
|
|
|
|
static DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
|
|
|
|
|
|
|
|
static DEFINE_bool(dryRun, false,
|
|
|
|
"just print the tests that would be run, without actually running them.");
|
|
|
|
|
|
|
|
static DEFINE_string(images, "",
|
|
|
|
"List of images and/or directories to decode. A directory with no images"
|
|
|
|
" is treated as a fatal error.");
|
|
|
|
|
|
|
|
static DEFINE_bool(simpleCodec, false,
|
|
|
|
"Runs of a subset of the codec tests, "
|
|
|
|
"with no scaling or subsetting, always using the canvas color type.");
|
2019-03-21 18:08:08 +00:00
|
|
|
|
2019-03-25 15:54:59 +00:00
|
|
|
static DEFINE_string2(match, m, nullptr,
|
|
|
|
"[~][^]substring[$] [...] of name to run.\n"
|
|
|
|
"Multiple matches may be separated by spaces.\n"
|
|
|
|
"~ causes a matching name to always be skipped\n"
|
|
|
|
"^ requires the start of the name to match\n"
|
|
|
|
"$ requires the end of the name to match\n"
|
|
|
|
"^ and $ requires an exact match\n"
|
|
|
|
"If a name does not match any list entry,\n"
|
|
|
|
"it is skipped unless some list entry starts with ~");
|
|
|
|
|
|
|
|
static DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
|
|
|
|
static DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
|
|
|
|
|
|
|
|
static DEFINE_string(skps, "skps", "Directory to read skps from.");
|
|
|
|
static DEFINE_string(lotties, "lotties", "Directory to read (Bodymovin) jsons from.");
|
|
|
|
static DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
|
|
|
|
|
|
|
|
static DEFINE_int_2(threads, j, -1,
|
|
|
|
"Run threadsafe tests on a threadpool with this many extra threads, "
|
|
|
|
"defaulting to one extra thread per core.");
|
|
|
|
|
|
|
|
static DEFINE_string(key, "",
|
|
|
|
"Space-separated key/value pairs to add to JSON identifying this builder.");
|
|
|
|
static DEFINE_string(properties, "",
|
|
|
|
"Space-separated key/value pairs to add to JSON identifying this run.");
|
|
|
|
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
using namespace DM;
|
2016-03-31 01:56:19 +00:00
|
|
|
using sk_gpu_test::GrContextFactory;
|
2016-03-31 17:59:06 +00:00
|
|
|
using sk_gpu_test::GLTestContext;
|
2016-04-05 19:59:06 +00:00
|
|
|
using sk_gpu_test::ContextInfo;
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
2014-06-30 13:36:31 +00:00
|
|
|
|
2019-03-07 17:46:59 +00:00
|
|
|
static constexpr skcms_TransferFunction k2020_TF =
|
|
|
|
{2.22222f, 0.909672f, 0.0903276f, 0.222222f, 0.0812429f, 0, 0};
|
|
|
|
|
|
|
|
static sk_sp<SkColorSpace> rec2020() {
|
|
|
|
return SkColorSpace::MakeRGB(k2020_TF, SkNamedGamut::kRec2020);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2016-03-08 17:01:39 +00:00
|
|
|
static FILE* gVLog;
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
static void vlog(const char* fmt, Args&&... args) {
|
|
|
|
if (gVLog) {
|
|
|
|
fprintf(gVLog, fmt, args...);
|
|
|
|
fflush(gVLog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
static void info(const char* fmt, Args&&... args) {
|
|
|
|
vlog(fmt, args...);
|
|
|
|
if (!FLAGS_quiet) {
|
|
|
|
printf(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void info(const char* fmt) {
|
|
|
|
if (!FLAGS_quiet) {
|
|
|
|
printf("%s", fmt); // Clang warns printf(fmt) is insecure.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 00:12:46 +00:00
|
|
|
SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
|
2015-01-15 18:56:12 +00:00
|
|
|
static SkTArray<SkString> gFailures;
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2016-02-25 03:07:07 +00:00
|
|
|
static void fail(const SkString& err) {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkAutoMutexAcquire lock(gFailuresMutex);
|
|
|
|
SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
|
|
|
|
gFailures.push_back(err);
|
|
|
|
}
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2016-07-25 22:27:29 +00:00
|
|
|
struct Running {
|
|
|
|
SkString id;
|
|
|
|
SkThreadID thread;
|
|
|
|
|
|
|
|
void dump() const {
|
|
|
|
info("\t%s\n", id.c_str());
|
|
|
|
}
|
|
|
|
};
|
2015-03-18 12:27:14 +00:00
|
|
|
|
2019-03-25 15:54:59 +00:00
|
|
|
static void dump_json() {
|
|
|
|
if (!FLAGS_writePath.isEmpty()) {
|
|
|
|
JsonWriter::DumpJson(FLAGS_writePath[0], FLAGS_key, FLAGS_properties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-23 18:39:36 +00:00
|
|
|
// We use a spinlock to make locking this in a signal handler _somewhat_ safe.
|
2017-06-23 16:36:32 +00:00
|
|
|
static SkSpinlock gMutex;
|
|
|
|
static int gPending;
|
2016-07-25 22:27:29 +00:00
|
|
|
static SkTArray<Running> gRunning;
|
2016-02-25 03:07:07 +00:00
|
|
|
|
|
|
|
static void done(const char* config, const char* src, const char* srcOptions, const char* name) {
|
|
|
|
SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
|
2016-03-08 17:01:39 +00:00
|
|
|
vlog("done %s\n", id.c_str());
|
2016-02-24 20:28:32 +00:00
|
|
|
int pending;
|
2015-03-18 12:27:14 +00:00
|
|
|
{
|
2016-06-10 20:56:35 +00:00
|
|
|
SkAutoMutexAcquire lock(gMutex);
|
2015-03-18 12:27:14 +00:00
|
|
|
for (int i = 0; i < gRunning.count(); i++) {
|
2016-07-25 22:27:29 +00:00
|
|
|
if (gRunning[i].id == id) {
|
2015-03-18 12:27:14 +00:00
|
|
|
gRunning.removeShuffle(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-02-24 20:28:32 +00:00
|
|
|
pending = --gPending;
|
2015-05-19 21:13:31 +00:00
|
|
|
}
|
2017-06-23 16:36:32 +00:00
|
|
|
|
|
|
|
// We write out dm.json file and print out a progress update every once in a while.
|
|
|
|
// Notice this also handles the final dm.json and progress update when pending == 0.
|
2015-01-23 13:48:00 +00:00
|
|
|
if (pending % 500 == 0) {
|
2019-03-25 15:54:59 +00:00
|
|
|
dump_json();
|
2017-06-23 16:36:32 +00:00
|
|
|
|
|
|
|
int curr = sk_tools::getCurrResidentSetSizeMB(),
|
|
|
|
peak = sk_tools::getMaxResidentSetSizeMB();
|
|
|
|
|
|
|
|
SkAutoMutexAcquire lock(gMutex);
|
2018-10-02 13:57:44 +00:00
|
|
|
info("\n%dMB RAM, %dMB peak, %d queued, %d active:\n",
|
|
|
|
curr, peak, gPending - gRunning.count(), gRunning.count());
|
2017-06-23 16:36:32 +00:00
|
|
|
for (auto& task : gRunning) {
|
|
|
|
task.dump();
|
|
|
|
}
|
2015-01-23 13:48:00 +00:00
|
|
|
}
|
2015-01-10 19:18:04 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 03:07:07 +00:00
|
|
|
static void start(const char* config, const char* src, const char* srcOptions, const char* name) {
|
|
|
|
SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
|
2016-03-08 17:01:39 +00:00
|
|
|
vlog("start %s\n", id.c_str());
|
2016-06-10 20:56:35 +00:00
|
|
|
SkAutoMutexAcquire lock(gMutex);
|
2016-07-25 22:27:29 +00:00
|
|
|
gRunning.push_back({id,SkGetThreadID()});
|
2015-03-18 12:27:14 +00:00
|
|
|
}
|
|
|
|
|
2016-10-24 15:39:43 +00:00
|
|
|
static void find_culprit() {
|
|
|
|
// Assumes gMutex is locked.
|
|
|
|
SkThreadID thisThread = SkGetThreadID();
|
|
|
|
for (auto& task : gRunning) {
|
|
|
|
if (task.thread == thisThread) {
|
|
|
|
info("Likely culprit:\n");
|
|
|
|
task.dump();
|
2016-07-25 22:27:29 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-24 15:39:43 +00:00
|
|
|
}
|
2016-07-25 22:27:29 +00:00
|
|
|
|
2018-01-24 17:42:55 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN)
|
2016-06-09 15:59:48 +00:00
|
|
|
static LONG WINAPI crash_handler(EXCEPTION_POINTERS* e) {
|
2016-02-29 14:35:28 +00:00
|
|
|
static const struct {
|
|
|
|
const char* name;
|
2016-03-01 22:10:23 +00:00
|
|
|
DWORD code;
|
2016-02-29 14:35:28 +00:00
|
|
|
} kExceptions[] = {
|
|
|
|
#define _(E) {#E, E}
|
|
|
|
_(EXCEPTION_ACCESS_VIOLATION),
|
|
|
|
_(EXCEPTION_BREAKPOINT),
|
|
|
|
_(EXCEPTION_INT_DIVIDE_BY_ZERO),
|
|
|
|
_(EXCEPTION_STACK_OVERFLOW),
|
|
|
|
// TODO: more?
|
|
|
|
#undef _
|
|
|
|
};
|
|
|
|
|
2016-06-10 20:56:35 +00:00
|
|
|
SkAutoMutexAcquire lock(gMutex);
|
2016-06-09 15:59:48 +00:00
|
|
|
|
|
|
|
const DWORD code = e->ExceptionRecord->ExceptionCode;
|
|
|
|
info("\nCaught exception %u", code);
|
|
|
|
for (const auto& exception : kExceptions) {
|
|
|
|
if (exception.code == code) {
|
|
|
|
info(" %s", exception.name);
|
2016-02-29 14:35:28 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-09 15:59:48 +00:00
|
|
|
info(", was running:\n");
|
|
|
|
for (auto& task : gRunning) {
|
2016-07-25 22:27:29 +00:00
|
|
|
task.dump();
|
2016-06-09 15:59:48 +00:00
|
|
|
}
|
2016-07-25 22:27:29 +00:00
|
|
|
find_culprit();
|
2016-06-09 15:59:48 +00:00
|
|
|
fflush(stdout);
|
|
|
|
|
2016-02-29 14:35:28 +00:00
|
|
|
// Execute default exception handler... hopefully, exit.
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
2016-02-23 18:39:36 +00:00
|
|
|
}
|
|
|
|
|
2016-10-24 15:39:43 +00:00
|
|
|
static void setup_crash_handler() {
|
|
|
|
SetUnhandledExceptionFilter(crash_handler);
|
|
|
|
}
|
|
|
|
#else
|
2016-02-23 18:39:36 +00:00
|
|
|
#include <signal.h>
|
2016-10-24 15:39:43 +00:00
|
|
|
#if !defined(SK_BUILD_FOR_ANDROID)
|
|
|
|
#include <execinfo.h>
|
2017-07-19 14:53:20 +00:00
|
|
|
|
|
|
|
#endif
|
2016-10-24 15:39:43 +00:00
|
|
|
|
|
|
|
static constexpr int max_of() { return 0; }
|
|
|
|
template <typename... Rest>
|
|
|
|
static constexpr int max_of(int x, Rest... rest) {
|
|
|
|
return x > max_of(rest...) ? x : max_of(rest...);
|
|
|
|
}
|
|
|
|
|
2018-02-15 14:26:54 +00:00
|
|
|
static void (*previous_handler[max_of(SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGSEGV,SIGTERM)+1])(int);
|
2016-02-29 14:35:28 +00:00
|
|
|
|
2016-06-09 15:59:48 +00:00
|
|
|
static void crash_handler(int sig) {
|
2016-06-10 20:56:35 +00:00
|
|
|
SkAutoMutexAcquire lock(gMutex);
|
2016-06-09 15:59:48 +00:00
|
|
|
|
2018-06-28 14:08:19 +00:00
|
|
|
info("\nCaught signal %d [%s] (%dMB RAM, peak %dMB), was running:\n",
|
|
|
|
sig, strsignal(sig),
|
|
|
|
sk_tools::getCurrResidentSetSizeMB(), sk_tools::getMaxResidentSetSizeMB());
|
|
|
|
|
2016-06-09 15:59:48 +00:00
|
|
|
for (auto& task : gRunning) {
|
2016-07-25 22:27:29 +00:00
|
|
|
task.dump();
|
2016-06-09 15:59:48 +00:00
|
|
|
}
|
2016-07-25 22:27:29 +00:00
|
|
|
find_culprit();
|
2016-06-09 15:59:48 +00:00
|
|
|
|
2016-10-24 15:39:43 +00:00
|
|
|
#if !defined(SK_BUILD_FOR_ANDROID)
|
2016-06-09 15:59:48 +00:00
|
|
|
void* stack[64];
|
|
|
|
int count = backtrace(stack, SK_ARRAY_COUNT(stack));
|
|
|
|
char** symbols = backtrace_symbols(stack, count);
|
|
|
|
info("\nStack trace:\n");
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
info(" %s\n", symbols[i]);
|
|
|
|
}
|
2016-10-24 15:39:43 +00:00
|
|
|
#endif
|
2016-06-09 15:59:48 +00:00
|
|
|
fflush(stdout);
|
|
|
|
|
2019-03-18 14:01:39 +00:00
|
|
|
if (sig == SIGINT && FLAGS_ignoreSigInt) {
|
|
|
|
info("Ignoring signal %d because of --ignoreSigInt.\n"
|
|
|
|
"This is probably a sign the bot is overloaded with work.\n", sig);
|
|
|
|
} else {
|
|
|
|
signal(sig, previous_handler[sig]);
|
|
|
|
raise(sig);
|
|
|
|
}
|
2016-06-09 15:59:48 +00:00
|
|
|
}
|
|
|
|
|
2016-02-23 18:39:36 +00:00
|
|
|
static void setup_crash_handler() {
|
2018-06-28 14:08:19 +00:00
|
|
|
const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM };
|
2016-02-23 18:39:36 +00:00
|
|
|
for (int sig : kSignals) {
|
2016-10-24 15:39:43 +00:00
|
|
|
previous_handler[sig] = signal(sig, crash_handler);
|
2016-02-23 18:39:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2019-01-25 18:02:59 +00:00
|
|
|
struct Gold : public SkString {
|
|
|
|
Gold() : SkString("") {}
|
|
|
|
Gold(const SkString& sink, const SkString& src,
|
|
|
|
const SkString& srcOptions, const SkString& name,
|
|
|
|
const SkString& md5)
|
|
|
|
: SkString("") {
|
|
|
|
this->append(sink);
|
|
|
|
this->append(src);
|
|
|
|
this->append(srcOptions);
|
|
|
|
this->append(name);
|
|
|
|
this->append(md5);
|
|
|
|
}
|
|
|
|
struct Hash {
|
|
|
|
uint32_t operator()(const Gold& g) const {
|
|
|
|
return SkGoodHash()((const SkString&)g);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
static SkTHashSet<Gold, Gold::Hash> gGold;
|
|
|
|
|
|
|
|
static void add_gold(JsonWriter::BitmapResult r) {
|
|
|
|
gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gather_gold() {
|
|
|
|
if (!FLAGS_readPath.isEmpty()) {
|
|
|
|
SkString path(FLAGS_readPath[0]);
|
|
|
|
path.append("/dm.json");
|
|
|
|
if (!JsonWriter::ReadJson(path.c_str(), add_gold)) {
|
|
|
|
fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2018-01-24 17:42:55 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN)
|
2016-03-16 15:37:19 +00:00
|
|
|
static const char* kNewline = "\r\n";
|
|
|
|
#else
|
|
|
|
static const char* kNewline = "\n";
|
|
|
|
#endif
|
|
|
|
|
2015-04-03 21:15:33 +00:00
|
|
|
static SkTHashSet<SkString> gUninterestingHashes;
|
|
|
|
|
|
|
|
static void gather_uninteresting_hashes() {
|
|
|
|
if (!FLAGS_uninterestingHashesFile.isEmpty()) {
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_uninterestingHashesFile[0]));
|
2015-09-22 18:43:53 +00:00
|
|
|
if (!data) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("WARNING: unable to read uninteresting hashes from %s\n",
|
|
|
|
FLAGS_uninterestingHashesFile[0]);
|
2015-09-22 18:43:53 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-04-05 22:04:31 +00:00
|
|
|
|
|
|
|
// Copy to a string to make sure SkStrSplit has a terminating \0 to find.
|
|
|
|
SkString contents((const char*)data->data(), data->size());
|
|
|
|
|
2015-04-03 21:15:33 +00:00
|
|
|
SkTArray<SkString> hashes;
|
2017-04-05 22:04:31 +00:00
|
|
|
SkStrSplit(contents.c_str(), kNewline, &hashes);
|
2015-04-03 21:15:33 +00:00
|
|
|
for (const SkString& hash : hashes) {
|
|
|
|
gUninterestingHashes.add(hash);
|
|
|
|
}
|
2016-03-08 17:01:39 +00:00
|
|
|
info("FYI: loaded %d distinct uninteresting hashes from %d lines\n",
|
|
|
|
gUninterestingHashes.count(), hashes.count());
|
2015-04-03 21:15:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2016-11-03 18:40:50 +00:00
|
|
|
struct TaggedSrc : public std::unique_ptr<Src> {
|
2016-02-25 03:07:07 +00:00
|
|
|
SkString tag;
|
|
|
|
SkString options;
|
2015-07-29 13:37:28 +00:00
|
|
|
};
|
|
|
|
|
2016-11-03 18:40:50 +00:00
|
|
|
struct TaggedSink : public std::unique_ptr<Sink> {
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
SkString tag;
|
2015-04-03 14:24:48 +00:00
|
|
|
};
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
static const bool kMemcpyOK = true;
|
|
|
|
|
2015-07-29 13:37:28 +00:00
|
|
|
static SkTArray<TaggedSrc, kMemcpyOK> gSrcs;
|
|
|
|
static SkTArray<TaggedSink, kMemcpyOK> gSinks;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2015-04-27 15:45:01 +00:00
|
|
|
static bool in_shard() {
|
|
|
|
static int N = 0;
|
|
|
|
return N++ % FLAGS_shards == FLAGS_shard;
|
|
|
|
}
|
|
|
|
|
2016-02-25 03:07:07 +00:00
|
|
|
static void push_src(const char* tag, ImplicitString options, Src* s) {
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<Src> src(s);
|
2019-03-20 15:50:33 +00:00
|
|
|
if (in_shard() && FLAGS_src.contains(tag) &&
|
|
|
|
!CommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
|
2015-07-29 13:37:28 +00:00
|
|
|
TaggedSrc& s = gSrcs.push_back();
|
2016-03-16 20:53:35 +00:00
|
|
|
s.reset(src.release());
|
2015-01-15 18:56:12 +00:00
|
|
|
s.tag = tag;
|
2015-04-03 14:24:48 +00:00
|
|
|
s.options = options;
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-01 21:57:57 +00:00
|
|
|
static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorType dstColorType,
|
2016-02-03 17:42:42 +00:00
|
|
|
SkAlphaType dstAlphaType, float scale) {
|
2016-02-25 19:03:47 +00:00
|
|
|
if (FLAGS_simpleCodec) {
|
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
|
|
|
const bool simple = CodecSrc::kCodec_Mode == mode || CodecSrc::kAnimated_Mode == mode;
|
|
|
|
if (!simple || dstColorType != CodecSrc::kGetFromCanvas_DstColorType || scale != 1.0f) {
|
2016-02-25 19:03:47 +00:00
|
|
|
// Only decode in the simple case.
|
|
|
|
return;
|
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
|
|
|
}
|
2016-02-25 19:03:47 +00:00
|
|
|
}
|
2015-09-01 21:57:57 +00:00
|
|
|
SkString folder;
|
|
|
|
switch (mode) {
|
|
|
|
case CodecSrc::kCodec_Mode:
|
|
|
|
folder.append("codec");
|
|
|
|
break;
|
2016-01-13 17:31:39 +00:00
|
|
|
case CodecSrc::kCodecZeroInit_Mode:
|
|
|
|
folder.append("codec_zero_init");
|
|
|
|
break;
|
2015-09-01 21:57:57 +00:00
|
|
|
case CodecSrc::kScanline_Mode:
|
|
|
|
folder.append("scanline");
|
|
|
|
break;
|
|
|
|
case CodecSrc::kStripe_Mode:
|
|
|
|
folder.append("stripe");
|
|
|
|
break;
|
2016-02-22 20:27:46 +00:00
|
|
|
case CodecSrc::kCroppedScanline_Mode:
|
|
|
|
folder.append("crop");
|
|
|
|
break;
|
2015-09-01 21:57:57 +00:00
|
|
|
case CodecSrc::kSubset_Mode:
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
folder.append("codec_subset");
|
2015-09-01 21:57:57 +00:00
|
|
|
break;
|
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
|
|
|
case CodecSrc::kAnimated_Mode:
|
|
|
|
folder.append("codec_animated");
|
|
|
|
break;
|
2015-09-01 21:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (dstColorType) {
|
|
|
|
case CodecSrc::kGrayscale_Always_DstColorType:
|
|
|
|
folder.append("_kGray8");
|
|
|
|
break;
|
2016-04-22 23:27:24 +00:00
|
|
|
case CodecSrc::kNonNative8888_Always_DstColorType:
|
|
|
|
folder.append("_kNonNative");
|
|
|
|
break;
|
2015-09-01 21:57:57 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:42:42 +00:00
|
|
|
switch (dstAlphaType) {
|
|
|
|
case kPremul_SkAlphaType:
|
|
|
|
folder.append("_premul");
|
|
|
|
break;
|
|
|
|
case kUnpremul_SkAlphaType:
|
|
|
|
folder.append("_unpremul");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-09-01 21:57:57 +00:00
|
|
|
if (1.0f != scale) {
|
|
|
|
folder.appendf("_%.3f", scale);
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:42:42 +00:00
|
|
|
CodecSrc* src = new CodecSrc(path, mode, dstColorType, dstAlphaType, scale);
|
2015-09-01 21:57:57 +00:00
|
|
|
push_src("image", folder, src);
|
|
|
|
}
|
|
|
|
|
2016-05-16 16:04:13 +00:00
|
|
|
static void push_android_codec_src(Path path, CodecSrc::DstColorType dstColorType,
|
|
|
|
SkAlphaType dstAlphaType, int sampleSize) {
|
2015-10-21 17:27:10 +00:00
|
|
|
SkString folder;
|
2016-05-16 16:04:13 +00:00
|
|
|
folder.append("scaled_codec");
|
2015-10-21 17:27:10 +00:00
|
|
|
|
|
|
|
switch (dstColorType) {
|
|
|
|
case CodecSrc::kGrayscale_Always_DstColorType:
|
|
|
|
folder.append("_kGray8");
|
|
|
|
break;
|
2016-04-22 23:27:24 +00:00
|
|
|
case CodecSrc::kNonNative8888_Always_DstColorType:
|
|
|
|
folder.append("_kNonNative");
|
|
|
|
break;
|
2015-10-21 17:27:10 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:42:42 +00:00
|
|
|
switch (dstAlphaType) {
|
|
|
|
case kPremul_SkAlphaType:
|
|
|
|
folder.append("_premul");
|
|
|
|
break;
|
2016-02-03 20:39:10 +00:00
|
|
|
case kUnpremul_SkAlphaType:
|
|
|
|
folder.append("_unpremul");
|
|
|
|
break;
|
2016-02-03 17:42:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-21 17:27:10 +00:00
|
|
|
if (1 != sampleSize) {
|
2015-11-13 17:59:11 +00:00
|
|
|
folder.appendf("_%.3f", 1.0f / (float) sampleSize);
|
2015-10-21 17:27:10 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 16:04:13 +00:00
|
|
|
AndroidCodecSrc* src = new AndroidCodecSrc(path, dstColorType, dstAlphaType, sampleSize);
|
2015-10-21 17:27:10 +00:00
|
|
|
push_src("image", folder, src);
|
|
|
|
}
|
|
|
|
|
2016-03-09 22:20:58 +00:00
|
|
|
static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType alphaType, bool isGpu)
|
|
|
|
{
|
|
|
|
SkString folder;
|
|
|
|
switch (mode) {
|
|
|
|
case ImageGenSrc::kCodec_Mode:
|
|
|
|
folder.append("gen_codec");
|
|
|
|
break;
|
|
|
|
case ImageGenSrc::kPlatform_Mode:
|
|
|
|
folder.append("gen_platform");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isGpu) {
|
|
|
|
folder.append("_gpu");
|
|
|
|
} else {
|
|
|
|
switch (alphaType) {
|
|
|
|
case kOpaque_SkAlphaType:
|
|
|
|
folder.append("_opaque");
|
|
|
|
break;
|
|
|
|
case kPremul_SkAlphaType:
|
|
|
|
folder.append("_premul");
|
|
|
|
break;
|
|
|
|
case kUnpremul_SkAlphaType:
|
|
|
|
folder.append("_unpremul");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu);
|
|
|
|
push_src("image", folder, src);
|
|
|
|
}
|
|
|
|
|
2017-08-15 16:24:02 +00:00
|
|
|
static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode,
|
|
|
|
uint32_t sampleSize) {
|
|
|
|
SkString folder("brd_android_codec");
|
|
|
|
switch (mode) {
|
|
|
|
case BRDSrc::kFullImage_Mode:
|
|
|
|
break;
|
|
|
|
case BRDSrc::kDivisor_Mode:
|
|
|
|
folder.append("_divisor");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (dstColorType) {
|
|
|
|
case CodecSrc::kGetFromCanvas_DstColorType:
|
|
|
|
break;
|
|
|
|
case CodecSrc::kGrayscale_Always_DstColorType:
|
|
|
|
folder.append("_kGray");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (1 != sampleSize) {
|
|
|
|
folder.appendf("_%.3f", 1.0f / (float) sampleSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize);
|
|
|
|
push_src("image", folder, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void push_brd_srcs(Path path, bool gray) {
|
|
|
|
if (gray) {
|
|
|
|
// Only run grayscale to one sampleSize and Mode. Though interesting
|
|
|
|
// to test grayscale, it should not reveal anything across various
|
|
|
|
// sampleSizes and Modes
|
|
|
|
// Arbitrarily choose Mode and sampleSize.
|
|
|
|
push_brd_src(path, CodecSrc::kGrayscale_Always_DstColorType,
|
|
|
|
BRDSrc::kFullImage_Mode, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test on a variety of sampleSizes, making sure to include:
|
|
|
|
// - 2, 4, and 8, which are natively supported by jpeg
|
|
|
|
// - multiples of 2 which are not divisible by 4 (analogous for 4)
|
|
|
|
// - larger powers of two, since BRD clients generally use powers of 2
|
|
|
|
// We will only produce output for the larger sizes on large images.
|
|
|
|
const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 };
|
|
|
|
|
|
|
|
const BRDSrc::Mode modes[] = { BRDSrc::kFullImage_Mode, BRDSrc::kDivisor_Mode, };
|
|
|
|
|
|
|
|
for (uint32_t sampleSize : sampleSizes) {
|
|
|
|
for (BRDSrc::Mode mode : modes) {
|
|
|
|
push_brd_src(path, CodecSrc::kGetFromCanvas_DstColorType, mode, sampleSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-09 19:43:10 +00:00
|
|
|
static void push_codec_srcs(Path path) {
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
|
2015-04-09 19:43:10 +00:00
|
|
|
if (!encoded) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("Couldn't read %s.", path.c_str());
|
2015-04-09 19:43:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-07-23 19:30:02 +00:00
|
|
|
std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(encoded);
|
2015-08-27 14:41:13 +00:00
|
|
|
if (nullptr == codec.get()) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("Couldn't create codec for %s.", path.c_str());
|
2015-04-09 19:43:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-20 15:38:54 +00:00
|
|
|
// native scaling is only supported by WEBP and JPEG
|
|
|
|
bool supportsNativeScaling = false;
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
|
2016-02-22 20:27:46 +00:00
|
|
|
SkTArray<CodecSrc::Mode> nativeModes;
|
|
|
|
nativeModes.push_back(CodecSrc::kCodec_Mode);
|
|
|
|
nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode);
|
|
|
|
switch (codec->getEncodedFormat()) {
|
2016-11-23 15:55:18 +00:00
|
|
|
case SkEncodedImageFormat::kJPEG:
|
2016-02-22 20:27:46 +00:00
|
|
|
nativeModes.push_back(CodecSrc::kScanline_Mode);
|
|
|
|
nativeModes.push_back(CodecSrc::kStripe_Mode);
|
|
|
|
nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
|
2016-05-20 15:38:54 +00:00
|
|
|
supportsNativeScaling = true;
|
2016-02-22 20:27:46 +00:00
|
|
|
break;
|
2016-11-23 15:55:18 +00:00
|
|
|
case SkEncodedImageFormat::kWEBP:
|
2016-02-22 20:27:46 +00:00
|
|
|
nativeModes.push_back(CodecSrc::kSubset_Mode);
|
2016-05-20 15:38:54 +00:00
|
|
|
supportsNativeScaling = true;
|
2016-02-22 20:27:46 +00:00
|
|
|
break;
|
2016-11-23 15:55:18 +00:00
|
|
|
case SkEncodedImageFormat::kDNG:
|
2016-02-23 13:37:25 +00:00
|
|
|
break;
|
2016-02-22 20:27:46 +00:00
|
|
|
default:
|
|
|
|
nativeModes.push_back(CodecSrc::kScanline_Mode);
|
|
|
|
break;
|
|
|
|
}
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
|
2016-02-22 20:27:46 +00:00
|
|
|
SkTArray<CodecSrc::DstColorType> colorTypes;
|
|
|
|
colorTypes.push_back(CodecSrc::kGetFromCanvas_DstColorType);
|
2016-04-22 23:27:24 +00:00
|
|
|
colorTypes.push_back(CodecSrc::kNonNative8888_Always_DstColorType);
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
switch (codec->getInfo().colorType()) {
|
|
|
|
case kGray_8_SkColorType:
|
2016-02-22 20:27:46 +00:00
|
|
|
colorTypes.push_back(CodecSrc::kGrayscale_Always_DstColorType);
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-06-11 21:27:27 +00:00
|
|
|
|
2016-02-03 17:42:42 +00:00
|
|
|
SkTArray<SkAlphaType> alphaModes;
|
|
|
|
alphaModes.push_back(kPremul_SkAlphaType);
|
2016-05-20 18:08:27 +00:00
|
|
|
if (codec->getInfo().alphaType() != kOpaque_SkAlphaType) {
|
|
|
|
alphaModes.push_back(kUnpremul_SkAlphaType);
|
2016-02-03 17:42:42 +00:00
|
|
|
}
|
2016-01-22 22:46:42 +00:00
|
|
|
|
|
|
|
for (CodecSrc::Mode mode : nativeModes) {
|
2016-05-20 15:38:54 +00:00
|
|
|
for (CodecSrc::DstColorType colorType : colorTypes) {
|
|
|
|
for (SkAlphaType alphaType : alphaModes) {
|
2016-05-20 18:08:27 +00:00
|
|
|
// Only test kCroppedScanline_Mode when the alpha type is premul. The test is
|
2016-05-20 15:38:54 +00:00
|
|
|
// slow and won't be interestingly different with different alpha types.
|
|
|
|
if (CodecSrc::kCroppedScanline_Mode == mode &&
|
2016-05-20 18:08:27 +00:00
|
|
|
kPremul_SkAlphaType != alphaType) {
|
2016-05-20 15:38:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-02-22 20:27:46 +00:00
|
|
|
|
2016-05-20 15:38:54 +00:00
|
|
|
push_codec_src(path, mode, colorType, alphaType, 1.0f);
|
2016-04-26 20:06:38 +00:00
|
|
|
|
2016-05-20 15:38:54 +00:00
|
|
|
// Skip kNonNative on different native scales. It won't be interestingly
|
|
|
|
// different.
|
|
|
|
if (supportsNativeScaling &&
|
|
|
|
CodecSrc::kNonNative8888_Always_DstColorType == colorType) {
|
|
|
|
// Native Scales
|
|
|
|
// SkJpegCodec natively supports scaling to the following:
|
|
|
|
for (auto scale : { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f }) {
|
|
|
|
push_codec_src(path, mode, colorType, alphaType, scale);
|
|
|
|
}
|
2016-02-03 17:42:42 +00:00
|
|
|
}
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-01 21:57:57 +00:00
|
|
|
|
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
|
|
|
{
|
|
|
|
std::vector<SkCodec::FrameInfo> frameInfos = codec->getFrameInfo();
|
|
|
|
if (frameInfos.size() > 1) {
|
Add animation support to SkWebpCodec
TBR=reed@google.com
(No change to the public API, but changed a header file)
SkWebpCodec:
- Implement onGetFrameCount, onGetFrameInfo, and onGetRepetitionCount
- Respect the alpha reported by libwebp. Although the spec states that
it is only a hint, the libwebp encoder uses it properly. Respecting
allows us to draw opaque images faster and decode them to 565. This
also matches other SkCodecs (and Chromium).
- onGetPixels:
- Decode the frame requested, recursively decoding required frame if
necessary
- When blending with a prior frame, use SkRasterPipeline
SkCodec:
- Move check for negative index to getFrameInfo
- Reset the colorXform if one is not needed
SkCodecAnimation:
- Add new blend enum, for WebP's (and APNG's) non-blending option
SkFrameHolder:
- New base classes for frames and the owner of the frames, allowing
code sharing between SkWebpCodec and SkGifCodec (particularly for
determining whether a frame has alpha and what frame it depends on)
- When moving items from SkGIFFrameContext, use Skia conventions (i.e.
int instead of unsigned)
- Rename "delay time" to "duration", to match e.g. SkFrameInfo::
fDuration
SkGifImageReader:
- Move pieces to SkFrameHolder, and adapt to changes made in the
process
- Make setAlphaAndRequiredFrame (now on the base class SkFrameHolder)
more general to support webp, and add support for frames that do not
blend
- Change SkGIFFrameContext from a struct to a class, to match how we
use the distinction elsewhere (i.e. struct is a small object with
public fields)
- Rework hasTransparentPixel (now hasTransparency, since it returns true
in some cases where there is not a transparent pixel) to better fit
with the modified setAlphaAndRequiredFrame. Also be more consistent
when there is no transparent pixel but no color map.
- Simplify an if condition that was previously simplified in 2d61e717
but accidentally got reverted in a4db9be6
CodecAnimTest:
- Test new animated webp files
- Rearrange the test to more cleanly print alpha type mismatches for
the first frame
resources:
- webp-animated.webp
- animated webp from Chromium
- blendBG.webp
- new webp file using bits of webp-animated-semitransparent4.webp
from Chromium
- tests required frame and alpha when using the non-blending mode
- frames have the following properties:
- Frame 0: no alpha, fills screen
- Frame 1: alpha, fills screen
- Frame 2: no alpha, fills screen
- Frame 3: alpha, fills screen, blendBG
- Frame 4: no alpha, fills screen, blendBG
- Frame 5: alpha, blendBG
- Frame 6: covers 4, has alpha, blendBG
- also used to test decoding to 565 if the new frame data has alpha
but blends onto an opaque frame
DM.cpp:
- Test animated images to non-native 8888 and unpremul
DMSrcSink.cpp:
- Do not test non-native 8888 decodes to f16 dst
- Test unpremul decodes to f16
- Copy a frame of an animated image prior to drawing, since in unpremul
mode, the DM code will premultiply first.
Bug: skia: 3315
Change-Id: I4e55ae2ee5bc095b37a743bdcfac644be603b980
Reviewed-on: https://skia-review.googlesource.com/16707
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2017-05-23 13:37:21 +00:00
|
|
|
for (auto dstCT : { CodecSrc::kNonNative8888_Always_DstColorType,
|
|
|
|
CodecSrc::kGetFromCanvas_DstColorType }) {
|
|
|
|
for (auto at : { kUnpremul_SkAlphaType, kPremul_SkAlphaType }) {
|
|
|
|
push_codec_src(path, CodecSrc::kAnimated_Mode, dstCT, at, 1.0f);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-25 19:03:47 +00:00
|
|
|
if (FLAGS_simpleCodec) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-21 17:27:10 +00:00
|
|
|
const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
|
|
|
|
|
|
|
for (int sampleSize : sampleSizes) {
|
2016-02-22 20:27:46 +00:00
|
|
|
for (CodecSrc::DstColorType colorType : colorTypes) {
|
2016-02-03 17:42:42 +00:00
|
|
|
for (SkAlphaType alphaType : alphaModes) {
|
2016-04-26 20:06:38 +00:00
|
|
|
// We can exercise all of the kNonNative support code in the swizzler with just a
|
|
|
|
// few sample sizes. Skip the rest.
|
|
|
|
if (CodecSrc::kNonNative8888_Always_DstColorType == colorType && sampleSize > 3) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-05-16 16:04:13 +00:00
|
|
|
push_android_codec_src(path, colorType, alphaType, sampleSize);
|
2015-10-21 17:27:10 +00:00
|
|
|
}
|
2015-09-01 21:57:57 +00:00
|
|
|
}
|
2015-06-11 21:27:27 +00:00
|
|
|
}
|
2016-03-09 22:20:58 +00:00
|
|
|
|
2017-08-15 16:24:02 +00:00
|
|
|
const char* ext = strrchr(path.c_str(), '.');
|
|
|
|
if (ext) {
|
|
|
|
ext++;
|
2016-03-09 22:20:58 +00:00
|
|
|
|
2017-08-15 16:24:02 +00:00
|
|
|
static const char* const rawExts[] = {
|
|
|
|
"arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
|
|
|
|
"ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
|
|
|
|
};
|
|
|
|
for (const char* rawExt : rawExts) {
|
|
|
|
if (0 == strcmp(rawExt, ext)) {
|
|
|
|
// RAW is not supported by image generator (skbug.com/5079) or BRD.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* const brdExts[] = {
|
|
|
|
"jpg", "jpeg", "png", "webp",
|
|
|
|
"JPG", "JPEG", "PNG", "WEBP",
|
|
|
|
};
|
|
|
|
for (const char* brdExt : brdExts) {
|
|
|
|
if (0 == strcmp(brdExt, ext)) {
|
2017-12-05 18:55:24 +00:00
|
|
|
bool gray = codec->getInfo().colorType() == kGray_8_SkColorType;
|
2017-08-15 16:24:02 +00:00
|
|
|
push_brd_srcs(path, gray);
|
|
|
|
break;
|
|
|
|
}
|
2016-03-09 22:20:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Push image generator GPU test.
|
2016-03-24 14:27:43 +00:00
|
|
|
push_image_gen_src(path, ImageGenSrc::kCodec_Mode, codec->getInfo().alphaType(), true);
|
2016-03-09 22:20:58 +00:00
|
|
|
|
|
|
|
// Push image generator CPU tests.
|
|
|
|
for (SkAlphaType alphaType : alphaModes) {
|
|
|
|
push_image_gen_src(path, ImageGenSrc::kCodec_Mode, alphaType, false);
|
|
|
|
|
|
|
|
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
|
2016-11-23 15:55:18 +00:00
|
|
|
if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
|
|
|
|
SkEncodedImageFormat::kWBMP != codec->getEncodedFormat() &&
|
2016-03-09 22:20:58 +00:00
|
|
|
kUnpremul_SkAlphaType != alphaType)
|
|
|
|
{
|
|
|
|
push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
|
|
|
|
}
|
2016-03-17 20:50:17 +00:00
|
|
|
#elif defined(SK_BUILD_FOR_WIN)
|
2016-11-23 15:55:18 +00:00
|
|
|
if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
|
|
|
|
SkEncodedImageFormat::kWBMP != codec->getEncodedFormat())
|
2016-03-17 20:50:17 +00:00
|
|
|
{
|
|
|
|
push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
|
|
|
|
}
|
2016-03-09 22:20:58 +00:00
|
|
|
#endif
|
|
|
|
}
|
2015-04-09 19:43:10 +00:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:53:36 +00:00
|
|
|
template <typename T>
|
2019-03-20 15:50:33 +00:00
|
|
|
void gather_file_srcs(const CommandLineFlags::StringArray& flags,
|
|
|
|
const char* ext,
|
|
|
|
const char* src_name = nullptr) {
|
2018-07-19 19:09:11 +00:00
|
|
|
if (!src_name) {
|
|
|
|
// With the exception of Lottie files, the source name is the extension.
|
|
|
|
src_name = ext;
|
|
|
|
}
|
|
|
|
|
2016-08-04 02:53:36 +00:00
|
|
|
for (int i = 0; i < flags.count(); i++) {
|
|
|
|
const char* path = flags[i];
|
2015-01-30 15:31:19 +00:00
|
|
|
if (sk_isdir(path)) {
|
2016-08-04 02:53:36 +00:00
|
|
|
SkOSFile::Iter it(path, ext);
|
2015-01-30 15:31:19 +00:00
|
|
|
for (SkString file; it.next(&file); ) {
|
2018-07-19 19:09:11 +00:00
|
|
|
push_src(src_name, "", new T(SkOSPath::Join(path, file.c_str())));
|
2015-01-30 15:31:19 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-07-19 19:09:11 +00:00
|
|
|
push_src(src_name, "", new T(path));
|
2014-02-28 20:31:31 +00:00
|
|
|
}
|
2014-02-26 16:31:22 +00:00
|
|
|
}
|
2016-08-04 02:53:36 +00:00
|
|
|
}
|
2016-02-03 20:19:11 +00:00
|
|
|
|
2016-08-04 02:53:36 +00:00
|
|
|
static bool gather_srcs() {
|
2018-07-30 21:07:07 +00:00
|
|
|
for (skiagm::GMFactory f : skiagm::GMRegistry::Range()) {
|
|
|
|
push_src("gm", "", new GMSrc(f));
|
2016-06-02 19:41:14 +00:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:01:16 +00:00
|
|
|
gather_file_srcs<SKPSrc>(FLAGS_skps, "skp");
|
2016-08-04 02:53:36 +00:00
|
|
|
gather_file_srcs<MSKPSrc>(FLAGS_mskps, "mskp");
|
2018-05-04 16:23:24 +00:00
|
|
|
#if defined(SK_ENABLE_SKOTTIE)
|
2018-07-19 19:09:11 +00:00
|
|
|
gather_file_srcs<SkottieSrc>(FLAGS_lotties, "json", "lottie");
|
2017-12-31 22:02:26 +00:00
|
|
|
#endif
|
2016-08-04 02:53:36 +00:00
|
|
|
#if defined(SK_XML)
|
|
|
|
gather_file_srcs<SVGSrc>(FLAGS_svgs, "svg");
|
|
|
|
#endif
|
2018-09-28 17:27:39 +00:00
|
|
|
if (!FLAGS_bisect.isEmpty()) {
|
|
|
|
// An empty l/r trail string will draw all the paths.
|
|
|
|
push_src("bisect", "",
|
|
|
|
new BisectSrc(FLAGS_bisect[0], FLAGS_bisect.count() > 1 ? FLAGS_bisect[1] : ""));
|
|
|
|
}
|
2016-08-04 02:53:36 +00:00
|
|
|
|
2016-02-03 20:19:11 +00:00
|
|
|
SkTArray<SkString> images;
|
2016-04-29 16:38:40 +00:00
|
|
|
if (!CollectImages(FLAGS_images, &images)) {
|
2016-02-03 20:19:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto image : images) {
|
|
|
|
push_codec_srcs(image);
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2016-02-03 20:19:11 +00:00
|
|
|
|
2016-04-29 16:38:40 +00:00
|
|
|
SkTArray<SkString> colorImages;
|
|
|
|
if (!CollectImages(FLAGS_colorImages, &colorImages)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto colorImage : colorImages) {
|
2019-03-06 16:56:04 +00:00
|
|
|
push_src("colorImage", "decode_native", new ColorCodecSrc(colorImage, false));
|
|
|
|
push_src("colorImage", "decode_to_dst", new ColorCodecSrc(colorImage, true));
|
2016-04-29 16:38:40 +00:00
|
|
|
}
|
|
|
|
|
2016-02-03 20:19:11 +00:00
|
|
|
return true;
|
2015-01-15 16:30:25 +00:00
|
|
|
}
|
|
|
|
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
static void push_sink(const SkCommandLineConfig& config, Sink* s) {
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<Sink> sink(s);
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
|
2015-07-29 13:37:28 +00:00
|
|
|
// Try a simple Src as a canary. If it fails, skip this sink.
|
2015-01-15 18:56:12 +00:00
|
|
|
struct : public Src {
|
2015-07-29 13:37:28 +00:00
|
|
|
Error draw(SkCanvas* c) const override {
|
|
|
|
c->drawRect(SkRect::MakeWH(1,1), SkPaint());
|
|
|
|
return "";
|
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize size() const override { return SkISize::Make(16, 16); }
|
2015-07-29 13:37:28 +00:00
|
|
|
Name name() const override { return "justOneRect"; }
|
|
|
|
} justOneRect;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkDynamicMemoryWStream stream;
|
2015-02-03 02:26:03 +00:00
|
|
|
SkString log;
|
2015-07-29 13:37:28 +00:00
|
|
|
Error err = sink->draw(justOneRect, &bitmap, &stream, &log);
|
2015-03-05 16:40:28 +00:00
|
|
|
if (err.isFatal()) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("Could not run %s: %s\n", config.getTag().c_str(), err.c_str());
|
2015-04-21 17:49:13 +00:00
|
|
|
exit(1);
|
2014-07-28 14:21:24 +00:00
|
|
|
}
|
2015-01-15 16:30:25 +00:00
|
|
|
|
2015-07-29 13:37:28 +00:00
|
|
|
TaggedSink& ts = gSinks.push_back();
|
2016-03-16 20:53:35 +00:00
|
|
|
ts.reset(sink.release());
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
ts.tag = config.getTag();
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
|
2019-02-19 11:14:39 +00:00
|
|
|
static sk_sp<SkColorSpace> rgb_to_gbr() {
|
|
|
|
return SkColorSpace::MakeSRGB()->makeColorSpin();
|
|
|
|
}
|
|
|
|
|
2017-02-22 19:00:42 +00:00
|
|
|
static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLineConfig* config) {
|
2018-05-31 18:27:17 +00:00
|
|
|
if (FLAGS_gpu) {
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
|
2016-04-05 18:06:27 +00:00
|
|
|
GrContextFactory::ContextType contextType = gpuConfig->getContextType();
|
2017-02-21 19:36:05 +00:00
|
|
|
GrContextFactory::ContextOverrides contextOverrides = gpuConfig->getContextOverrides();
|
2017-02-22 19:00:42 +00:00
|
|
|
GrContextFactory testFactory(grCtxOptions);
|
2017-02-21 19:36:05 +00:00
|
|
|
if (!testFactory.get(contextType, contextOverrides)) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("WARNING: can not create GPU context for config '%s'. "
|
|
|
|
"GM tests will be skipped.\n", gpuConfig->getTag().c_str());
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2017-08-30 14:02:10 +00:00
|
|
|
if (gpuConfig->getTestThreading()) {
|
2018-07-11 19:32:05 +00:00
|
|
|
SkASSERT(!gpuConfig->getTestPersistentCache());
|
2018-03-09 14:01:53 +00:00
|
|
|
return new GPUThreadTestingSink(
|
|
|
|
contextType, contextOverrides, gpuConfig->getSurfType(),
|
|
|
|
gpuConfig->getSamples(), gpuConfig->getUseDIText(),
|
|
|
|
gpuConfig->getColorType(), gpuConfig->getAlphaType(),
|
|
|
|
sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading, grCtxOptions);
|
2018-07-11 19:32:05 +00:00
|
|
|
} else if (gpuConfig->getTestPersistentCache()) {
|
|
|
|
return new GPUPersistentCacheTestingSink(
|
|
|
|
contextType, contextOverrides, gpuConfig->getSurfType(),
|
|
|
|
gpuConfig->getSamples(), gpuConfig->getUseDIText(),
|
|
|
|
gpuConfig->getColorType(), gpuConfig->getAlphaType(),
|
2019-04-03 17:04:16 +00:00
|
|
|
sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading, grCtxOptions,
|
|
|
|
gpuConfig->getTestPersistentCache());
|
2017-08-30 14:02:10 +00:00
|
|
|
} else {
|
2018-03-09 14:01:53 +00:00
|
|
|
return new GPUSink(contextType, contextOverrides, gpuConfig->getSurfType(),
|
|
|
|
gpuConfig->getSamples(), gpuConfig->getUseDIText(),
|
|
|
|
gpuConfig->getColorType(), gpuConfig->getAlphaType(),
|
|
|
|
sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading,
|
|
|
|
grCtxOptions);
|
2017-08-30 14:02:10 +00:00
|
|
|
}
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
}
|
Revert of Add config options to run different GPU APIs to dm and nanobench (patchset #21 id:400001 of https://codereview.chromium.org/1490113005/ )
Reason for revert:
The Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug builder fails after this CL.
Links to specific builds:
http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1689
http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1690
http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1691
Original issue's description:
> Add config options to run different GPU APIs to dm and nanobench
>
> Add extended config specification form that can be used to run different
> gpu backend with different APIs.
>
> The configs can be specified with the form:
> gpu(api=string,dit=bool,nvpr=bool,samples=int)
>
> This replaces and removes the --gpuAPI flag.
>
> All existing configs should still work.
>
> Adds following documentation:
>
> out/Debug/dm --help config
>
> Flags:
> --config: type: string default: 565 8888 gpu nonrendering
> Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
> nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
> xps or use extended form 'backend(option=value,...)'.
>
> Extended form: 'backend(option=value,...)'
>
> Possible backends and options:
>
> gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
> api type: string default: native.
> Select graphics API to use with gpu backend.
> Options:
> native Use platform default OpenGL or OpenGL ES backend.
> gl Use OpenGL.
> gles Use OpenGL ES.
> debug Use debug OpenGL.
> null Use null OpenGL.
> dit type: bool default: false.
> Use device independent text.
> nvpr type: bool default: false.
> Use NV_path_rendering OpenGL and OpenGL ES extension.
> samples type: int default: 0.
> Use multisampling with N samples.
>
> Predefined configs:
>
> gpu = gpu()
> msaa4 = gpu(samples=4)
> msaa16 = gpu(samples=16)
> nvprmsaa4 = gpu(nvpr=true,samples=4)
> nvprmsaa16 = gpu(nvpr=true,samples=16)
> gpudft = gpu(dit=true)
> gpudebug = gpu(api=debug)
> gpunull = gpu(api=null)
> debug = gpu(api=debug)
> nullgpu = gpu(api=null)
>
> BUG=skia:2992
>
> Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
>
> Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
>
> Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
TBR=mtklein@google.com,bsalomon@google.com,joshualitt@google.com,scroggo@google.com,kkinnunen@nvidia.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:2992
Review URL: https://codereview.chromium.org/1548683002
2015-12-22 18:22:26 +00:00
|
|
|
}
|
2018-03-02 21:54:21 +00:00
|
|
|
if (const SkCommandLineConfigSvg* svgConfig = config->asConfigSvg()) {
|
|
|
|
int pageIndex = svgConfig->getPageIndex();
|
|
|
|
return new SVGSink(pageIndex);
|
|
|
|
}
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
|
2018-11-30 20:33:19 +00:00
|
|
|
#define SINK(t, sink, ...) if (config->getBackend().equals(t)) return new sink(__VA_ARGS__)
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Review URL: https://codereview.chromium.org/1490113005
2015-12-22 07:48:13 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
if (FLAGS_cpu) {
|
2018-01-09 16:21:58 +00:00
|
|
|
SINK("g8", RasterSink, kGray_8_SkColorType);
|
2017-03-02 13:53:46 +00:00
|
|
|
SINK("565", RasterSink, kRGB_565_SkColorType);
|
2018-01-24 18:42:05 +00:00
|
|
|
SINK("4444", RasterSink, kARGB_4444_SkColorType);
|
2017-03-02 13:53:46 +00:00
|
|
|
SINK("8888", RasterSink, kN32_SkColorType);
|
2018-01-25 14:09:32 +00:00
|
|
|
SINK("rgba", RasterSink, kRGBA_8888_SkColorType);
|
|
|
|
SINK("bgra", RasterSink, kBGRA_8888_SkColorType);
|
|
|
|
SINK("rgbx", RasterSink, kRGB_888x_SkColorType);
|
|
|
|
SINK("1010102", RasterSink, kRGBA_1010102_SkColorType);
|
|
|
|
SINK("101010x", RasterSink, kRGB_101010x_SkColorType);
|
2017-07-20 19:36:00 +00:00
|
|
|
SINK("pdf", PDFSink, false, SK_ScalarDefaultRasterDPI);
|
2017-03-02 13:53:46 +00:00
|
|
|
SINK("skp", SKPSink);
|
|
|
|
SINK("svg", SVGSink);
|
|
|
|
SINK("null", NullSink);
|
|
|
|
SINK("xps", XPSSink);
|
2017-07-20 19:36:00 +00:00
|
|
|
SINK("pdfa", PDFSink, true, SK_ScalarDefaultRasterDPI);
|
|
|
|
SINK("pdf300", PDFSink, false, 300);
|
2016-10-25 14:33:27 +00:00
|
|
|
SINK("jsdebug", DebugSink);
|
2018-06-19 20:00:40 +00:00
|
|
|
|
|
|
|
// Configs relevant to color management testing (and 8888 for reference).
|
|
|
|
|
|
|
|
// 'narrow' has a gamut narrower than sRGB, and different transfer function.
|
2019-01-04 22:03:00 +00:00
|
|
|
auto narrow = SkColorSpace::MakeRGB(SkNamedTransferFn::k2Dot2, gNarrow_toXYZD50),
|
2018-06-19 20:00:40 +00:00
|
|
|
srgb = SkColorSpace::MakeSRGB(),
|
2018-08-16 13:09:14 +00:00
|
|
|
srgbLinear = SkColorSpace::MakeSRGBLinear(),
|
2019-01-04 22:03:00 +00:00
|
|
|
p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
|
2018-08-17 20:19:24 +00:00
|
|
|
|
|
|
|
SINK( "f16", RasterSink, kRGBA_F16_SkColorType, srgbLinear);
|
|
|
|
SINK( "srgb", RasterSink, kRGBA_8888_SkColorType, srgb );
|
|
|
|
SINK( "esrgb", RasterSink, kRGBA_F16_SkColorType, srgb );
|
2019-02-19 11:14:39 +00:00
|
|
|
SINK( "esgbr", RasterSink, kRGBA_F16_SkColorType, rgb_to_gbr());
|
2018-08-17 20:19:24 +00:00
|
|
|
SINK( "narrow", RasterSink, kRGBA_8888_SkColorType, narrow );
|
|
|
|
SINK( "enarrow", RasterSink, kRGBA_F16_SkColorType, narrow );
|
|
|
|
SINK( "p3", RasterSink, kRGBA_8888_SkColorType, p3 );
|
|
|
|
SINK( "ep3", RasterSink, kRGBA_F16_SkColorType, p3 );
|
2018-09-13 15:13:15 +00:00
|
|
|
SINK( "rec2020", RasterSink, kRGBA_8888_SkColorType, rec2020() );
|
|
|
|
SINK("erec2020", RasterSink, kRGBA_F16_SkColorType, rec2020() );
|
2018-06-26 15:43:06 +00:00
|
|
|
|
2019-02-28 16:03:27 +00:00
|
|
|
SINK("f16norm", RasterSink, kRGBA_F16Norm_SkColorType, srgb);
|
|
|
|
|
2018-06-26 15:43:06 +00:00
|
|
|
SINK( "f32", RasterSink, kRGBA_F32_SkColorType, srgbLinear);
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
#undef SINK
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
static Sink* create_via(const SkString& tag, Sink* wrapped) {
|
2018-11-30 20:33:19 +00:00
|
|
|
#define VIA(t, via, ...) if (tag.equals(t)) return new via(__VA_ARGS__)
|
SkLite*
SkLiteRecorder, a new SkCanvas, fills out SkLiteDL, a new SkDrawable.
This SkDrawable is a display list similar to SkRecord and SkBigPicture / SkRecordedDrawable, but with a few new design points inspired by Android and slimming paint:
1) SkLiteDL is structured as one big contiguous array rather than the two layer structure of SkRecord. This trades away flexibility and large-op-count performance for better data locality for small to medium size pictures.
2) We keep a global freelist of SkLiteDLs, both reusing the SkLiteDL struct itself and its contiguous byte array. This keeps the expected number of mallocs per display list allocation <1 (really, ~0) for cyclical use cases.
These two together mean recording is faster. Measuring against the code we use at head, SkLiteRecorder trends about ~3x faster across various size pictures, matching speed at 0 draws and beating the special-case 1-draw pictures we have today. (I.e. we won't need those special case implementations anymore, because they're slower than this new generic code.) This new strategy records 10 drawRects() in about the same time the old strategy took for 2.
This strategy stays the winner until at least 500 drawRect()s on my laptop, where I stopped checking.
A simpler alternative to freelisting is also possible (but not implemented here), where we allow the client to manually reset() an SkLiteDL for reuse when its refcnt is 1. That's essentially what we're doing with the freelist, except tracking what's available for reuse globally instead of making the client do it.
This code is not fully capable yet, but most of the key design points are there. The internal structure of SkLiteDL is the area I expect to be most volatile (anything involving Op), but its interface and the whole of SkLiteRecorder ought to be just about done.
You can run nanobench --match picture_overhead as a demo. Everything it exercises is fully fleshed out, so what it tests is an apples-to-apples comparison as far as recording costs go. I have not yet compared playback performance.
It should be simple to wrap this into an SkPicture subclass if we want.
I won't start proposing we replace anything old with anything new quite yet until I have more ducks in a row, but this does look pretty promising (similar to the SkRecord over old SkPicture change a couple years ago) and I'd like to land, experiment, iterate, especially with an eye toward Android.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2213333002
Review-Url: https://codereview.chromium.org/2213333002
2016-08-06 19:51:51 +00:00
|
|
|
VIA("lite", ViaLite, wrapped);
|
2017-02-18 21:50:45 +00:00
|
|
|
#ifdef TEST_VIA_SVG
|
2017-02-17 22:06:11 +00:00
|
|
|
VIA("svg", ViaSVG, wrapped);
|
2017-02-18 21:50:45 +00:00
|
|
|
#endif
|
2015-08-27 14:41:13 +00:00
|
|
|
VIA("serialize", ViaSerialization, wrapped);
|
2016-01-08 18:19:35 +00:00
|
|
|
VIA("pic", ViaPicture, wrapped);
|
2015-08-27 14:41:13 +00:00
|
|
|
VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped);
|
2015-01-21 21:18:51 +00:00
|
|
|
VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2018-12-17 19:45:00 +00:00
|
|
|
VIA("ddl", ViaDDL, 1, 3, wrapped);
|
|
|
|
VIA("ddl2", ViaDDL, 2, 3, wrapped);
|
2018-03-27 12:06:57 +00:00
|
|
|
|
2015-02-17 19:13:33 +00:00
|
|
|
if (FLAGS_matrix.count() == 4) {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkMatrix m;
|
2015-02-17 19:13:33 +00:00
|
|
|
m.reset();
|
|
|
|
m.setScaleX((SkScalar)atof(FLAGS_matrix[0]));
|
|
|
|
m.setSkewX ((SkScalar)atof(FLAGS_matrix[1]));
|
|
|
|
m.setSkewY ((SkScalar)atof(FLAGS_matrix[2]));
|
|
|
|
m.setScaleY((SkScalar)atof(FLAGS_matrix[3]));
|
|
|
|
VIA("matrix", ViaMatrix, m, wrapped);
|
|
|
|
VIA("upright", ViaUpright, m, wrapped);
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2015-03-05 16:01:07 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
#undef VIA
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-07-28 14:21:24 +00:00
|
|
|
}
|
2014-05-14 17:55:32 +00:00
|
|
|
|
2017-08-11 21:33:22 +00:00
|
|
|
static bool gather_sinks(const GrContextOptions& grCtxOptions, bool defaultConfigs) {
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
SkCommandLineConfigArray configs;
|
|
|
|
ParseConfigs(FLAGS_config, &configs);
|
|
|
|
for (int i = 0; i < configs.count(); i++) {
|
|
|
|
const SkCommandLineConfig& config = *configs[i];
|
2017-02-22 19:00:42 +00:00
|
|
|
Sink* sink = create_sink(grCtxOptions, &config);
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
if (sink == nullptr) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
|
|
|
|
config.getTag().c_str());
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkTArray<SkString>& parts = config.getViaParts();
|
|
|
|
for (int j = parts.count(); j-- > 0;) {
|
|
|
|
const SkString& part = parts[j];
|
|
|
|
Sink* next = create_via(part, sink);
|
2015-08-27 14:41:13 +00:00
|
|
|
if (next == nullptr) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
|
|
|
|
part.c_str());
|
2015-01-15 18:56:12 +00:00
|
|
|
delete sink;
|
2015-08-27 14:41:13 +00:00
|
|
|
sink = nullptr;
|
2015-01-15 18:56:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sink = next;
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
if (sink) {
|
|
|
|
push_sink(config, sink);
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2014-05-14 17:55:32 +00:00
|
|
|
}
|
2016-05-09 20:42:16 +00:00
|
|
|
|
|
|
|
// If no configs were requested (just running tests, perhaps?), then we're okay.
|
2017-08-11 21:33:22 +00:00
|
|
|
if (configs.count() == 0 ||
|
|
|
|
// If we're using the default configs, we're okay.
|
|
|
|
defaultConfigs ||
|
2017-08-11 01:25:55 +00:00
|
|
|
// Otherwise, make sure that all specified configs have become sinks.
|
|
|
|
configs.count() == gSinks.count()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2014-05-14 17:55:32 +00:00
|
|
|
|
2015-01-15 21:44:22 +00:00
|
|
|
static bool match(const char* needle, const char* haystack) {
|
2017-08-15 21:43:08 +00:00
|
|
|
if ('~' == needle[0]) {
|
|
|
|
return !match(needle + 1, haystack);
|
|
|
|
}
|
|
|
|
if (0 == strcmp("_", needle)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return nullptr != strstr(haystack, needle);
|
2015-01-15 21:44:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 03:07:07 +00:00
|
|
|
static bool is_blacklisted(const char* sink, const char* src,
|
|
|
|
const char* srcOptions, const char* name) {
|
2015-04-03 14:51:00 +00:00
|
|
|
for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) {
|
2015-01-15 21:44:22 +00:00
|
|
|
if (match(FLAGS_blacklist[i+0], sink) &&
|
2015-04-03 14:24:48 +00:00
|
|
|
match(FLAGS_blacklist[i+1], src) &&
|
|
|
|
match(FLAGS_blacklist[i+2], srcOptions) &&
|
|
|
|
match(FLAGS_blacklist[i+3], name)) {
|
2016-02-25 03:07:07 +00:00
|
|
|
return true;
|
2015-01-15 21:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-25 03:07:07 +00:00
|
|
|
return false;
|
2015-01-15 21:44:22 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 14:20:20 +00:00
|
|
|
// Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
|
|
|
|
// .png encoding are definitely thread safe. This lets us offload that work to CPU threads.
|
|
|
|
static SkTaskGroup gDefinitelyThreadSafeWork;
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
// The finest-grained unit of work we can run: draw a single Src into a single Sink,
|
|
|
|
// report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream.
|
|
|
|
struct Task {
|
2015-07-29 13:37:28 +00:00
|
|
|
Task(const TaggedSrc& src, const TaggedSink& sink) : src(src), sink(sink) {}
|
|
|
|
const TaggedSrc& src;
|
|
|
|
const TaggedSink& sink;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2016-02-08 20:39:59 +00:00
|
|
|
static void Run(const Task& task) {
|
|
|
|
SkString name = task.src->name();
|
2015-07-29 13:37:28 +00:00
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
SkString log;
|
2016-02-25 03:07:07 +00:00
|
|
|
if (!FLAGS_dryRun) {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkBitmap bitmap;
|
|
|
|
SkDynamicMemoryWStream stream;
|
2016-02-25 03:07:07 +00:00
|
|
|
start(task.sink.tag.c_str(), task.src.tag.c_str(),
|
|
|
|
task.src.options.c_str(), name.c_str());
|
2016-02-08 20:39:59 +00:00
|
|
|
Error err = task.sink->draw(*task.src, &bitmap, &stream, &log);
|
2016-03-07 21:20:52 +00:00
|
|
|
if (!log.isEmpty()) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("%s %s %s %s:\n%s\n", task.sink.tag.c_str()
|
|
|
|
, task.src.tag.c_str()
|
|
|
|
, task.src.options.c_str()
|
|
|
|
, name.c_str()
|
|
|
|
, log.c_str());
|
2016-03-07 21:20:52 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
if (!err.isEmpty()) {
|
2015-03-05 16:40:28 +00:00
|
|
|
if (err.isFatal()) {
|
2015-04-03 14:24:48 +00:00
|
|
|
fail(SkStringPrintf("%s %s %s %s: %s",
|
2016-02-08 20:39:59 +00:00
|
|
|
task.sink.tag.c_str(),
|
|
|
|
task.src.tag.c_str(),
|
|
|
|
task.src.options.c_str(),
|
2015-03-05 16:40:28 +00:00
|
|
|
name.c_str(),
|
|
|
|
err.c_str()));
|
2015-03-18 12:27:14 +00:00
|
|
|
} else {
|
2016-02-25 03:07:07 +00:00
|
|
|
done(task.sink.tag.c_str(), task.src.tag.c_str(),
|
|
|
|
task.src.options.c_str(), name.c_str());
|
2016-01-21 17:39:35 +00:00
|
|
|
return;
|
2015-03-05 16:40:28 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
2016-01-05 14:20:20 +00:00
|
|
|
|
|
|
|
// We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
|
2017-03-14 18:35:02 +00:00
|
|
|
SkStreamAsset* data = stream.detachAsStream().release();
|
2016-01-05 14:20:20 +00:00
|
|
|
gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<SkStreamAsset> ownedData(data);
|
2016-01-05 14:20:20 +00:00
|
|
|
|
2019-03-07 17:46:59 +00:00
|
|
|
std::unique_ptr<HashAndEncode> hashAndEncode;
|
|
|
|
|
2016-01-05 14:20:20 +00:00
|
|
|
SkString md5;
|
2019-01-25 18:02:59 +00:00
|
|
|
if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
|
2016-01-05 14:20:20 +00:00
|
|
|
SkMD5 hash;
|
|
|
|
if (data->getLength()) {
|
|
|
|
hash.writeStream(data, data->getLength());
|
|
|
|
data->rewind();
|
DM: swizzle BGRA to RGBA before calculating pixel MD5.
We name our .pngs by pixel hashes for gold. For 8888 images, we're hashing
SkPMColors, which have platform-dependent order: BGRA on Linux and Windows,
RGBA otherwise. This means we can end up with pixel-identical pngs with
different hashes, which is confusing.
This CL standardizes on RGBA for 8888 configs, arbitrarily chosen so that
Android ends up a no-op. Long-term, this should eliminate most of the
0-pixel-diff problems we see on gold.skia.org. There are other ways to end up
with the same .png from different SkBitmaps (think, red 565 square vs. red 8888
square) but they're rather less common / likely.
This will temporarily create a giant 0-pixel-diff problem on gold.skia.org.
Any Linux or Windows images which are not already pixel-identical to a Mac or
Android image should show up as untriaged hashes that are pixel-identical to
their version just before landing (we're only changing the hash, not the .png).
This means anything vaguely platform dependent (fonts, GPUs) will probably show
up as needing a triage but with a zero diff from a previous image.
If this goes well, we might do the same for 565. Just want to leave them out
for now to cut down on the triaging I need to do in one go.
BUG=skia:
Review URL: https://codereview.chromium.org/1226933005
2015-07-08 14:25:27 +00:00
|
|
|
} else {
|
2019-03-07 17:46:59 +00:00
|
|
|
hashAndEncode.reset(new HashAndEncode(bitmap));
|
|
|
|
hashAndEncode->write(&hash);
|
2016-01-05 14:20:20 +00:00
|
|
|
}
|
2019-04-03 14:13:45 +00:00
|
|
|
SkMD5::Digest digest = hash.finish();
|
2016-01-05 14:20:20 +00:00
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
md5.appendf("%02x", digest.data[i]);
|
DM: swizzle BGRA to RGBA before calculating pixel MD5.
We name our .pngs by pixel hashes for gold. For 8888 images, we're hashing
SkPMColors, which have platform-dependent order: BGRA on Linux and Windows,
RGBA otherwise. This means we can end up with pixel-identical pngs with
different hashes, which is confusing.
This CL standardizes on RGBA for 8888 configs, arbitrarily chosen so that
Android ends up a no-op. Long-term, this should eliminate most of the
0-pixel-diff problems we see on gold.skia.org. There are other ways to end up
with the same .png from different SkBitmaps (think, red 565 square vs. red 8888
square) but they're rather less common / likely.
This will temporarily create a giant 0-pixel-diff problem on gold.skia.org.
Any Linux or Windows images which are not already pixel-identical to a Mac or
Android image should show up as untriaged hashes that are pixel-identical to
their version just before landing (we're only changing the hash, not the .png).
This means anything vaguely platform dependent (fonts, GPUs) will probably show
up as needing a triage but with a zero diff from a previous image.
If this goes well, we might do the same for 565. Just want to leave them out
for now to cut down on the triaging I need to do in one go.
BUG=skia:
Review URL: https://codereview.chromium.org/1226933005
2015-07-08 14:25:27 +00:00
|
|
|
}
|
2015-01-27 22:46:26 +00:00
|
|
|
}
|
|
|
|
|
2019-01-25 18:02:59 +00:00
|
|
|
if (!FLAGS_readPath.isEmpty() &&
|
|
|
|
!gGold.contains(Gold(task.sink.tag, task.src.tag,
|
|
|
|
task.src.options, name, md5))) {
|
|
|
|
fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
|
|
|
|
md5.c_str(),
|
|
|
|
task.sink.tag.c_str(),
|
|
|
|
task.src.tag.c_str(),
|
|
|
|
task.src.options.c_str(),
|
|
|
|
name.c_str(),
|
|
|
|
FLAGS_readPath[0]));
|
|
|
|
}
|
|
|
|
|
2016-01-05 14:20:20 +00:00
|
|
|
if (!FLAGS_writePath.isEmpty()) {
|
2016-02-08 20:39:59 +00:00
|
|
|
const char* ext = task.sink->fileExtension();
|
2017-08-30 18:50:22 +00:00
|
|
|
if (ext && !FLAGS_dont_write.contains(ext)) {
|
2017-07-24 14:37:19 +00:00
|
|
|
if (data->getLength()) {
|
2019-03-07 17:46:59 +00:00
|
|
|
WriteToDisk(task, md5, ext, data, data->getLength(), nullptr, nullptr);
|
2017-07-24 14:37:19 +00:00
|
|
|
SkASSERT(bitmap.drawsNothing());
|
|
|
|
} else if (!bitmap.drawsNothing()) {
|
2019-03-07 17:46:59 +00:00
|
|
|
WriteToDisk(task, md5, ext, nullptr, 0, &bitmap, hashAndEncode.get());
|
2017-07-24 14:37:19 +00:00
|
|
|
}
|
2016-01-05 14:20:20 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
2019-03-11 15:20:55 +00:00
|
|
|
|
|
|
|
SkPixmap pm;
|
|
|
|
if (FLAGS_checkF16 && bitmap.colorType() == kRGBA_F16Norm_SkColorType &&
|
|
|
|
bitmap.peekPixels(&pm)) {
|
|
|
|
bool unclamped = false;
|
|
|
|
for (int y = 0; y < pm.height() && !unclamped; ++y)
|
|
|
|
for (int x = 0; x < pm.width() && !unclamped; ++x) {
|
|
|
|
Sk4f rgba = SkHalfToFloat_finite_ftz(*pm.addr64(x, y));
|
|
|
|
float a = rgba[3];
|
|
|
|
if (a > 1.0f || (rgba < 0.0f).anyTrue() || (rgba > a).anyTrue()) {
|
2019-03-15 14:02:16 +00:00
|
|
|
SkDebugf("[%s] F16Norm pixel [%d, %d] unclamped: (%g, %g, %g, %g)\n",
|
|
|
|
name.c_str(), x, y, rgba[0], rgba[1], rgba[2], rgba[3]);
|
2019-03-11 15:20:55 +00:00
|
|
|
unclamped = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 14:20:20 +00:00
|
|
|
});
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2016-02-25 03:07:07 +00:00
|
|
|
done(task.sink.tag.c_str(), task.src.tag.c_str(), task.src.options.c_str(), name.c_str());
|
2014-12-13 00:41:12 +00:00
|
|
|
}
|
|
|
|
|
2019-02-12 18:03:54 +00:00
|
|
|
static SkString identify_gamut(SkColorSpace* cs) {
|
|
|
|
if (!cs) {
|
|
|
|
return SkString("untagged");
|
|
|
|
}
|
|
|
|
|
|
|
|
skcms_Matrix3x3 gamut;
|
|
|
|
if (cs->toXYZD50(&gamut)) {
|
|
|
|
auto eq = [](skcms_Matrix3x3 x, skcms_Matrix3x3 y) {
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
if (x.vals[i][j] != y.vals[i][j]) { return false; }
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (eq(gamut, SkNamedGamut::kSRGB )) { return SkString("sRGB"); }
|
|
|
|
if (eq(gamut, SkNamedGamut::kAdobeRGB)) { return SkString("Adobe"); }
|
|
|
|
if (eq(gamut, SkNamedGamut::kDCIP3 )) { return SkString("P3"); }
|
|
|
|
if (eq(gamut, SkNamedGamut::kRec2020 )) { return SkString("2020"); }
|
|
|
|
if (eq(gamut, SkNamedGamut::kXYZ )) { return SkString("XYZ"); }
|
|
|
|
if (eq(gamut, gNarrow_toXYZD50 )) { return SkString("narrow"); }
|
|
|
|
return SkString("other");
|
|
|
|
}
|
|
|
|
return SkString("non-XYZ");
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkString identify_transfer_fn(SkColorSpace* cs) {
|
|
|
|
if (!cs) {
|
|
|
|
return SkString("untagged");
|
|
|
|
}
|
|
|
|
|
|
|
|
skcms_TransferFunction tf;
|
|
|
|
if (cs->isNumericalTransferFn(&tf)) {
|
|
|
|
auto eq = [](skcms_TransferFunction x, skcms_TransferFunction y) {
|
|
|
|
return x.g == y.g
|
|
|
|
&& x.a == y.a
|
|
|
|
&& x.b == y.b
|
|
|
|
&& x.c == y.c
|
|
|
|
&& x.d == y.d
|
|
|
|
&& x.e == y.e
|
|
|
|
&& x.f == y.f;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (tf.a == 1 && tf.b == 0 && tf.c == 0 && tf.d == 0 && tf.e == 0 && tf.f == 0) {
|
|
|
|
return SkStringPrintf("gamma %.3g", tf.g);
|
|
|
|
}
|
|
|
|
if (eq(tf, SkNamedTransferFn::kSRGB)) { return SkString("sRGB"); }
|
|
|
|
if (eq(tf, k2020_TF )) { return SkString("2020"); }
|
|
|
|
return SkStringPrintf("%.3g %.3g %.3g %.3g %.3g %.3g %.3g",
|
|
|
|
tf.g, tf.a, tf.b, tf.c, tf.d, tf.e, tf.f);
|
|
|
|
}
|
|
|
|
return SkString("non-numeric");
|
|
|
|
}
|
|
|
|
|
2019-03-07 20:11:16 +00:00
|
|
|
// Equivalence class to slice color type by in Gold.
|
|
|
|
// Basically the same as color type ignoring channel order.
|
|
|
|
static const char* color_depth(SkColorType ct) {
|
|
|
|
switch (ct) {
|
|
|
|
case kUnknown_SkColorType: break;
|
|
|
|
|
|
|
|
case kAlpha_8_SkColorType: return "A8";
|
|
|
|
case kRGB_565_SkColorType: return "565";
|
|
|
|
case kARGB_4444_SkColorType: return "4444";
|
|
|
|
case kRGBA_8888_SkColorType: return "8888";
|
|
|
|
case kRGB_888x_SkColorType: return "888";
|
|
|
|
case kBGRA_8888_SkColorType: return "8888";
|
|
|
|
case kRGBA_1010102_SkColorType: return "1010102";
|
|
|
|
case kRGB_101010x_SkColorType: return "101010";
|
|
|
|
case kGray_8_SkColorType: return "G8";
|
|
|
|
case kRGBA_F16Norm_SkColorType: return "F16Norm"; // TODO: "F16"?
|
|
|
|
case kRGBA_F16_SkColorType: return "F16";
|
|
|
|
case kRGBA_F32_SkColorType: return "F32";
|
|
|
|
}
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
static void WriteToDisk(const Task& task,
|
2015-01-27 22:46:26 +00:00
|
|
|
SkString md5,
|
|
|
|
const char* ext,
|
2015-01-15 18:56:12 +00:00
|
|
|
SkStream* data, size_t len,
|
2019-03-07 17:46:59 +00:00
|
|
|
const SkBitmap* bitmap,
|
|
|
|
const HashAndEncode* hashAndEncode) {
|
Add gamma_correct option field to dm.json
E.g.
{
"max_rss_MB" : 23,
"results" : [
{
"key" : {
"config" : "pdf",
"name" : "gamma",
"source_type" : "gm"
},
"md5" : "c5dfb531f4d76c77c3305b6a04733262",
"options" : {
"ext" : "pdf",
"gamma_correct" : false
}
},
{
"key" : {
"config" : "8888",
"name" : "gamma",
"source_type" : "gm"
},
"md5" : "6177860ed24106446d3a9087527e67bf",
"options" : {
"ext" : "png",
"gamma_correct" : false
}
},
{
"key" : {
"config" : "f16",
"name" : "gamma",
"source_type" : "gm"
},
"md5" : "213f80145953ecd4c71e0612447b2ad9",
"options" : {
"ext" : "png",
"gamma_correct" : true
}
}
]
}
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1741973002
Review URL: https://codereview.chromium.org/1741973002
2016-02-29 15:38:01 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
JsonWriter::BitmapResult result;
|
2015-04-03 14:24:48 +00:00
|
|
|
result.name = task.src->name();
|
2016-02-25 03:07:07 +00:00
|
|
|
result.config = task.sink.tag;
|
2015-04-03 14:24:48 +00:00
|
|
|
result.sourceType = task.src.tag;
|
|
|
|
result.sourceOptions = task.src.options;
|
|
|
|
result.ext = ext;
|
|
|
|
result.md5 = md5;
|
2019-03-06 15:57:49 +00:00
|
|
|
if (bitmap) {
|
|
|
|
result.gamut = identify_gamut (bitmap->colorSpace());
|
|
|
|
result.transferFn = identify_transfer_fn (bitmap->colorSpace());
|
2019-03-20 16:12:10 +00:00
|
|
|
result.colorType = ToolUtils::colortype_name(bitmap->colorType());
|
|
|
|
result.alphaType = ToolUtils::alphatype_name(bitmap->alphaType());
|
2019-03-07 20:11:16 +00:00
|
|
|
result.colorDepth = color_depth (bitmap->colorType());
|
2019-03-06 15:57:49 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
JsonWriter::AddBitmapResult(result);
|
2015-01-15 16:30:25 +00:00
|
|
|
|
2015-04-07 20:38:48 +00:00
|
|
|
// If an MD5 is uninteresting, we want it noted in the JSON file,
|
|
|
|
// but don't want to dump it out as a .png (or whatever ext is).
|
|
|
|
if (gUninterestingHashes.contains(md5)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
const char* dir = FLAGS_writePath[0];
|
2019-03-25 15:54:59 +00:00
|
|
|
SkString resources = GetResourcePath();
|
2015-01-15 18:56:12 +00:00
|
|
|
if (0 == strcmp(dir, "@")) { // Needed for iOS.
|
2019-03-25 15:54:59 +00:00
|
|
|
dir = resources.c_str();
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
sk_mkdir(dir);
|
|
|
|
|
|
|
|
SkString path;
|
|
|
|
if (FLAGS_nameByHash) {
|
|
|
|
path = SkOSPath::Join(dir, result.md5.c_str());
|
|
|
|
path.append(".");
|
|
|
|
path.append(ext);
|
|
|
|
if (sk_exists(path.c_str())) {
|
|
|
|
return; // Content-addressed. If it exists already, we're done.
|
|
|
|
}
|
|
|
|
} else {
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
path = SkOSPath::Join(dir, task.sink.tag.c_str());
|
2015-01-15 18:56:12 +00:00
|
|
|
sk_mkdir(path.c_str());
|
2015-09-01 21:57:57 +00:00
|
|
|
path = SkOSPath::Join(path.c_str(), task.src.tag.c_str());
|
2015-01-15 18:56:12 +00:00
|
|
|
sk_mkdir(path.c_str());
|
2015-09-01 21:57:57 +00:00
|
|
|
if (strcmp(task.src.options.c_str(), "") != 0) {
|
|
|
|
path = SkOSPath::Join(path.c_str(), task.src.options.c_str());
|
2015-04-03 14:24:48 +00:00
|
|
|
sk_mkdir(path.c_str());
|
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
|
|
|
|
path.append(".");
|
|
|
|
path.append(ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bitmap) {
|
2019-03-07 17:46:59 +00:00
|
|
|
SkASSERT(hashAndEncode);
|
FM, a dumber new testing tool
FM's a bit like DM, and a bit like the old GM tool, maybe closer to GM.
FM always does one serial run through of a list of GM, image, or .skp
sources (-s/--sources) into one drawing configuration, set at a high
level with -b/--backend, fine-tuned by flags like --ct, --at, --gamut,
--samples, etc.
FM prints all available GMs when run with no arguments, part of
how it integrates well with external parallelization like xargs:
out/fm | time xargs -n4 -P32 out/fm -b cpu ... -s
out/fm | time xargs -n32 -P8 out/fm -b gl ... -s
ls *.skp | xargs ... out/fm ... -s
...
TODO later:
vector backends: --backend pdf, svg, xps, skp
--source *.svg, *.json (Skottie)
Create/update a dm.json file
Change-Id: Idacbd2785deaf6f1d33674c66c4d984fa91dbd85
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203520
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-25 17:57:58 +00:00
|
|
|
if (!hashAndEncode->writePngTo(path.c_str(),
|
|
|
|
result.md5.c_str(),
|
|
|
|
FLAGS_key,
|
|
|
|
FLAGS_properties)) {
|
2015-01-15 18:56:12 +00:00
|
|
|
fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2015-08-24 20:27:01 +00:00
|
|
|
SkFILEWStream file(path.c_str());
|
|
|
|
if (!file.isValid()) {
|
|
|
|
fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
if (!file.writeStream(data, len)) {
|
|
|
|
fail(SkStringPrintf("Can't write to %s.\n", path.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
|
|
|
// Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
|
|
|
|
|
2016-02-08 20:39:59 +00:00
|
|
|
static SkTDArray<skiatest::Test> gParallelTests, gSerialTests;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
static void gather_tests() {
|
2015-01-20 21:47:23 +00:00
|
|
|
if (!FLAGS_src.contains("tests")) {
|
2015-01-15 18:56:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-07-30 21:07:07 +00:00
|
|
|
for (const skiatest::Test& test : skiatest::TestRegistry::Range()) {
|
2015-04-27 15:45:01 +00:00
|
|
|
if (!in_shard()) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-20 15:50:33 +00:00
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
|
2015-01-15 18:56:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
2018-05-31 18:27:17 +00:00
|
|
|
if (test.needsGpu && FLAGS_gpu) {
|
2018-08-08 15:23:41 +00:00
|
|
|
(FLAGS_gpu_threading ? gParallelTests : gSerialTests).push_back(test);
|
2015-01-20 17:30:20 +00:00
|
|
|
} else if (!test.needsGpu && FLAGS_cpu) {
|
2018-08-08 15:23:41 +00:00
|
|
|
gParallelTests.push_back(test);
|
2015-01-15 20:46:02 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
2014-06-30 13:36:31 +00:00
|
|
|
}
|
|
|
|
|
2017-02-22 19:00:42 +00:00
|
|
|
static void run_test(skiatest::Test test, const GrContextOptions& grCtxOptions) {
|
2015-01-20 17:30:20 +00:00
|
|
|
struct : public skiatest::Reporter {
|
2015-03-26 01:17:31 +00:00
|
|
|
void reportFailed(const skiatest::Failure& failure) override {
|
2015-01-20 17:30:20 +00:00
|
|
|
fail(failure.toString());
|
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
bool allowExtendedTest() const override {
|
2015-01-20 17:30:20 +00:00
|
|
|
return FLAGS_pathOpsExtended;
|
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
bool verbose() const override { return FLAGS_veryVerbose; }
|
2015-01-20 17:30:20 +00:00
|
|
|
} reporter;
|
2015-06-12 19:06:22 +00:00
|
|
|
|
2016-02-25 03:07:07 +00:00
|
|
|
if (!FLAGS_dryRun && !is_blacklisted("_", "tests", "_", test.name)) {
|
2017-10-30 18:02:48 +00:00
|
|
|
GrContextOptions options = grCtxOptions;
|
|
|
|
test.modifyGrContextOptions(&options);
|
|
|
|
|
2019-03-13 14:13:46 +00:00
|
|
|
skiatest::ReporterContext ctx(&reporter, SkString(test.name));
|
2016-02-08 20:39:59 +00:00
|
|
|
start("unit", "test", "", test.name);
|
2017-11-15 20:48:03 +00:00
|
|
|
test.run(&reporter, options);
|
2014-02-26 23:01:57 +00:00
|
|
|
}
|
2016-02-25 03:07:07 +00:00
|
|
|
done("unit", "test", "", test.name);
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2014-02-26 23:01:57 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2017-02-06 17:46:20 +00:00
|
|
|
int main(int argc, char** argv) {
|
2018-02-16 18:55:21 +00:00
|
|
|
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_HAS_HEIF_LIBRARY)
|
|
|
|
android::ProcessState::self()->startThreadPool();
|
|
|
|
#endif
|
2019-03-20 15:50:33 +00:00
|
|
|
CommandLineFlags::Parse(argc, argv);
|
2017-07-20 19:43:35 +00:00
|
|
|
|
2017-07-24 15:38:01 +00:00
|
|
|
initializeEventTracingForTools();
|
2017-07-20 19:43:35 +00:00
|
|
|
|
2017-12-19 14:09:33 +00:00
|
|
|
#if !defined(SK_BUILD_FOR_GOOGLE3) && defined(SK_BUILD_FOR_IOS)
|
2017-02-06 14:26:14 +00:00
|
|
|
cd_Documents();
|
|
|
|
#endif
|
2016-04-26 21:27:21 +00:00
|
|
|
setbuf(stdout, nullptr);
|
2016-02-23 18:39:36 +00:00
|
|
|
setup_crash_handler();
|
2016-02-24 20:28:32 +00:00
|
|
|
|
2019-03-22 20:30:07 +00:00
|
|
|
ToolUtils::SetDefaultFontMgr();
|
2019-03-22 16:39:09 +00:00
|
|
|
SetAnalyticAAFromCommonFlags();
|
2016-10-04 18:23:22 +00:00
|
|
|
|
2017-07-05 19:45:52 +00:00
|
|
|
if (FLAGS_forceRasterPipeline) {
|
|
|
|
gSkForceRasterPipelineBlitter = true;
|
|
|
|
}
|
2017-01-13 15:13:13 +00:00
|
|
|
|
2017-06-26 17:23:12 +00:00
|
|
|
// The bots like having a verbose.log to upload, so always touch the file even if --verbose.
|
|
|
|
if (!FLAGS_writePath.isEmpty()) {
|
2016-03-11 20:59:09 +00:00
|
|
|
sk_mkdir(FLAGS_writePath[0]);
|
2016-07-22 19:23:46 +00:00
|
|
|
gVLog = fopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(), "w");
|
2016-03-08 17:01:39 +00:00
|
|
|
}
|
2017-06-26 17:23:12 +00:00
|
|
|
if (FLAGS_verbose) {
|
|
|
|
gVLog = stderr;
|
|
|
|
}
|
2016-03-08 17:01:39 +00:00
|
|
|
|
2017-02-22 19:00:42 +00:00
|
|
|
GrContextOptions grCtxOptions;
|
2017-12-18 21:22:34 +00:00
|
|
|
SetCtxOptionsFromCommonFlags(&grCtxOptions);
|
2017-02-22 19:00:42 +00:00
|
|
|
|
2019-03-25 15:54:59 +00:00
|
|
|
dump_json(); // It's handy for the bots to assume this is ~never missing.
|
|
|
|
|
2015-01-15 18:15:02 +00:00
|
|
|
SkAutoGraphics ag;
|
|
|
|
SkTaskGroup::Enabler enabled(FLAGS_threads);
|
2015-01-15 16:30:25 +00:00
|
|
|
|
2017-12-09 01:27:41 +00:00
|
|
|
if (nullptr == GetResourceAsData("images/color_wheel.png")) {
|
|
|
|
info("Some resources are missing. Do you need to set --resourcePath?\n");
|
2016-02-25 01:59:16 +00:00
|
|
|
}
|
2019-01-25 18:02:59 +00:00
|
|
|
gather_gold();
|
2015-04-03 21:15:33 +00:00
|
|
|
gather_uninteresting_hashes();
|
2015-01-27 22:46:26 +00:00
|
|
|
|
2016-02-03 20:19:11 +00:00
|
|
|
if (!gather_srcs()) {
|
|
|
|
return 1;
|
|
|
|
}
|
2017-08-11 21:33:22 +00:00
|
|
|
// TODO(dogben): This is a bit ugly. Find a cleaner way to do this.
|
|
|
|
bool defaultConfigs = true;
|
|
|
|
for (int i = 0; i < argc; i++) {
|
|
|
|
static const char* kConfigArg = "--config";
|
|
|
|
if (strcmp(argv[i], kConfigArg) == 0) {
|
|
|
|
defaultConfigs = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!gather_sinks(grCtxOptions, defaultConfigs)) {
|
2016-05-09 20:42:16 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
gather_tests();
|
2016-02-08 20:39:59 +00:00
|
|
|
gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerialTests.count();
|
2017-08-03 16:13:47 +00:00
|
|
|
info("%d srcs * %d sinks + %d tests == %d tasks\n",
|
2016-03-08 17:01:39 +00:00
|
|
|
gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.count(), gPending);
|
2014-02-26 23:01:57 +00:00
|
|
|
|
2016-02-08 20:39:59 +00:00
|
|
|
// Kick off as much parallel work as we can, making note of any serial work we'll need to do.
|
|
|
|
SkTaskGroup parallel;
|
|
|
|
SkTArray<Task> serial;
|
|
|
|
|
|
|
|
for (auto& sink : gSinks)
|
|
|
|
for (auto& src : gSrcs) {
|
2016-02-25 03:07:07 +00:00
|
|
|
if (src->veto(sink->flags()) ||
|
|
|
|
is_blacklisted(sink.tag.c_str(), src.tag.c_str(),
|
|
|
|
src.options.c_str(), src->name().c_str())) {
|
2016-06-10 20:56:35 +00:00
|
|
|
SkAutoMutexAcquire lock(gMutex);
|
2016-02-25 03:07:07 +00:00
|
|
|
gPending--;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-02-08 20:39:59 +00:00
|
|
|
Task task(src, sink);
|
|
|
|
if (src->serial() || sink->serial()) {
|
|
|
|
serial.push_back(task);
|
|
|
|
} else {
|
|
|
|
parallel.add([task] { Task::Run(task); });
|
2015-01-15 20:46:02 +00:00
|
|
|
}
|
2015-01-21 23:50:13 +00:00
|
|
|
}
|
2016-02-08 20:39:59 +00:00
|
|
|
for (auto test : gParallelTests) {
|
2017-02-22 19:00:42 +00:00
|
|
|
parallel.add([test, grCtxOptions] { run_test(test, grCtxOptions); });
|
2016-02-08 20:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// With the parallel work running, run serial tasks and tests here on main thread.
|
|
|
|
for (auto task : serial) { Task::Run(task); }
|
2017-02-22 19:00:42 +00:00
|
|
|
for (auto test : gSerialTests) { run_test(test, grCtxOptions); }
|
2016-02-08 20:39:59 +00:00
|
|
|
|
|
|
|
// Wait for any remaining parallel work to complete (including any spun off of serial tasks).
|
|
|
|
parallel.wait();
|
2016-01-05 14:20:20 +00:00
|
|
|
gDefinitelyThreadSafeWork.wait();
|
|
|
|
|
2018-07-10 23:40:15 +00:00
|
|
|
// At this point we're back in single-threaded land.
|
|
|
|
|
2016-02-25 02:00:23 +00:00
|
|
|
// We'd better have run everything.
|
|
|
|
SkASSERT(gPending == 0);
|
2016-02-26 23:53:06 +00:00
|
|
|
// Make sure we've flushed all our results to disk.
|
2019-03-25 15:54:59 +00:00
|
|
|
dump_json();
|
2016-02-25 02:00:23 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
if (gFailures.count() > 0) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("Failures:\n");
|
2015-01-15 18:56:12 +00:00
|
|
|
for (int i = 0; i < gFailures.count(); i++) {
|
2016-03-08 17:01:39 +00:00
|
|
|
info("\t%s\n", gFailures[i].c_str());
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
2016-03-08 17:01:39 +00:00
|
|
|
info("%d failures\n", gFailures.count());
|
2019-03-20 13:46:09 +00:00
|
|
|
// A non-zero return code does not make it to Swarming
|
|
|
|
// An abort does.
|
|
|
|
#ifdef SK_BUILD_FOR_IOS
|
|
|
|
SK_ABORT("There were failures!");
|
|
|
|
#endif
|
2015-01-15 18:56:12 +00:00
|
|
|
return 1;
|
2014-12-13 00:41:12 +00:00
|
|
|
}
|
2016-02-24 20:28:32 +00:00
|
|
|
|
2017-01-26 21:48:28 +00:00
|
|
|
SkGraphics::PurgeAllCaches();
|
2016-03-08 17:01:39 +00:00
|
|
|
info("Finished!\n");
|
2017-07-20 19:43:35 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
return 0;
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|