Remove a bunch of unused files and functions
Bug: skia:
Change-Id: I1f05014a6ab955f324e4cde4f7b7aebe8f7d72a1
Reviewed-on: https://skia-review.googlesource.com/c/160385
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/gm/gm_expectations.h b/gm/gm_expectations.h
deleted file mode 100644
index 52e711f..0000000
--- a/gm/gm_expectations.h
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * TODO(epoger): Combine this with tools/image_expectations.h, or eliminate one of the two.
- */
-#ifndef gm_expectations_DEFINED
-#define gm_expectations_DEFINED
-
-#include "gm.h"
-#include "SkBitmap.h"
-#include "SkData.h"
-#include "SkJSONCPP.h"
-#include "SkOSFile.h"
-#include "SkRefCnt.h"
-#include "SkStream.h"
-#include "SkTArray.h"
-
-
-namespace skiagm {
-
- Json::Value CreateJsonTree(Json::Value expectedResults,
- Json::Value actualResultsFailed,
- Json::Value actualResultsFailureIgnored,
- Json::Value actualResultsNoComparison,
- Json::Value actualResultsSucceeded);
- /**
- * The digest of a GM test result.
- *
- * Currently, this is always a uint64_t hash digest of an SkBitmap...
- * but we will add other flavors soon.
- */
- class GmResultDigest {
- public:
- /**
- * Create a ResultDigest representing an actual image result.
- */
- explicit GmResultDigest(const SkBitmap &bitmap);
-
- /**
- * Create a ResultDigest representing an allowed result
- * checksum within JSON expectations file, in the form
- * ["bitmap-64bitMD5", 12345].
- */
- explicit GmResultDigest(const Json::Value &jsonTypeValuePair);
-
- /**
- * Returns true if this GmResultDigest was fully and successfully
- * created.
- */
- bool isValid() const;
-
- /**
- * Returns true if this and other GmResultDigest could
- * represent identical results.
- */
- bool equals(const GmResultDigest &other) const;
-
- /**
- * Returns a JSON type/value pair representing this result,
- * such as ["bitmap-64bitMD5", 12345].
- */
- Json::Value asJsonTypeValuePair() const;
-
- /**
- * Returns the hashtype, such as "bitmap-64bitMD5", as an SkString.
- */
- SkString getHashType() const;
-
- /**
- * Returns the hash digest value, such as "12345", as an SkString.
- */
- SkString getDigestValue() const;
-
- private:
- bool fIsValid; // always check this first--if it's false, other fields are meaningless
- uint64_t fHashDigest;
- };
-
- /**
- * Encapsulates an SkBitmap and its GmResultDigest, guaranteed to keep them in sync.
- */
- class BitmapAndDigest {
- public:
- explicit BitmapAndDigest(const SkBitmap &bitmap) : fBitmap(bitmap), fDigest(bitmap) {}
-
- const SkBitmap fBitmap;
- const GmResultDigest fDigest;
- };
-
- /**
- * Test expectations (allowed image results, etc.)
- */
- class Expectations {
- public:
- /**
- * No expectations at all.
- */
- explicit Expectations(bool ignoreFailure=kDefaultIgnoreFailure);
-
- /**
- * Expect exactly one image (appropriate for the case when we
- * are comparing against a single PNG file).
- */
- explicit Expectations(const SkBitmap& bitmap, bool ignoreFailure=kDefaultIgnoreFailure);
-
- /**
- * Expect exactly one image, whose digest has already been computed.
- */
- explicit Expectations(const BitmapAndDigest& bitmapAndDigest);
-
- /**
- * Create Expectations from a JSON element as found within the
- * kJsonKey_ExpectedResults section.
- *
- * It's fine if the jsonElement is null or empty; in that case, we just
- * don't have any expectations.
- */
- explicit Expectations(Json::Value jsonElement);
-
- /**
- * Returns true iff we want to ignore failed expectations.
- */
- bool ignoreFailure() const { return this->fIgnoreFailure; }
-
- /**
- * Override default setting of fIgnoreFailure.
- */
- void setIgnoreFailure(bool val) { this->fIgnoreFailure = val; }
-
- /**
- * Returns true iff there are no allowed results.
- */
- bool empty() const { return this->fAllowedResultDigests.empty(); }
-
- /**
- * Returns true iff resultDigest matches any allowed result,
- * regardless of fIgnoreFailure. (The caller can check
- * that separately.)
- */
- bool match(GmResultDigest resultDigest) const;
-
- /**
- * If this Expectation is based on a single SkBitmap, return a
- * pointer to that SkBitmap. Otherwise (if the Expectation is
- * empty, or if it was based on a list of checksums rather
- * than a single bitmap), returns nullptr.
- */
- const SkBitmap *asBitmap() const {
- return (kUnknown_SkColorType == fBitmap.colorType()) ? nullptr : &fBitmap;
- }
-
- /**
- * Return a JSON representation of the expectations.
- */
- Json::Value asJsonValue() const;
-
- private:
- const static bool kDefaultIgnoreFailure = false;
-
- SkTArray<GmResultDigest> fAllowedResultDigests;
- bool fIgnoreFailure;
- SkBitmap fBitmap;
- };
-
- /**
- * Abstract source of Expectations objects for individual tests.
- */
- class ExpectationsSource : public SkRefCnt {
- public:
- virtual Expectations get(const char *testName) const = 0;
-
- private:
- typedef SkRefCnt INHERITED;
- };
-
- /**
- * Return Expectations based on individual image files on disk.
- */
- class IndividualImageExpectationsSource : public ExpectationsSource {
- public:
- /**
- * Create an ExpectationsSource that will return Expectations based on
- * image files found within rootDir.
- *
- * rootDir: directory under which to look for image files
- * (this string will be copied to storage within this object)
- */
- explicit IndividualImageExpectationsSource(const char *rootDir) : fRootDir(rootDir) {}
-
- Expectations get(const char *testName) const override ;
-
- private:
- const SkString fRootDir;
- };
-
- /**
- * Return Expectations based on JSON summary file.
- */
- class JsonExpectationsSource : public ExpectationsSource {
- public:
- /**
- * Create an ExpectationsSource that will return Expectations based on
- * a JSON file.
- *
- * jsonPath: path to JSON file to read
- */
- explicit JsonExpectationsSource(const char *jsonPath);
-
- Expectations get(const char *testName) const override;
-
- private:
-
- /**
- * Read the file contents from jsonPath and parse them into jsonRoot.
- *
- * Returns true if successful.
- */
- static bool Parse(const char *jsonPath, Json::Value *jsonRoot);
-
- Json::Value fJsonRoot;
- Json::Value fJsonExpectedResults;
- };
-
-}
-#endif
diff --git a/tools/imgblur.cpp b/tools/imgblur.cpp
deleted file mode 100644
index 20d3684..0000000
--- a/tools/imgblur.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkBitmap.h"
-#include "SkCommandLineFlags.h"
-#include "SkCommonFlags.h"
-#include "SkData.h"
-#include "SkImage.h"
-#include "SkStream.h"
-#include "SkTypes.h"
-
-#include "sk_tool_utils.h"
-
-DEFINE_string(in, "input.png", "Input image");
-DEFINE_string(out, "blurred.png", "Output image");
-DEFINE_double(sigma, 1, "Sigma to be used for blur (> 0.0f)");
-
-
-// This tool just performs a blur on an input image
-// Return codes:
-static const int kSuccess = 0;
-static const int kError = 1;
-
-int main(int argc, char** argv) {
- SkCommandLineFlags::SetUsage("Brute force blur of an image.");
- SkCommandLineFlags::Parse(argc, argv);
-
- if (FLAGS_sigma <= 0) {
- if (!FLAGS_quiet) {
- SkDebugf("Sigma must be greater than zero (it is %f).\n", FLAGS_sigma);
- }
- return kError;
- }
-
- sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_in[0]));
- if (nullptr == data) {
- if (!FLAGS_quiet) {
- SkDebugf("Couldn't open file: %s\n", FLAGS_in[0]);
- }
- return kError;
- }
-
- sk_sp<SkImage> image(SkImage::MakeFromEncoded(data));
- if (!image) {
- if (!FLAGS_quiet) {
- SkDebugf("Couldn't create image for: %s.\n", FLAGS_in[0]);
- }
- return kError;
- }
-
- SkBitmap src;
- if (!image->asLegacyBitmap(&src, SkImage::kRW_LegacyBitmapMode)) {
- if (!FLAGS_quiet) {
- SkDebugf("Couldn't create bitmap for: %s.\n", FLAGS_in[0]);
- }
- return kError;
- }
-
- SkBitmap dst = sk_tool_utils::slow_blur(src, (float) FLAGS_sigma);
-
- if (!sk_tool_utils::EncodeImageToFile(FLAGS_out[0], dst, SkEncodedImageFormat::kPNG, 100)) {
- if (!FLAGS_quiet) {
- SkDebugf("Couldn't write to file: %s\n", FLAGS_out[0]);
- }
- return kError;
- }
-
- return kSuccess;
-}
diff --git a/tools/imgslice.cpp b/tools/imgslice.cpp
deleted file mode 100644
index 51aeef7..0000000
--- a/tools/imgslice.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkBitmap.h"
-#include "SkCommandLineFlags.h"
-#include "SkData.h"
-#include "SkImage.h"
-#include "SkStream.h"
-
-DEFINE_bool(header, false, "Print an extra row of the min-max values");
-DEFINE_string2(label, l, "label", "Label printed as the first value");
-
-DEFINE_string2(image, i, "", "Input image");
-DEFINE_int32_2(row, r, -1, "Row to extract");
-DEFINE_int32_2(column, c, -1, "Column to extract");
-
-DEFINE_int32_2(min, n, 0, "Minimum row/column to extract - inclusive");
-DEFINE_int32_2(max, m, 100, "Maximum row/column to extract - inclusive");
-
-DEFINE_int32(rgb, 0, "Color channel to print (0->b, 1->g, 2->r, 3->a)");
-
-DEFINE_bool2(quiet, q, false, "Quiet");
-DEFINE_bool2(reverse, v, false, "Iterate from max to min");
-
-
-// This tool just loads a single image and prints out a comma-separated row or column
-// Return codes:
-static const int kSuccess = 0;
-static const int kError = 1;
-
-int main(int argc, char** argv) {
- SkCommandLineFlags::SetUsage("Print out a row or column of an image.");
- SkCommandLineFlags::Parse(argc, argv);
-
- if (FLAGS_rgb > 3 || FLAGS_rgb < 0) {
- if (!FLAGS_quiet) {
- SkDebugf("Channel (--rgb) must be between 0 and 3 (inclusive) - value is %d.\n",
- FLAGS_rgb);
- }
- return kError;
- }
-
- if (FLAGS_row >= 0 && FLAGS_column >= 0) {
- if (!FLAGS_quiet) {
- SkDebugf("Only one of '-c' or '-r' can be specified at at time.\n");
- }
- return kError;
- }
-
- if (FLAGS_row < 0 && FLAGS_column < 0) {
- if (!FLAGS_quiet) {
- SkDebugf("At least one of '-c' or '-r' need to be specified.\n");
- }
- return kError;
- }
-
- sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_image[0]));
- if (nullptr == data) {
- if (!FLAGS_quiet) {
- SkDebugf("Couldn't open file: %s\n", FLAGS_image[0]);
- }
- return kError;
- }
-
- sk_sp<SkImage> image(SkImage::MakeFromEncoded(data));
- if (!image) {
- if (!FLAGS_quiet) {
- SkDebugf("Couldn't create image for: %s.\n", FLAGS_image[0]);
- }
- return kError;
- }
-
- SkBitmap bitmap;
- if (!image->asLegacyBitmap(&bitmap, SkImage::kRW_LegacyBitmapMode)) {
- if (!FLAGS_quiet) {
- SkDebugf("Couldn't create bitmap for: %s.\n", FLAGS_image[0]);
- }
- return kError;
- }
-
- int top, bottom, left, right;
-
- if (-1 != FLAGS_row) {
- SkASSERT(-1 == FLAGS_column);
-
- top = bottom = SkTPin(FLAGS_row, 0, bitmap.height()-1);
- FLAGS_min = left = SkTPin(FLAGS_min, 0, bitmap.width()-1);
- FLAGS_max = right = SkTPin(FLAGS_max, left, bitmap.width()-1);
- } else {
- SkASSERT(-1 != FLAGS_column);
- left = right = SkTPin(FLAGS_column, 0, bitmap.width()-1);
- FLAGS_min = top = SkTPin(FLAGS_min, 0, bitmap.height()-1);
- FLAGS_max = bottom = SkTPin(FLAGS_max, top, bitmap.height()-1);
- }
-
- if (FLAGS_header) {
- SkDebugf("header");
- if (FLAGS_reverse) {
- for (int i = FLAGS_max; i >= FLAGS_min; --i) {
- SkDebugf(", %d", i);
- }
- } else {
- for (int i = FLAGS_min; i <= FLAGS_max; ++i) {
- SkDebugf(", %d", i);
- }
- }
- SkDebugf("\n");
- }
-
- SkDebugf("%s", FLAGS_label[0]);
- if (FLAGS_reverse) {
- for (int y = bottom; y >= top; --y) {
- for (int x = right; x >= left; --x) {
- SkColor c = bitmap.getColor(x, y);
-
- SkDebugf(", %d", ((c) >> (FLAGS_rgb*8)) & 0xFF);
- }
- }
- } else {
- for (int y = top; y <= bottom; ++y) {
- for (int x = left; x <= right; ++x) {
- SkColor c = bitmap.getColor(x, y);
-
- SkDebugf(", %d", ((c) >> (FLAGS_rgb*8)) & 0xFF);
- }
- }
- }
-
- SkDebugf("\n");
-
- return kSuccess;
-}
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
index a0b57e5..00c8e63 100644
--- a/tools/sk_tool_utils.cpp
+++ b/tools/sk_tool_utils.cpp
@@ -286,181 +286,6 @@
#include "BigPathBench.inc" // IWYU pragma: keep
}
-static float gaussian2d_value(int x, int y, float sigma) {
- // don't bother with the scale term since we're just going to normalize the
- // kernel anyways
- float temp = expf(-(x*x + y*y)/(2*sigma*sigma));
- return temp;
-}
-
-static float* create_2d_kernel(float sigma, int* filterSize) {
- // We will actually take 2*halfFilterSize+1 samples (i.e., our filter kernel
- // sizes are always odd)
- int halfFilterSize = SkScalarCeilToInt(6*sigma)/2;
- int wh = *filterSize = 2*halfFilterSize + 1;
-
- float* temp = new float[wh*wh];
-
- float filterTot = 0.0f;
- for (int yOff = 0; yOff < wh; ++yOff) {
- for (int xOff = 0; xOff < wh; ++xOff) {
- temp[yOff*wh+xOff] = gaussian2d_value(xOff-halfFilterSize, yOff-halfFilterSize, sigma);
-
- filterTot += temp[yOff*wh+xOff];
- }
- }
-
- // normalize the kernel
- for (int yOff = 0; yOff < wh; ++yOff) {
- for (int xOff = 0; xOff < wh; ++xOff) {
- temp[yOff*wh+xOff] /= filterTot;
- }
- }
-
- return temp;
-}
-
-static SkPMColor blur_pixel(const SkBitmap& bm, int x, int y, float* kernel, int wh) {
- SkASSERT(wh & 0x1);
-
- int halfFilterSize = (wh-1)/2;
-
- float r = 0.0f, g = 0.0f, b = 0.0f;
- for (int yOff = 0; yOff < wh; ++yOff) {
- int ySamp = y + yOff - halfFilterSize;
-
- if (ySamp < 0) {
- ySamp = 0;
- } else if (ySamp > bm.height()-1) {
- ySamp = bm.height()-1;
- }
-
- for (int xOff = 0; xOff < wh; ++xOff) {
- int xSamp = x + xOff - halfFilterSize;
-
- if (xSamp < 0) {
- xSamp = 0;
- } else if (xSamp > bm.width()-1) {
- xSamp = bm.width()-1;
- }
-
- float filter = kernel[yOff*wh + xOff];
-
- SkPMColor c = *bm.getAddr32(xSamp, ySamp);
-
- r += SkGetPackedR32(c) * filter;
- g += SkGetPackedG32(c) * filter;
- b += SkGetPackedB32(c) * filter;
- }
- }
-
- U8CPU r8, g8, b8;
-
- r8 = (U8CPU) (r+0.5f);
- g8 = (U8CPU) (g+0.5f);
- b8 = (U8CPU) (b+0.5f);
-
- return SkPackARGB32(255, r8, g8, b8);
-}
-
-SkBitmap slow_blur(const SkBitmap& src, float sigma) {
- SkBitmap dst;
-
- dst.allocN32Pixels(src.width(), src.height(), true);
-
- int wh;
- std::unique_ptr<float[]> kernel(create_2d_kernel(sigma, &wh));
-
- for (int y = 0; y < src.height(); ++y) {
- for (int x = 0; x < src.width(); ++x) {
- *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh);
- }
- }
-
- return dst;
-}
-
-// compute the intersection point between the diagonal and the ellipse in the
-// lower right corner
-static SkPoint intersection(SkScalar w, SkScalar h) {
- SkASSERT(w > 0.0f || h > 0.0f);
-
- return SkPoint::Make(w / SK_ScalarSqrt2, h / SK_ScalarSqrt2);
-}
-
-// Use the intersection of the corners' diagonals with their ellipses to shrink
-// the bounding rect
-SkRect compute_central_occluder(const SkRRect& rr) {
- const SkRect r = rr.getBounds();
-
- SkScalar newL = r.fLeft, newT = r.fTop, newR = r.fRight, newB = r.fBottom;
-
- SkVector radii = rr.radii(SkRRect::kUpperLeft_Corner);
- if (!radii.isZero()) {
- SkPoint p = intersection(radii.fX, radii.fY);
-
- newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
- newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
- }
-
- radii = rr.radii(SkRRect::kUpperRight_Corner);
- if (!radii.isZero()) {
- SkPoint p = intersection(radii.fX, radii.fY);
-
- newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
- newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
- }
-
- radii = rr.radii(SkRRect::kLowerRight_Corner);
- if (!radii.isZero()) {
- SkPoint p = intersection(radii.fX, radii.fY);
-
- newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
- newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
- }
-
- radii = rr.radii(SkRRect::kLowerLeft_Corner);
- if (!radii.isZero()) {
- SkPoint p = intersection(radii.fX, radii.fY);
-
- newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
- newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
- }
-
- return SkRect::MakeLTRB(newL, newT, newR, newB);
-}
-
-// The widest inset rect
-SkRect compute_widest_occluder(const SkRRect& rr) {
- const SkRect& r = rr.getBounds();
-
- const SkVector& ul = rr.radii(SkRRect::kUpperLeft_Corner);
- const SkVector& ur = rr.radii(SkRRect::kUpperRight_Corner);
- const SkVector& lr = rr.radii(SkRRect::kLowerRight_Corner);
- const SkVector& ll = rr.radii(SkRRect::kLowerLeft_Corner);
-
- SkScalar maxT = SkTMax(ul.fY, ur.fY);
- SkScalar maxB = SkTMax(ll.fY, lr.fY);
-
- return SkRect::MakeLTRB(r.fLeft, r.fTop + maxT, r.fRight, r.fBottom - maxB);
-
-}
-
-// The tallest inset rect
-SkRect compute_tallest_occluder(const SkRRect& rr) {
- const SkRect& r = rr.getBounds();
-
- const SkVector& ul = rr.radii(SkRRect::kUpperLeft_Corner);
- const SkVector& ur = rr.radii(SkRRect::kUpperRight_Corner);
- const SkVector& lr = rr.radii(SkRRect::kLowerRight_Corner);
- const SkVector& ll = rr.radii(SkRRect::kLowerLeft_Corner);
-
- SkScalar maxL = SkTMax(ul.fX, ll.fX);
- SkScalar maxR = SkTMax(ur.fX, lr.fX);
-
- return SkRect::MakeLTRB(r.fLeft + maxL, r.fTop, r.fRight - maxR, r.fBottom);
-}
-
bool copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) {
SkPixmap srcPM;
if (!src.peekPixels(&srcPM)) {
diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h
index 210b659..1d3072a 100644
--- a/tools/sk_tool_utils.h
+++ b/tools/sk_tool_utils.h
@@ -142,14 +142,6 @@
void make_big_path(SkPath& path);
- // Return a blurred version of 'src'. This doesn't use a separable filter
- // so it is slow!
- SkBitmap slow_blur(const SkBitmap& src, float sigma);
-
- SkRect compute_central_occluder(const SkRRect& rr);
- SkRect compute_widest_occluder(const SkRRect& rr);
- SkRect compute_tallest_occluder(const SkRRect& rr);
-
// A helper object to test the topological sorting code (TopoSortBench.cpp & TopoSortTest.cpp)
class TopoTestNode : public SkRefCnt {
public:
diff --git a/tools/skpmaker.cpp b/tools/skpmaker.cpp
deleted file mode 100644
index a3ccd61..0000000
--- a/tools/skpmaker.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Simple tool to generate SKP files for testing.
- */
-
-#include "SkCanvas.h"
-#include "SkColor.h"
-#include "SkCommandLineFlags.h"
-#include "SkPaint.h"
-#include "SkPicture.h"
-#include "SkPictureRecorder.h"
-#include "SkScalar.h"
-#include "SkStream.h"
-
-#include <stdlib.h>
-
-// Flags used by this file, alphabetically:
-DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255.");
-DEFINE_int32(border, 4, "Width of the black border around the image.");
-DEFINE_int32(green, 128, "Value of green color channel in image, 0-255.");
-DEFINE_int32(height, 200, "Height of canvas to create.");
-DEFINE_int32(red, 128, "Value of red color channel in image, 0-255.");
-DEFINE_int32(width, 300, "Width of canvas to create.");
-DEFINE_string(writePath, "", "Filepath to write the SKP into.");
-
-// Create a 'width' by 'height' skp with a 'border'-wide black border around
-// a 'color' rectangle.
-static void make_skp(SkScalar width, SkScalar height, SkScalar border, SkColor color,
- const char *writePath) {
- SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0);
- SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(SK_ColorBLACK);
- SkRect r = SkRect::MakeWH(width, height);
- canvas->drawRect(r, paint);
- paint.setColor(color);
- r.inset(border, border);
- canvas->drawRect(r, paint);
- SkFILEWStream stream(writePath);
- recorder.finishRecordingAsPicture()->serialize(&stream);
-}
-
-int main(int argc, char** argv) {
- SkCommandLineFlags::SetUsage("Creates a simple .skp file for testing.");
- SkCommandLineFlags::Parse(argc, argv);
-
- // Validate flags.
- if ((FLAGS_blue < 0) || (FLAGS_blue > 255)) {
- SkDebugf("--blue must be within range [0,255]\n");
- exit(-1);
- }
- if ((FLAGS_green < 0) || (FLAGS_green > 255)) {
- SkDebugf("--green must be within range [0,255]\n");
- exit(-1);
- }
- if (FLAGS_height <= 0) {
- SkDebugf("--height must be >0\n");
- exit(-1);
- }
- if ((FLAGS_red < 0) || (FLAGS_red > 255)) {
- SkDebugf("--red must be within range [0,255]\n");
- exit(-1);
- }
- if (FLAGS_width <= 0) {
- SkDebugf("--width must be >0\n");
- exit(-1);
- }
- if (FLAGS_writePath.isEmpty()) {
- SkDebugf("--writePath must be nonempty\n");
- exit(-1);
- }
-
- SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue);
- make_skp(SkIntToScalar(FLAGS_width),
- SkIntToScalar(FLAGS_height),
- SkIntToScalar(FLAGS_border),
- color, FLAGS_writePath[0]);
- return 0;
-}