Merge latest Skia into master (3 commits)
https://skia.googlesource.com/skia.git/+log/0831f1b..874a872
Test: Presubmit checks will test this change.
Change-Id: I72ab252fe17218f7841c79dc1c50a201ec1d34f9
diff --git a/gm/savelayer.cpp b/gm/savelayer.cpp
index 9b4db35..8f2d5c8 100644
--- a/gm/savelayer.cpp
+++ b/gm/savelayer.cpp
@@ -7,17 +7,20 @@
#include "gm.h"
-static void saveLayer(SkCanvas* canvas, SkScalar l, SkScalar t, SkScalar r, SkScalar b) {
- uint32_t flag = 1U << 31;
+// This GM tests out the deprecated Android-specific unclipped saveLayer "feature".
+// In particular, it attempts to compare the performance of unclipped saveLayers with alternatives.
+
+static void save_layer_unclipped(SkCanvas* canvas,
+ SkScalar l, SkScalar t, SkScalar r, SkScalar b) {
+ static const uint32_t kSecretDeprecated_DontClipToLayerFlag = 1U << 31;
SkRect rect = SkRect::MakeLTRB(l, t, r, b);
- canvas->saveLayer({ &rect, nullptr, nullptr, flag });
+ canvas->saveLayer({ &rect, nullptr, nullptr, kSecretDeprecated_DontClipToLayerFlag });
}
static void do_draw(SkCanvas* canvas) {
SkPaint paint;
SkRandom rand;
- SkAutoCanvasRestore acr(canvas, true);
for (int i = 0; i < 20; ++i) {
paint.setColor(rand.nextU() | (0xFF << 24));
canvas->drawRect({ 15, 15, 290, 40 }, paint);
@@ -25,18 +28,60 @@
}
}
-DEF_SIMPLE_GM(savelayer_unclipped, canvas, 320, 640) {
- const SkScalar L = 10;
- const SkScalar T = 10;
- const SkScalar R = 310;
- const SkScalar B = 630;
+class UnclippedSaveLayerGM : public skiagm::GM {
+public:
+ enum class Mode {
+ kClipped,
+ kUnclipped
+ };
- canvas->clipRect({ L, T, R, B });
+ UnclippedSaveLayerGM(Mode mode) : fMode(mode) { this->setBGColor(SK_ColorWHITE); }
- for (int i = 0; i < 100; ++i) {
- SkAutoCanvasRestore acr(canvas, true);
- saveLayer(canvas, L, T, R, T + 20);
- saveLayer(canvas, L, B - 20, R, B);
- do_draw(canvas);
+protected:
+ bool runAsBench() const override { return true; }
+
+ SkString onShortName() override {
+ if (Mode::kClipped == fMode) {
+ return SkString("savelayer_unclipped");
+ } else {
+ SkASSERT(Mode::kUnclipped == fMode);
+ return SkString("savelayer_clipped");
+ }
}
-}
+
+ SkISize onISize() override { return SkISize::Make(320, 640); }
+
+ void onDraw(SkCanvas* canvas) override {
+ const SkScalar L = 10;
+ const SkScalar T = 10;
+ const SkScalar R = 310;
+ const SkScalar B = 630;
+
+ canvas->clipRect({ L, T, R, B });
+
+ for (int i = 0; i < 100; ++i) {
+ SkAutoCanvasRestore acr(canvas, true);
+ if (Mode::kClipped == fMode) {
+ save_layer_unclipped(canvas, L, T, R, T + 20);
+ save_layer_unclipped(canvas, L, B - 20, R, B);
+ } else {
+ SkASSERT(Mode::kUnclipped == fMode);
+ canvas->saveLayer({ L, T, R, B }, nullptr);
+ }
+
+ do_draw(canvas);
+ }
+ }
+
+private:
+ Mode fMode;
+
+ typedef skiagm::GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+DEF_GM(return new UnclippedSaveLayerGM(UnclippedSaveLayerGM::Mode::kClipped);)
+DEF_GM(return new UnclippedSaveLayerGM(UnclippedSaveLayerGM::Mode::kUnclipped);)
+
+
diff --git a/src/core/SkAnalyticEdge.h b/src/core/SkAnalyticEdge.h
index c70772d..e2a9867 100644
--- a/src/core/SkAnalyticEdge.h
+++ b/src/core/SkAnalyticEdge.h
@@ -10,6 +10,11 @@
#include "SkEdge.h"
+// Use this to check that we successfully guard the change against Chromium layout tests
+#ifndef SK_SUPPORT_LEGACY_AAA
+# define SK_SUPPORT_LEGACY_AAA
+#endif
+
struct SkAnalyticEdge {
// Similar to SkEdge, the conic edges will be converted to quadratic edges
enum Type {
diff --git a/src/core/SkImageInfoPriv.h b/src/core/SkImageInfoPriv.h
index 72138ae..2b09a4e 100644
--- a/src/core/SkImageInfoPriv.h
+++ b/src/core/SkImageInfoPriv.h
@@ -51,6 +51,8 @@
* should we use kPremul or kUnpremul color values with the opaque alphas? Or should
* we just use whatever the |src| alpha is? In the future, we could choose to clearly
* define this, but currently no one is asking for this feature.
+ * We will not convert to a particular color space if |src| is nullptr. The color space
+ * conversion is not well-defined.
*/
static inline bool SkImageInfoValidConversion(const SkImageInfo& dst, const SkImageInfo& src) {
if (!SkImageInfoIsValid(dst) || !SkImageInfoIsValid(src)) {
@@ -73,5 +75,9 @@
return false;
}
+ if (dst.colorSpace() && !src.colorSpace()) {
+ return false;
+ }
+
return true;
}
diff --git a/src/core/SkScan.h b/src/core/SkScan.h
index c995542..d0c10fa 100644
--- a/src/core/SkScan.h
+++ b/src/core/SkScan.h
@@ -23,6 +23,11 @@
*/
typedef SkIRect SkXRect;
+// Use this to check that we successfully guard the change against Chromium layout tests
+#ifndef SK_SUPPORT_LEGACY_AAA
+# define SK_SUPPORT_LEGACY_AAA
+#endif
+
extern std::atomic<bool> gSkUseAnalyticAA;
extern std::atomic<bool> gSkForceAnalyticAA;
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 4f9d944..904ca20 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -34,6 +34,14 @@
using namespace sk_gpu_test;
+SkImageInfo read_pixels_info(SkImage* image) {
+ if (as_IB(image)->onImageInfo().colorSpace()) {
+ return SkImageInfo::MakeS32(image->width(), image->height(), image->alphaType());
+ }
+
+ return SkImageInfo::MakeN32(image->width(), image->height(), image->alphaType());
+}
+
static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect* subsetA,
SkImage* b) {
const int widthA = subsetA ? subsetA->width() : a->width();
@@ -45,11 +53,9 @@
// see https://bug.skia.org/3965
//REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque());
- // The codecs may have given us back F16, we can't read from F16 raster to N32, only S32.
- SkImageInfo info = SkImageInfo::MakeS32(widthA, heightA, a->alphaType());
SkAutoPixmapStorage pmapA, pmapB;
- pmapA.alloc(info);
- pmapB.alloc(info);
+ pmapA.alloc(read_pixels_info(a));
+ pmapB.alloc(read_pixels_info(b));
const int srcX = subsetA ? subsetA->x() : 0;
const int srcY = subsetA ? subsetA->y() : 0;
@@ -57,7 +63,7 @@
REPORTER_ASSERT(reporter, a->readPixels(pmapA, srcX, srcY));
REPORTER_ASSERT(reporter, b->readPixels(pmapB, 0, 0));
- const size_t widthBytes = widthA * info.bytesPerPixel();
+ const size_t widthBytes = widthA * 4;
for (int y = 0; y < heightA; ++y) {
REPORTER_ASSERT(reporter, !memcmp(pmapA.addr32(0, y), pmapB.addr32(0, y), widthBytes));
}