Reland "Make SkBitmap/SkPixmap::erase* do so in sRGB"
This reverts commit832c931d5b
. Reason for revert: To confirm whether it was blocking, and update Chrome if necessary Bug: skia:8663 Original change's description: > Revert "Make SkBitmap/SkPixmap::erase* do so in sRGB" > > This reverts commit6f44647e52
. > > 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> TBR=djsollen@google.com,mtklein@google.com,robertphillips@google.com,scroggo@google.com,brianosman@google.com,reed@google.com Cq-Include-Trybots: luci.chromium.try:linux-blink-rel;luci.chromium.try:android-kitkat-arm-rel;luci.chromium.try:android-marshmallow-arm64-rel;luci.chromium.try:linux-chromeos-rel;luci.chromium.try:linux_chromium_asan_rel_ng;luci.chromium.try:win7_chromium_rel_ng;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:mac_chromium_rel_ng;luci.chromium.try:linux_chromium_tsan_rel_ng;luci.chromium.try:linux_chromium_rel_ng; Change-Id: I226fd5b6f298fad648b1d05c8a8e806eac874a46 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/182142 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
parent
ed6e82796b
commit
565f17f29d
@ -780,10 +780,10 @@ public:
|
||||
*/
|
||||
void notifyPixelsChanged() const;
|
||||
|
||||
/** 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.
|
||||
/** 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.
|
||||
|
||||
@param c unpremultiplied color
|
||||
|
||||
@ -791,11 +791,11 @@ public:
|
||||
*/
|
||||
void eraseColor(SkColor c) const;
|
||||
|
||||
/** 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.
|
||||
/** 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.
|
||||
|
||||
@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)
|
||||
@ -806,8 +806,8 @@ public:
|
||||
this->eraseColor(SkColorSetARGB(a, r, g, b));
|
||||
}
|
||||
|
||||
/** Replaces pixel values inside area with c. If area does not intersect bounds(),
|
||||
call has no effect.
|
||||
/** Replaces pixel values inside area with c. interpreted as being in the sRGB
|
||||
SkColorSpace. 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,
|
||||
|
@ -672,7 +672,7 @@ public:
|
||||
Returns false if colorType() is kUnknown_SkColorType, or if subset does
|
||||
not intersect bounds().
|
||||
|
||||
@param color unpremultiplied color to write
|
||||
@param color sRGB unpremultiplied color to write
|
||||
@param subset bounding integer SkRect of written pixels
|
||||
@return true if pixels are changed
|
||||
|
||||
@ -684,7 +684,7 @@ public:
|
||||
Returns false if colorType() is kUnknown_SkColorType, or if bounds()
|
||||
is empty.
|
||||
|
||||
@param color unpremultiplied color to write
|
||||
@param color sRGB unpremultiplied color to write
|
||||
@return true if pixels are changed
|
||||
*/
|
||||
bool erase(SkColor color) const { return this->erase(color, this->bounds()); }
|
||||
@ -694,7 +694,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 unpremultiplied color to write
|
||||
@param color sRGB unpremultiplied color to write
|
||||
@param subset bounding integer SkRect of pixels to write; may be nullptr
|
||||
@return true if pixels are changed
|
||||
|
||||
|
@ -177,7 +177,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, this->colorSpace());
|
||||
paint.setColor4f(color, nullptr);
|
||||
|
||||
SkIRect clip = this->bounds();
|
||||
if (subset && !clip.intersect(*subset)) {
|
||||
|
@ -253,6 +253,20 @@ 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;
|
||||
|
Loading…
Reference in New Issue
Block a user