Revert "Revert "Disallow readPixels() conversions from untagged srcs to tagged dsts""
This reverts commit8461506c8b
. Reason for revert: Fixed some Chrome code, let's try this again. Original change's description: > Revert "Disallow readPixels() conversions from untagged srcs to tagged dsts" > > This reverts commitccfd1083a7
. > > Reason for revert: Roll is failing. > > Original change's description: > > Disallow readPixels() conversions from untagged srcs to tagged dsts > > > > This might break the roll into Chrome. But let's see how. > > > > BUG=skia:6021 > > > > Change-Id: I2698b5d6fe72d01bed0dc64703b592a03d441a80 > > Reviewed-on: https://skia-review.googlesource.com/7127 > > Reviewed-by: Mike Reed <reed@google.com> > > Commit-Queue: Matt Sarett <msarett@google.com> > > > > TBR=msarett@google.com,brianosman@google.com,reed@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=skia:6021 > > Change-Id: I4b62178fd7c23f43cf69ca69fc14526ecd503956 > Reviewed-on: https://skia-review.googlesource.com/7205 > Commit-Queue: Matt Sarett <msarett@google.com> > Reviewed-by: Matt Sarett <msarett@google.com> > TBR=msarett@google.com,brianosman@google.com,reed@google.com # Not skipping CQ checks because original CL landed > 1 day ago. BUG=skia:6021 Change-Id: I3f3f33fe6b84fbd5c537b60ed5c8b9201d529a6a Reviewed-on: https://skia-review.googlesource.com/8156 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
This commit is contained in:
parent
696b29346e
commit
f575993686
@ -50,6 +50,8 @@ static inline bool SkImageInfoIsValid(const SkImageInfo& info) {
|
|||||||
* should we use kPremul or kUnpremul color values with the opaque alphas? Or should
|
* 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
|
* 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.
|
* 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) {
|
static inline bool SkImageInfoValidConversion(const SkImageInfo& dst, const SkImageInfo& src) {
|
||||||
if (!SkImageInfoIsValid(dst) || !SkImageInfoIsValid(src)) {
|
if (!SkImageInfoIsValid(dst) || !SkImageInfoIsValid(src)) {
|
||||||
@ -72,5 +74,9 @@ static inline bool SkImageInfoValidConversion(const SkImageInfo& dst, const SkIm
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dst.colorSpace() && !src.colorSpace()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,14 @@
|
|||||||
|
|
||||||
using namespace sk_gpu_test;
|
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,
|
static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect* subsetA,
|
||||||
SkImage* b) {
|
SkImage* b) {
|
||||||
const int widthA = subsetA ? subsetA->width() : a->width();
|
const int widthA = subsetA ? subsetA->width() : a->width();
|
||||||
@ -45,11 +53,9 @@ static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect
|
|||||||
// see https://bug.skia.org/3965
|
// see https://bug.skia.org/3965
|
||||||
//REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque());
|
//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;
|
SkAutoPixmapStorage pmapA, pmapB;
|
||||||
pmapA.alloc(info);
|
pmapA.alloc(read_pixels_info(a));
|
||||||
pmapB.alloc(info);
|
pmapB.alloc(read_pixels_info(b));
|
||||||
|
|
||||||
const int srcX = subsetA ? subsetA->x() : 0;
|
const int srcX = subsetA ? subsetA->x() : 0;
|
||||||
const int srcY = subsetA ? subsetA->y() : 0;
|
const int srcY = subsetA ? subsetA->y() : 0;
|
||||||
@ -57,7 +63,7 @@ static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect
|
|||||||
REPORTER_ASSERT(reporter, a->readPixels(pmapA, srcX, srcY));
|
REPORTER_ASSERT(reporter, a->readPixels(pmapA, srcX, srcY));
|
||||||
REPORTER_ASSERT(reporter, b->readPixels(pmapB, 0, 0));
|
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) {
|
for (int y = 0; y < heightA; ++y) {
|
||||||
REPORTER_ASSERT(reporter, !memcmp(pmapA.addr32(0, y), pmapB.addr32(0, y), widthBytes));
|
REPORTER_ASSERT(reporter, !memcmp(pmapA.addr32(0, y), pmapB.addr32(0, y), widthBytes));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user