Commit f58d0d0c authored by Brian Osman's avatar Brian Osman Committed by Commit Bot

Guard some unit test code against an upcoming SkBitmap bug fix

This code was relying on a bug: That SkColors passed to erase were
treated as being in the bitmap's color space, rather than sRGB. (In
every other context, they are interpreted as sRGB). Fixing that bug
in Skia breaks this one unit test.

To keep the current expectations valid, rewrite the code that fills
the bitmap to clearly do what was happening before - draw rectangles
with the test colors, accompanied by the bitmap's color space, to
prevent any color space conversion. This version of the test passes
now, and continues to pass when the Skia bug is fixed.

Bug: skia:8663
Change-Id: I3a7e94847f08472081390b23fcfe0a12d8e5a38f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2161617Reviewed-by: default avatarMike Klein <mtklein@google.com>
Reviewed-by: default avatarLeon Scroggins <scroggo@google.com>
Reviewed-by: default avatarmark a. foltz <mfoltz@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Cr-Commit-Position: refs/heads/master@{#762007}
parent 1455c482
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h" #include "third_party/skia/include/core/SkPixmap.h"
...@@ -97,10 +98,15 @@ class VideoCaptureOverlayTest : public testing::Test { ...@@ -97,10 +98,15 @@ class VideoCaptureOverlayTest : public testing::Test {
kTestImageSize.width(), kTestImageSize.height(), kTestImageSize.width(), kTestImageSize.height(),
GetLinearSRGB().ToSkColorSpace()); GetLinearSRGB().ToSkColorSpace());
CHECK(result.tryAllocPixels(info, info.minRowBytes())); CHECK(result.tryAllocPixels(info, info.minRowBytes()));
result.eraseColor(kTestImageBackground); SkCanvas canvas(result);
canvas.drawColor(kTestImageBackground);
for (size_t i = 0; i < base::size(kTestImageColors); ++i) { for (size_t i = 0; i < base::size(kTestImageColors); ++i) {
const size_t idx = (i + cycle) % base::size(kTestImageColors); const size_t idx = (i + cycle) % base::size(kTestImageColors);
result.erase(kTestImageColors[idx], kTestImageColorRects[i]); SkPaint paint;
paint.setBlendMode(SkBlendMode::kSrc);
paint.setColor(SkColor4f::FromColor(kTestImageColors[idx]),
info.colorSpace());
canvas.drawIRect(kTestImageColorRects[i], paint);
} }
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment