Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tests/SpecialImageTest.cpp

Issue 1808833002: Revert of Add SkSpecialImage::extractSubset & NewFromPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/ImageTest.cpp ('k') | tests/TestingSpecialImageAccess.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SpecialImageTest.cpp
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 7511e6297123a82b6d78ccfadf3ba4f670e5072c..9bde7eec3348546474bbbc377cbfbc87139a099f 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -5,11 +5,9 @@
* found in the LICENSE file
*/
-#include "SkAutoPixmapStorage.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkImage.h"
-#include "SkPixmap.h"
#include "SkSpecialImage.h"
#include "SkSpecialSurface.h"
#include "Test.h"
@@ -50,11 +48,10 @@
// Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw)
static void test_image(SkSpecialImage* img, skiatest::Reporter* reporter,
- bool peekPixelsSucceeds, bool peekTextureSucceeds,
- int offset, int size) {
+ bool peekPixelsSucceeds, bool peekTextureSucceeds) {
const SkIRect subset = TestingSpecialImageAccess::Subset(img);
- REPORTER_ASSERT(reporter, offset == subset.left());
- REPORTER_ASSERT(reporter, offset == subset.top());
+ REPORTER_ASSERT(reporter, kPad == subset.left());
+ REPORTER_ASSERT(reporter, kPad == subset.top());
REPORTER_ASSERT(reporter, kSmallerSize == subset.width());
REPORTER_ASSERT(reporter, kSmallerSize == subset.height());
@@ -66,8 +63,8 @@
REPORTER_ASSERT(reporter, peekPixelsSucceeds ==
!!TestingSpecialImageAccess::PeekPixels(img, &pixmap));
if (peekPixelsSucceeds) {
- REPORTER_ASSERT(reporter, size == pixmap.width());
- REPORTER_ASSERT(reporter, size == pixmap.height());
+ REPORTER_ASSERT(reporter, kFullSize == pixmap.width());
+ REPORTER_ASSERT(reporter, kFullSize == pixmap.height());
}
//--------------
@@ -98,22 +95,10 @@
DEF_TEST(SpecialImage_Raster, reporter) {
SkBitmap bm = create_bm();
- SkAutoTUnref<SkSpecialImage> fullSImage(SkSpecialImage::NewFromRaster(
- nullptr,
- SkIRect::MakeWH(kFullSize, kFullSize),
- bm));
-
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- {
- SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromRaster(nullptr, subset, bm));
- test_image(subSImg1, reporter, true, false, kPad, kFullSize);
- }
-
- {
- SkAutoTUnref<SkSpecialImage> subSImg2(fullSImage->extractSubset(subset));
- test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
- }
+ SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromRaster(nullptr, subset, bm));
+ test_image(img, reporter, true, false);
}
DEF_TEST(SpecialImage_Image, reporter) {
@@ -121,55 +106,11 @@
SkAutoTUnref<SkImage> fullImage(SkImage::NewFromBitmap(bm));
- SkAutoTUnref<SkSpecialImage> fullSImage(SkSpecialImage::NewFromImage(
- nullptr,
- SkIRect::MakeWH(kFullSize, kFullSize),
- fullImage));
-
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- {
- SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromImage(nullptr,
- subset,
- fullImage));
- test_image(subSImg1, reporter, true, false, kPad, kFullSize);
- }
-
- {
- SkAutoTUnref<SkSpecialImage> subSImg2(fullSImage->extractSubset(subset));
- test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
- }
+ SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromImage(nullptr, subset, fullImage));
+ test_image(img, reporter, true, false);
}
-
-DEF_TEST(SpecialImage_Pixmap, reporter) {
- SkAutoPixmapStorage pixmap;
-
- const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType);
- pixmap.alloc(info);
- pixmap.erase(SK_ColorGREEN);
-
- const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
-
- pixmap.erase(SK_ColorRED, subset);
-
- {
- // The SkAutoPixmapStorage keeps hold of the memory
- SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromPixmap(nullptr, subset, pixmap,
- nullptr, nullptr));
- test_image(img, reporter, true, false, kPad, kFullSize);
- }
-
- {
- // The image takes ownership of the memory
- SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromPixmap(
- nullptr, subset, pixmap,
- [] (void* addr, void*) -> void { sk_free(addr); },
- nullptr));
- pixmap.release();
- test_image(img, reporter, true, false, kPad, kFullSize);
- }
-}
-
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, context) {
@@ -187,26 +128,12 @@
return;
}
- SkAutoTUnref<SkSpecialImage> fullSImg(SkSpecialImage::NewFromGpu(
- nullptr,
- SkIRect::MakeWH(kFullSize, kFullSize),
- kNeedNewImageUniqueID_SpecialImage,
- texture));
-
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- {
- SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromGpu(
- nullptr, subset,
- kNeedNewImageUniqueID_SpecialImage,
- texture));
- test_image(subSImg1, reporter, false, true, kPad, kFullSize);
- }
-
- {
- SkAutoTUnref<SkSpecialImage> subSImg2(fullSImg->extractSubset(subset));
- test_image(subSImg2, reporter, false, true, kPad, kFullSize);
- }
+ SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromGpu(nullptr, subset,
+ kNeedNewImageUniqueID_SpecialImage,
+ texture));
+ test_image(img, reporter, false, true);
}
#endif
« no previous file with comments | « tests/ImageTest.cpp ('k') | tests/TestingSpecialImageAccess.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698