aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-04-27 20:08:39 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-27 20:08:45 +0000
commit0122af08f6af0dee490e1a4f35b552377d0d4753 (patch)
treedc2a227b525f067fe8c837cc8d4c5c3480cb69de /tests
parent4b32ab1b7cac09f42b0867f6c63cd8656dd9918d (diff)
Revert "Delete copyTo(Allocator), hide copyTo() behind flag"
This reverts commit d4a338f4d0a0cdc08d7d3668931c60997f0fa971. Reason for revert: Looks like I missed something I was supposed to delete in Android. Original change's description: > Delete copyTo(Allocator), hide copyTo() behind flag > > Replace uses of copyTo() in Skia. > > Bug: skia:6464 > Change-Id: I921dc53a1c29a5176d18f05741f7c0b5a008e548 > Reviewed-on: https://skia-review.googlesource.com/14502 > Commit-Queue: Matt Sarett <msarett@google.com> > Reviewed-by: Mike Reed <reed@google.com> > TBR=msarett@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I4d252940cc6a2462b030007055ea6c229471fc6e Reviewed-on: https://skia-review.googlesource.com/14602 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/BitmapCopyTest.cpp20
-rw-r--r--tests/BitmapTest.cpp3
-rw-r--r--tests/CodecAnimTest.cpp4
-rw-r--r--tests/CodecTest.cpp2
4 files changed, 21 insertions, 8 deletions
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index dd5bf1afde..aadf192285 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -9,7 +9,6 @@
#include "SkRect.h"
#include "SkTemplates.h"
#include "Test.h"
-#include "sk_tool_utils.h"
static void init_src(const SkBitmap& bitmap) {
if (bitmap.getPixels()) {
@@ -113,7 +112,7 @@ DEF_TEST(BitmapCopy_extractSubset, reporter) {
// Test copying an extracted subset.
for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) {
SkBitmap copy;
- bool success = sk_tool_utils::copy_to(&copy, gPairs[j].fColorType, subset);
+ bool success = subset.copyTo(&copy, gPairs[j].fColorType);
if (!success) {
// Skip checking that success matches fValid, which is redundant
// with the code below.
@@ -237,3 +236,20 @@ DEF_TEST(BitmapReadPixels, reporter) {
}
}
}
+
+DEF_TEST(BitmapCopy_ColorSpaceMatch, r) {
+ // We should support matching color spaces, even if they are parametric.
+ SkColorSpaceTransferFn fn;
+ fn.fA = 1.f; fn.fB = 0.f; fn.fC = 0.f; fn.fD = 0.f; fn.fE = 0.f; fn.fF = 0.f; fn.fG = 1.8f;
+ sk_sp<SkColorSpace> cs = SkColorSpace::MakeRGB(fn, SkColorSpace::kRec2020_Gamut);
+
+ SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1, cs);
+ SkBitmap bitmap;
+ bitmap.allocPixels(info);
+ bitmap.eraseColor(0);
+
+ SkBitmap copy;
+ bool success = bitmap.copyTo(&copy, kN32_SkColorType);
+ REPORTER_ASSERT(r, success);
+ REPORTER_ASSERT(r, cs.get() == copy.colorSpace());
+}
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index e0a7f78d8b..0d4b785231 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -9,7 +9,6 @@
#include "SkMallocPixelRef.h"
#include "SkRandom.h"
#include "Test.h"
-#include "sk_tool_utils.h"
static void test_peekpixels(skiatest::Reporter* reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
@@ -138,7 +137,7 @@ DEF_TEST(Bitmap_getColor_Swizzle, r) {
};
for (SkColorType ct : colorTypes) {
SkBitmap copy;
- if (!sk_tool_utils::copy_to(&copy, ct, source)) {
+ if (!source.copyTo(&copy, ct)) {
ERRORF(r, "SkBitmap::copy failed %d", (int)ct);
continue;
}
diff --git a/tests/CodecAnimTest.cpp b/tests/CodecAnimTest.cpp
index 24b9c13ae9..79e03bdef8 100644
--- a/tests/CodecAnimTest.cpp
+++ b/tests/CodecAnimTest.cpp
@@ -14,7 +14,6 @@
#include "Resources.h"
#include "Test.h"
-#include "sk_tool_utils.h"
#include <initializer_list>
#include <vector>
@@ -240,8 +239,7 @@ DEF_TEST(Codec_frames, r) {
// First copy the pixels from the cached frame
const int requiredFrame = frameInfos[index].fRequiredFrame;
if (requiredFrame != SkCodec::kNone) {
- const bool success = sk_tool_utils::copy_to(bm, kN32_SkColorType,
- cachedFrames[requiredFrame]);
+ const bool success = cachedFrames[requiredFrame].copyTo(bm);
REPORTER_ASSERT(r, success);
}
}
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 4a135337a7..7944877702 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -850,7 +850,7 @@ DEF_TEST(Codec_pngChunkReader, r) {
if (decodedBm.colorType() != bm.colorType()) {
SkBitmap tmp;
- bool success = sk_tool_utils::copy_to(&tmp, bm.colorType(), decodedBm);
+ bool success = decodedBm.copyTo(&tmp, bm.colorType());
REPORTER_ASSERT(r, success);
if (!success) {
return;