aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-04-11 15:50:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-12 00:12:00 +0000
commita00f34774712598cdee89b6a6fbdedb68cb9c193 (patch)
tree508121d63ad1a36a566084b117a7abdb4f29e70e /tests
parent921ebe5b736b068182ce5de1ab0e36add06d5e2c (diff)
switch over to no lockPixels in pixelref
Bug: skia:6481 Change-Id: I7c32d2e6dcd4c9cd8aa761ac5c4794c916eb650a Reviewed-on: https://skia-review.googlesource.com/13193 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/DrawBitmapRectTest.cpp41
-rw-r--r--tests/PDFInvalidBitmapTest.cpp63
2 files changed, 0 insertions, 104 deletions
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index 62da1c2af8..df410b2b00 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -19,46 +19,6 @@
#include "SkSurface.h"
#include "Test.h"
-class FailurePixelRef : public SkPixelRef {
-public:
- FailurePixelRef(const SkImageInfo& info) : SkPixelRef(info) {}
-protected:
- bool onNewLockPixels(LockRec*) override { return false; }
- void onUnlockPixels() override {}
-};
-
-// crbug.com/295895
-// Crashing in skia when a pixelref fails in lockPixels
-//
-static void test_faulty_pixelref(skiatest::Reporter* reporter) {
- // need a cache, but don't expect to use it, so the budget is not critical
- sk_sp<SkDiscardableMemoryPool> pool(
- SkDiscardableMemoryPool::Create(10 * 1000, nullptr));
-
- SkBitmap bm;
- const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- bm.setInfo(info);
- bm.setPixelRef(sk_make_sp<FailurePixelRef>(info), 0, 0);
- // now our bitmap has a pixelref, but we know it will fail to lock
-
- auto surface(SkSurface::MakeRasterN32Premul(200, 200));
- SkCanvas* canvas = surface->getCanvas();
-
- const SkFilterQuality levels[] = {
- kNone_SkFilterQuality,
- kLow_SkFilterQuality,
- kMedium_SkFilterQuality,
- kHigh_SkFilterQuality,
- };
-
- SkPaint paint;
- canvas->scale(2, 2); // need a scale, otherwise we may ignore filtering
- for (size_t i = 0; i < SK_ARRAY_COUNT(levels); ++i) {
- paint.setFilterQuality(levels[i]);
- canvas->drawBitmap(bm, 0, 0, &paint);
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
static void rand_matrix(SkMatrix* mat, SkRandom& rand, unsigned mask) {
@@ -308,5 +268,4 @@ DEF_TEST(DrawBitmapRect, reporter) {
test_giantrepeat_crbug118018(reporter);
test_treatAsSprite(reporter);
- test_faulty_pixelref(reporter);
}
diff --git a/tests/PDFInvalidBitmapTest.cpp b/tests/PDFInvalidBitmapTest.cpp
deleted file mode 100644
index 54acf02f40..0000000000
--- a/tests/PDFInvalidBitmapTest.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkBitmap.h"
-#include "SkCanvas.h"
-#include "SkDocument.h"
-#include "SkImageInfo.h"
-#include "SkPixelRef.h"
-#include "SkRefCnt.h"
-#include "SkStream.h"
-
-#include "Test.h"
-
-namespace {
-
-// SkPixelRef which fails to lock, as a lazy pixel ref might if its pixels
-// cannot be generated.
-class InvalidPixelRef : public SkPixelRef {
-public:
- InvalidPixelRef(const SkImageInfo& info) : SkPixelRef(info) {}
-private:
- bool onNewLockPixels(LockRec*) override { return false; }
- void onUnlockPixels() override {
- SkDEBUGFAIL("InvalidPixelRef can't be locked");
- }
-};
-
-SkBitmap make_invalid_bitmap(const SkImageInfo& imageInfo) {
- SkBitmap bitmap;
- bitmap.setInfo(imageInfo);
- bitmap.setPixelRef(sk_make_sp<InvalidPixelRef>(imageInfo), 0 ,0);
- return bitmap;
-}
-
-SkBitmap make_invalid_bitmap(SkColorType colorType) {
- return make_invalid_bitmap(
- SkImageInfo::Make(100, 100, colorType, kPremul_SkAlphaType));
-}
-
-} // namespace
-
-DEF_TEST(SkPDF_InvalidBitmap, reporter) {
- SkDynamicMemoryWStream stream;
- sk_sp<SkDocument> document(SkDocument::MakePDF(&stream));
- if (!document) {
- return;
- }
- SkCanvas* canvas = document->beginPage(100, 100);
-
- canvas->drawBitmap(SkBitmap(), 0, 0);
- canvas->drawBitmap(make_invalid_bitmap(SkImageInfo()), 0, 0);
- canvas->drawBitmap(make_invalid_bitmap(kN32_SkColorType), 0, 0);
- canvas->drawBitmap(make_invalid_bitmap(kIndex_8_SkColorType), 0, 0);
- canvas->drawBitmap(make_invalid_bitmap(kARGB_4444_SkColorType), 0, 0);
- canvas->drawBitmap(make_invalid_bitmap(kRGB_565_SkColorType), 0, 0);
- canvas->drawBitmap(make_invalid_bitmap(kAlpha_8_SkColorType), 0, 0);
-
- // This test passes if it does not crash.
-}