Revert "Make SkBitmap/SkPixmap::erase* do so in sRGB"

This reverts commit 6f44647e52.

Reason for revert: checking to see if this is blocking the Chrome roll

Original change's description:
> Make SkBitmap/SkPixmap::erase* do so in sRGB
> 
> We generally consider untagged colors to be sRGB, so this makes us more
> consistent with other parts of the API.
> 
> Add a test.
> 
> Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
> Change-Id: I5468c86ad92164797a65ffd9fbe471e01a97a2ca
> Reviewed-on: https://skia-review.googlesource.com/c/179245
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=djsollen@google.com,mtklein@google.com,scroggo@google.com,brianosman@google.com,reed@google.com

Change-Id: Ia592adf2c790d294da1e32c1e83f9f34e81d79cc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Reviewed-on: https://skia-review.googlesource.com/c/182083
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-01-08 13:04:10 +00:00 committed by Skia Commit-Bot
parent b20e68e2a9
commit 832c931d5b
4 changed files with 15 additions and 29 deletions

View File

@ -777,20 +777,20 @@ public:
*/
void notifyPixelsChanged() const;
/** Replaces pixel values with c, interpreted as being in the sRGB SkColorSpace.
All pixels contained by bounds() are affected. If the colorType() is
kGray_8_SkColorType or kRGB_565_SkColorType, then alpha is ignored; RGB is
treated as opaque. If colorType() is kAlpha_8_SkColorType, then RGB is ignored.
/** Replaces pixel values with c. All pixels contained by bounds() are affected.
If the colorType() is kGray_8_SkColorType or kRGB_565_SkColorType, then alpha
is ignored; RGB is treated as opaque. If colorType() is kAlpha_8_SkColorType,
then RGB is ignored.
@param c unpremultiplied color
*/
void eraseColor(SkColor c) const;
/** Replaces pixel values with unpremultiplied color built from a, r, g, and b,
interpreted as being in the sRGB SkColorSpace. All pixels contained by
bounds() are affected. If the colorType() is kGray_8_SkColorType or
kRGB_565_SkColorType, then a is ignored; r, g, and b are treated as opaque.
If colorType() is kAlpha_8_SkColorType, then r, g, and b are ignored.
/** Replaces pixel values with unpremultiplied color built from a, r, g, and b.
All pixels contained by bounds() are affected.
If the colorType() is kGray_8_SkColorType or kRGB_565_SkColorType, then a
is ignored; r, g, and b are treated as opaque. If colorType() is kAlpha_8_SkColorType,
then r, g, and b are ignored.
@param a amount of alpha, from fully transparent (0) to fully opaque (255)
@param r amount of red, from no red (0) to full red (255)
@ -801,8 +801,8 @@ public:
this->eraseColor(SkColorSetARGB(a, r, g, b));
}
/** Replaces pixel values inside area with c. interpreted as being in the sRGB
SkColorSpace. If area does not intersect bounds(), call has no effect.
/** Replaces pixel values inside area with c. If area does not intersect bounds(),
call has no effect.
If the colorType() is kGray_8_SkColorType or kRGB_565_SkColorType, then alpha
is ignored; RGB is treated as opaque. If colorType() is kAlpha_8_SkColorType,

View File

@ -669,7 +669,7 @@ public:
Returns false if colorType() is kUnknown_SkColorType, or if subset does
not intersect bounds().
@param color sRGB unpremultiplied color to write
@param color unpremultiplied color to write
@param subset bounding integer SkRect of written pixels
@return true if pixels are changed
*/
@ -679,7 +679,7 @@ public:
Returns false if colorType() is kUnknown_SkColorType, or if bounds()
is empty.
@param color sRGB unpremultiplied color to write
@param color unpremultiplied color to write
@return true if pixels are changed
*/
bool erase(SkColor color) const { return this->erase(color, this->bounds()); }
@ -689,7 +689,7 @@ public:
colorType() is kUnknown_SkColorType, if subset is not nullptr and does
not intersect bounds(), or if subset is nullptr and bounds() is empty.
@param color sRGB unpremultiplied color to write
@param color unpremultiplied color to write
@param subset bounding integer SkRect of pixels to write; may be nullptr
@return true if pixels are changed
*/

View File

@ -155,7 +155,7 @@ bool SkPixmap::erase(SkColor color, const SkIRect& subset) const {
bool SkPixmap::erase(const SkColor4f& color, const SkIRect* subset) const {
SkPaint paint;
paint.setBlendMode(SkBlendMode::kSrc);
paint.setColor4f(color, nullptr);
paint.setColor4f(color, this->colorSpace());
SkIRect clip = this->bounds();
if (subset && !clip.intersect(*subset)) {

View File

@ -224,20 +224,6 @@ DEF_TEST(Bitmap_erase_f16_erase_getColor, r) {
}
}
// Verify that SkBitmap::erase erases in SRGB, regardless of the SkColorSpace of the
// SkBitmap.
DEF_TEST(Bitmap_erase_srgb, r) {
SkBitmap bm;
// Use a color spin from SRGB.
bm.allocPixels(SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlphaType,
SkColorSpace::MakeSRGB()->makeColorSpin()));
// RED will be converted into the spun color space.
bm.eraseColor(SK_ColorRED);
// getColor doesn't take the color space into account, so the returned color
// is different due to the color spin.
REPORTER_ASSERT(r, bm.getColor(0, 0) == SK_ColorBLUE);
}
// Make sure that the bitmap remains valid when pixelref is removed.
DEF_TEST(Bitmap_clear_pixelref_keep_info, r) {
SkBitmap bm;