2016-02-04 18:52:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file
|
|
|
|
*/
|
|
|
|
|
2016-03-17 13:58:39 +00:00
|
|
|
#include "SkAutoPixmapStorage.h"
|
2016-02-04 18:52:42 +00:00
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkImage.h"
|
2016-03-17 13:58:39 +00:00
|
|
|
#include "SkPixmap.h"
|
2016-02-04 18:52:42 +00:00
|
|
|
#include "SkSpecialImage.h"
|
|
|
|
#include "SkSpecialSurface.h"
|
2016-03-21 20:44:18 +00:00
|
|
|
#include "SkSurface.h"
|
2016-02-04 18:52:42 +00:00
|
|
|
#include "Test.h"
|
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
#include "GrBackendSurface.h"
|
2016-02-04 18:52:42 +00:00
|
|
|
#include "GrContext.h"
|
2018-01-08 18:40:32 +00:00
|
|
|
#include "GrContextPriv.h"
|
2018-01-16 13:06:32 +00:00
|
|
|
#include "GrProxyProvider.h"
|
2016-11-09 11:50:43 +00:00
|
|
|
#include "GrSurfaceProxy.h"
|
2017-03-09 03:21:00 +00:00
|
|
|
#include "GrTextureProxy.h"
|
2017-03-07 21:58:08 +00:00
|
|
|
#include "SkGr.h"
|
2016-02-04 18:52:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// This test creates backing resources exactly sized to [kFullSize x kFullSize].
|
|
|
|
// It then wraps them in an SkSpecialImage with only the center (red) region being active.
|
|
|
|
// It then draws the SkSpecialImage to a full sized (all blue) canvas and checks that none
|
|
|
|
// of the inactive (green) region leaked out.
|
|
|
|
|
|
|
|
static const int kSmallerSize = 10;
|
|
|
|
static const int kPad = 3;
|
|
|
|
static const int kFullSize = kSmallerSize + 2 * kPad;
|
|
|
|
|
|
|
|
// Create a bitmap with red in the center and green around it
|
|
|
|
static SkBitmap create_bm() {
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocN32Pixels(kFullSize, kFullSize, true);
|
|
|
|
|
|
|
|
SkCanvas temp(bm);
|
|
|
|
|
|
|
|
temp.clear(SK_ColorGREEN);
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorRED);
|
|
|
|
p.setAntiAlias(false);
|
|
|
|
|
|
|
|
temp.drawRect(SkRect::MakeXYWH(SkIntToScalar(kPad), SkIntToScalar(kPad),
|
2016-03-29 16:03:52 +00:00
|
|
|
SkIntToScalar(kSmallerSize), SkIntToScalar(kSmallerSize)),
|
2016-02-04 18:52:42 +00:00
|
|
|
p);
|
|
|
|
|
|
|
|
return bm;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw)
|
2016-03-17 21:31:39 +00:00
|
|
|
static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter,
|
2017-01-31 16:31:39 +00:00
|
|
|
GrContext* context, bool isGPUBacked,
|
2016-03-17 13:58:39 +00:00
|
|
|
int offset, int size) {
|
2016-04-20 18:48:36 +00:00
|
|
|
const SkIRect subset = img->subset();
|
2016-03-17 13:58:39 +00:00
|
|
|
REPORTER_ASSERT(reporter, offset == subset.left());
|
|
|
|
REPORTER_ASSERT(reporter, offset == subset.top());
|
2016-02-04 18:52:42 +00:00
|
|
|
REPORTER_ASSERT(reporter, kSmallerSize == subset.width());
|
|
|
|
REPORTER_ASSERT(reporter, kSmallerSize == subset.height());
|
|
|
|
|
|
|
|
//--------------
|
2017-02-21 15:19:29 +00:00
|
|
|
// Test that isTextureBacked reports the correct backing type
|
2017-01-31 16:31:39 +00:00
|
|
|
REPORTER_ASSERT(reporter, isGPUBacked == img->isTextureBacked());
|
2016-04-08 19:10:42 +00:00
|
|
|
|
|
|
|
//--------------
|
2017-02-19 17:27:01 +00:00
|
|
|
// Test asTextureProxyRef - as long as there is a context this should succeed
|
2016-04-08 19:10:42 +00:00
|
|
|
if (context) {
|
2017-02-19 17:27:01 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy(img->asTextureProxyRef(context));
|
|
|
|
REPORTER_ASSERT(reporter, proxy);
|
2016-04-08 19:10:42 +00:00
|
|
|
}
|
2016-02-04 18:52:42 +00:00
|
|
|
|
|
|
|
//--------------
|
2016-04-08 19:10:42 +00:00
|
|
|
// Test getROPixels - this should always succeed regardless of backing store
|
|
|
|
SkBitmap bitmap;
|
|
|
|
REPORTER_ASSERT(reporter, img->getROPixels(&bitmap));
|
2016-04-26 22:02:25 +00:00
|
|
|
if (context) {
|
|
|
|
REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width());
|
|
|
|
REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, size == bitmap.width());
|
|
|
|
REPORTER_ASSERT(reporter, size == bitmap.height());
|
|
|
|
}
|
2016-02-04 18:52:42 +00:00
|
|
|
|
|
|
|
//--------------
|
2016-03-21 20:44:18 +00:00
|
|
|
// Test that draw restricts itself to the subset
|
2018-07-06 17:57:01 +00:00
|
|
|
SkImageFilter::OutputProperties outProps(kN32_SkColorType, img->getColorSpace());
|
2016-09-23 20:04:05 +00:00
|
|
|
sk_sp<SkSpecialSurface> surf(img->makeSurface(outProps, SkISize::Make(kFullSize, kFullSize),
|
2017-01-17 15:48:53 +00:00
|
|
|
kPremul_SkAlphaType));
|
2016-02-04 18:52:42 +00:00
|
|
|
|
|
|
|
SkCanvas* canvas = surf->getCanvas();
|
|
|
|
|
|
|
|
canvas->clear(SK_ColorBLUE);
|
2016-02-16 20:09:36 +00:00
|
|
|
img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr);
|
2016-02-04 18:52:42 +00:00
|
|
|
|
|
|
|
SkBitmap bm;
|
2017-01-17 15:48:53 +00:00
|
|
|
bm.allocN32Pixels(kFullSize, kFullSize, false);
|
2016-02-04 18:52:42 +00:00
|
|
|
|
|
|
|
bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0, 0);
|
|
|
|
SkASSERT_RELEASE(result);
|
|
|
|
|
|
|
|
// Only the center (red) portion should've been drawn into the canvas
|
|
|
|
REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1));
|
|
|
|
REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad));
|
|
|
|
REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kSmallerSize+kPad-1,
|
|
|
|
kSmallerSize+kPad-1));
|
|
|
|
REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad,
|
|
|
|
kSmallerSize+kPad));
|
2016-03-21 20:44:18 +00:00
|
|
|
|
|
|
|
//--------------
|
2017-02-18 21:58:09 +00:00
|
|
|
// Test that asImage & makeTightSurface return appropriately sized objects
|
2016-03-21 20:44:18 +00:00
|
|
|
// of the correct backing type
|
|
|
|
SkIRect newSubset = SkIRect::MakeWH(subset.width(), subset.height());
|
|
|
|
{
|
2017-02-18 21:58:09 +00:00
|
|
|
sk_sp<SkImage> tightImg(img->asImage(&newSubset));
|
2016-03-21 20:44:18 +00:00
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, tightImg->width() == subset.width());
|
|
|
|
REPORTER_ASSERT(reporter, tightImg->height() == subset.height());
|
2017-03-21 20:22:00 +00:00
|
|
|
REPORTER_ASSERT(reporter, isGPUBacked == tightImg->isTextureBacked());
|
2016-03-21 20:44:18 +00:00
|
|
|
SkPixmap tmpPixmap;
|
2017-01-31 16:31:39 +00:00
|
|
|
REPORTER_ASSERT(reporter, isGPUBacked != !!tightImg->peekPixels(&tmpPixmap));
|
2016-03-21 20:44:18 +00:00
|
|
|
}
|
|
|
|
{
|
2018-07-06 17:57:01 +00:00
|
|
|
SkImageFilter::OutputProperties outProps(kN32_SkColorType, img->getColorSpace());
|
2016-09-23 20:04:05 +00:00
|
|
|
sk_sp<SkSurface> tightSurf(img->makeTightSurface(outProps, subset.size()));
|
2016-03-21 20:44:18 +00:00
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, tightSurf->width() == subset.width());
|
|
|
|
REPORTER_ASSERT(reporter, tightSurf->height() == subset.height());
|
2018-04-05 13:30:38 +00:00
|
|
|
GrBackendTexture backendTex = tightSurf->getBackendTexture(
|
|
|
|
SkSurface::kDiscardWrite_BackendHandleAccess);
|
|
|
|
REPORTER_ASSERT(reporter, isGPUBacked == backendTex.isValid());
|
2016-03-21 20:44:18 +00:00
|
|
|
SkPixmap tmpPixmap;
|
2017-01-31 16:31:39 +00:00
|
|
|
REPORTER_ASSERT(reporter, isGPUBacked != !!tightSurf->peekPixels(&tmpPixmap));
|
2016-03-21 20:44:18 +00:00
|
|
|
}
|
2016-02-04 18:52:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(SpecialImage_Raster, reporter) {
|
|
|
|
SkBitmap bm = create_bm();
|
|
|
|
|
2016-03-17 21:31:39 +00:00
|
|
|
sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromRaster(
|
2016-03-17 13:58:39 +00:00
|
|
|
SkIRect::MakeWH(kFullSize, kFullSize),
|
|
|
|
bm));
|
|
|
|
|
2016-02-04 18:52:42 +00:00
|
|
|
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
|
|
|
|
|
2016-03-17 13:58:39 +00:00
|
|
|
{
|
2016-04-20 18:48:36 +00:00
|
|
|
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(subset, bm));
|
2016-04-08 19:10:42 +00:00
|
|
|
test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
|
2016-03-17 13:58:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2016-03-17 21:31:39 +00:00
|
|
|
sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
|
2016-04-08 19:10:42 +00:00
|
|
|
test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize);
|
2016-03-17 13:58:39 +00:00
|
|
|
}
|
2016-02-04 18:52:42 +00:00
|
|
|
}
|
|
|
|
|
2018-10-12 16:01:22 +00:00
|
|
|
static void test_specialimage_image(skiatest::Reporter* reporter) {
|
2016-02-04 18:52:42 +00:00
|
|
|
SkBitmap bm = create_bm();
|
|
|
|
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm));
|
2016-02-04 18:52:42 +00:00
|
|
|
|
2016-03-17 21:31:39 +00:00
|
|
|
sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage(
|
2019-01-10 21:34:22 +00:00
|
|
|
nullptr,
|
2016-03-17 13:58:39 +00:00
|
|
|
SkIRect::MakeWH(kFullSize, kFullSize),
|
2018-10-12 16:01:22 +00:00
|
|
|
fullImage));
|
2016-03-17 13:58:39 +00:00
|
|
|
|
2016-02-04 18:52:42 +00:00
|
|
|
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
|
|
|
|
|
2016-03-17 13:58:39 +00:00
|
|
|
{
|
2019-01-10 21:34:22 +00:00
|
|
|
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(nullptr, subset, fullImage));
|
2016-04-26 22:02:25 +00:00
|
|
|
test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
|
2016-03-17 13:58:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2016-03-17 21:31:39 +00:00
|
|
|
sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
|
2016-04-26 22:02:25 +00:00
|
|
|
test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize);
|
2016-03-17 13:58:39 +00:00
|
|
|
}
|
2016-02-04 18:52:42 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 16:28:24 +00:00
|
|
|
DEF_TEST(SpecialImage_Image_Legacy, reporter) {
|
2018-10-12 16:01:22 +00:00
|
|
|
test_specialimage_image(reporter);
|
2016-11-18 16:28:24 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 15:14:27 +00:00
|
|
|
static void test_texture_backed(skiatest::Reporter* reporter,
|
|
|
|
const sk_sp<SkSpecialImage>& orig,
|
|
|
|
const sk_sp<SkSpecialImage>& gpuBacked) {
|
|
|
|
REPORTER_ASSERT(reporter, gpuBacked);
|
2016-04-08 19:10:42 +00:00
|
|
|
REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked());
|
2016-03-18 15:14:27 +00:00
|
|
|
REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID());
|
|
|
|
REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().width() &&
|
|
|
|
gpuBacked->subset().height() == orig->subset().height());
|
2016-07-21 14:15:37 +00:00
|
|
|
REPORTER_ASSERT(reporter, gpuBacked->getColorSpace() == orig->getColorSpace());
|
2016-03-18 15:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test out the SkSpecialImage::makeTextureImage entry point
|
2016-04-12 16:59:58 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) {
|
2016-05-11 13:33:06 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
2016-03-18 15:14:27 +00:00
|
|
|
SkBitmap bm = create_bm();
|
|
|
|
|
|
|
|
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
|
|
|
|
|
|
|
|
{
|
|
|
|
// raster
|
|
|
|
sk_sp<SkSpecialImage> rasterImage(SkSpecialImage::MakeFromRaster(
|
|
|
|
SkIRect::MakeWH(kFullSize,
|
|
|
|
kFullSize),
|
|
|
|
bm));
|
|
|
|
|
|
|
|
{
|
2016-04-20 18:48:36 +00:00
|
|
|
sk_sp<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(context));
|
2016-03-18 15:14:27 +00:00
|
|
|
test_texture_backed(reporter, rasterImage, fromRaster);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
sk_sp<SkSpecialImage> subRasterImage(rasterImage->makeSubset(subset));
|
|
|
|
|
2016-04-20 18:48:36 +00:00
|
|
|
sk_sp<SkSpecialImage> fromSubRaster(subRasterImage->makeTextureImage(context));
|
2016-03-18 15:14:27 +00:00
|
|
|
test_texture_backed(reporter, subRasterImage, fromSubRaster);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// gpu
|
2018-09-12 14:19:41 +00:00
|
|
|
sk_sp<SkImage> rasterImage = SkImage::MakeFromBitmap(bm);
|
|
|
|
sk_sp<GrTextureProxy> proxy =
|
|
|
|
proxyProvider->createTextureProxy(rasterImage, kNone_GrSurfaceFlags, 1,
|
|
|
|
SkBudgeted::kNo, SkBackingFit::kExact);
|
2017-03-02 23:18:38 +00:00
|
|
|
if (!proxy) {
|
2016-03-18 15:14:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-21 15:19:29 +00:00
|
|
|
sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeDeferredFromGpu(
|
2017-03-02 23:18:38 +00:00
|
|
|
context,
|
|
|
|
SkIRect::MakeWH(kFullSize, kFullSize),
|
|
|
|
kNeedNewImageUniqueID_SpecialImage,
|
|
|
|
std::move(proxy), nullptr));
|
2016-03-18 15:14:27 +00:00
|
|
|
|
|
|
|
{
|
2016-04-20 18:48:36 +00:00
|
|
|
sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context));
|
2016-03-18 15:14:27 +00:00
|
|
|
test_texture_backed(reporter, gpuImage, fromGPU);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset));
|
|
|
|
|
2016-04-20 18:48:36 +00:00
|
|
|
sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(context));
|
2016-03-18 15:14:27 +00:00
|
|
|
test_texture_backed(reporter, subGPUImage, fromSubGPU);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 16:59:58 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
|
2016-05-11 13:33:06 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
2016-02-04 18:52:42 +00:00
|
|
|
SkBitmap bm = create_bm();
|
2018-09-12 14:19:41 +00:00
|
|
|
sk_sp<SkImage> rasterImage = SkImage::MakeFromBitmap(bm);
|
2016-02-04 18:52:42 +00:00
|
|
|
|
2018-03-07 18:01:25 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy =
|
2018-09-12 14:19:41 +00:00
|
|
|
proxyProvider->createTextureProxy(rasterImage, kNone_GrSurfaceFlags, 1,
|
|
|
|
SkBudgeted::kNo, SkBackingFit::kExact);
|
2017-03-02 23:18:38 +00:00
|
|
|
if (!proxy) {
|
2016-02-04 18:52:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-01 21:28:40 +00:00
|
|
|
sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeDeferredFromGpu(
|
|
|
|
context,
|
|
|
|
SkIRect::MakeWH(kFullSize, kFullSize),
|
|
|
|
kNeedNewImageUniqueID_SpecialImage,
|
2017-03-02 23:18:38 +00:00
|
|
|
proxy, nullptr));
|
2016-11-01 21:28:40 +00:00
|
|
|
|
|
|
|
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
|
|
|
|
|
|
|
|
{
|
|
|
|
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu(
|
2017-03-02 23:18:38 +00:00
|
|
|
context, subset,
|
2016-11-01 21:28:40 +00:00
|
|
|
kNeedNewImageUniqueID_SpecialImage,
|
2017-03-02 23:18:38 +00:00
|
|
|
std::move(proxy), nullptr));
|
2016-11-01 21:28:40 +00:00
|
|
|
test_image(subSImg1, reporter, context, true, kPad, kFullSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset));
|
|
|
|
test_image(subSImg2, reporter, context, true, kPad, kFullSize);
|
|
|
|
}
|
|
|
|
}
|
2018-10-05 15:13:04 +00:00
|
|
|
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_ReadbackAndCachingSubsets_Gpu, reporter, ctxInfo) {
|
|
|
|
GrContext* context = ctxInfo.grContext();
|
|
|
|
SkImageInfo ii = SkImageInfo::Make(50, 50, kN32_SkColorType, kPremul_SkAlphaType);
|
|
|
|
auto surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii);
|
|
|
|
|
|
|
|
// Fill out our surface:
|
|
|
|
// Green | Blue
|
|
|
|
// Red | Green
|
|
|
|
{
|
|
|
|
surface->getCanvas()->clear(SK_ColorGREEN);
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorRED);
|
|
|
|
surface->getCanvas()->drawRect(SkRect::MakeXYWH(0, 25, 25, 25), p);
|
|
|
|
p.setColor(SK_ColorBLUE);
|
|
|
|
surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 0, 25, 25), p);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto image = surface->makeImageSnapshot();
|
2019-01-10 21:34:22 +00:00
|
|
|
auto redImg = SkSpecialImage::MakeFromImage(context, SkIRect::MakeXYWH(10, 30, 10, 10), image);
|
|
|
|
auto blueImg = SkSpecialImage::MakeFromImage(context, SkIRect::MakeXYWH(30, 10, 10, 10), image);
|
2018-10-05 15:13:04 +00:00
|
|
|
|
|
|
|
// This isn't necessary, but if it ever becomes false, then the cache collision bug that we're
|
|
|
|
// checking below is irrelevant.
|
|
|
|
REPORTER_ASSERT(reporter, redImg->uniqueID() == blueImg->uniqueID());
|
|
|
|
|
|
|
|
SkBitmap redBM, blueBM;
|
|
|
|
SkAssertResult(redImg->getROPixels(&redBM));
|
|
|
|
SkAssertResult(blueImg->getROPixels(&blueBM));
|
|
|
|
|
|
|
|
// Each image should read from the correct sub-rect. Past bugs (skbug.com/8448) have included:
|
|
|
|
// - Always reading back from (0, 0), producing green
|
|
|
|
// - Incorrectly hitting the cache on the 2nd read-back, causing blueBM to be red
|
|
|
|
REPORTER_ASSERT(reporter, redBM.getColor(0, 0) == SK_ColorRED,
|
|
|
|
"0x%08x != 0x%08x", redBM.getColor(0, 0), SK_ColorRED);
|
|
|
|
REPORTER_ASSERT(reporter, blueBM.getColor(0, 0) == SK_ColorBLUE,
|
|
|
|
"0x%08x != 0x%08x", blueBM.getColor(0, 0), SK_ColorBLUE);
|
|
|
|
}
|