Begin kLegacyFontHost_InitType cleanup
This CL starts the process of pushing kLegacyFontHost_InitType-type SkSurfaceProps up the call stack and out of Skia. It: Gets rid of the default SkBaseDevice ctor. This means everyone has to always hand an explicit SkSurfaceProps to it. It makes public the SkBitmapDevice creation methods that require SkSurfaceProps. Removes (in Skia's code base) all SkBitmapDevice ctor calls w/o SkSurfaceProps. Makes the "recording" canvases (e.g., pdf, svg, xps) explicitly not use kLegacyFontHost_InitType. Replicates the creating canvas/device's flags on saveLayer devices BUG=skia:3934 Review URL: https://codereview.chromium.org/1204433002
This commit is contained in:
parent
462a33c7ac
commit
9a53fd7c41
@ -13,7 +13,7 @@
|
||||
|
||||
/** \class SkTrackDevice
|
||||
*
|
||||
* A Track Device is used to track that callstack of an operation that affected some pixels.
|
||||
* A Track Device is used to track the callstack of an operation that affected some pixels.
|
||||
* It can be used with SampleApp to investigate bugs (CL not checked in yet).
|
||||
*
|
||||
* every drawFoo is implemented as such:
|
||||
@ -22,12 +22,15 @@
|
||||
* after(); // - checks if pixels of interest, and issue a breakpoint.
|
||||
*
|
||||
*/
|
||||
// TODO: can this be derived from SkBaseDevice instead?
|
||||
class SkTrackDevice : public SkBitmapDevice {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkTrackDevice)
|
||||
|
||||
SkTrackDevice(const SkBitmap& bitmap) : SkBitmapDevice(bitmap)
|
||||
, fTracker(NULL) {}
|
||||
SkTrackDevice(const SkBitmap& bitmap)
|
||||
: INHERITED(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry))
|
||||
, fTracker(NULL) {
|
||||
}
|
||||
|
||||
virtual ~SkTrackDevice() {}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCommandLineFlags.h"
|
||||
#include "SkDevice.h"
|
||||
@ -121,8 +120,7 @@ static bool render_page(const SkString& outputDir,
|
||||
// Exercise all pdf codepaths as in normal rendering, but no actual bits are changed.
|
||||
if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) {
|
||||
SkBitmap bitmap;
|
||||
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
|
||||
SkNulCanvas canvas(device);
|
||||
SkNulCanvas canvas(bitmap);
|
||||
renderer.renderPage(page < 0 ? 0 : page, &canvas, rect);
|
||||
} else {
|
||||
// 8888
|
||||
@ -143,14 +141,11 @@ static bool render_page(const SkString& outputDir,
|
||||
setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height),
|
||||
background);
|
||||
#endif
|
||||
SkAutoTUnref<SkBaseDevice> device;
|
||||
if (strcmp(FLAGS_config[0], "8888") == 0) {
|
||||
device.reset(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
|
||||
} else {
|
||||
if (strcmp(FLAGS_config[0], "8888") != 0) {
|
||||
SkDebugf("unknown --config: %s\n", FLAGS_config[0]);
|
||||
return false;
|
||||
}
|
||||
SkCanvas canvas(device);
|
||||
SkCanvas canvas(bitmap);
|
||||
|
||||
#ifdef PDF_TRACE_DIFF_IN_PNG
|
||||
gDumpBitmap = &bitmap;
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkPdfRenderer.h"
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkDevice.h"
|
||||
@ -2910,8 +2909,7 @@ bool SkPDFNativeRenderToBitmap(SkStream* stream,
|
||||
|
||||
setup_bitmap(output, SkScalarCeilToInt(width), SkScalarCeilToInt(height));
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*output)));
|
||||
SkCanvas canvas(device);
|
||||
SkCanvas canvas(*output);
|
||||
|
||||
return renderer->renderPage(page, &canvas, rect);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "gm.h"
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkBitmapSource.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkRefCnt.h"
|
||||
@ -91,8 +90,7 @@ protected:
|
||||
bitmap.allocN32Pixels(16, 16);
|
||||
bitmap.eraseARGB(0x00, 0x00, 0x00, 0x00);
|
||||
{
|
||||
SkBitmapDevice bitmapDevice(bitmap);
|
||||
SkCanvas bitmapCanvas(&bitmapDevice);
|
||||
SkCanvas bitmapCanvas(bitmap);
|
||||
SkPaint paint;
|
||||
paint.setColor(0xFF00FF00);
|
||||
SkRect ovalRect = SkRect::MakeWH(16, 16);
|
||||
|
@ -20,21 +20,24 @@ public:
|
||||
* Construct a new device with the specified bitmap as its backend. It is
|
||||
* valid for the bitmap to have no pixels associated with it. In that case,
|
||||
* any drawing to this device will have no effect.
|
||||
*/
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap);
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Create a new device along with its requisite pixel memory using
|
||||
* default SkSurfaceProps (i.e., kLegacyFontHost_InitType-style).
|
||||
* Note: this entry point is slated for removal - no one should call it.
|
||||
*/
|
||||
static SkBitmapDevice* Create(const SkImageInfo& info);
|
||||
|
||||
/**
|
||||
* Construct a new device with the specified bitmap as its backend. It is
|
||||
* valid for the bitmap to have no pixels associated with it. In that case,
|
||||
* any drawing to this device will have no effect.
|
||||
*/
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps);
|
||||
private:
|
||||
static SkBitmapDevice* Create(const SkImageInfo&, const SkSurfaceProps*);
|
||||
public:
|
||||
static SkBitmapDevice* Create(const SkImageInfo& info) {
|
||||
return Create(info, NULL);
|
||||
}
|
||||
|
||||
static SkBitmapDevice* Create(const SkImageInfo&, const SkSurfaceProps&);
|
||||
|
||||
SkImageInfo imageInfo() const override;
|
||||
|
||||
|
@ -31,7 +31,6 @@ public:
|
||||
/**
|
||||
* Construct a new device.
|
||||
*/
|
||||
SkBaseDevice();
|
||||
explicit SkBaseDevice(const SkSurfaceProps&);
|
||||
virtual ~SkBaseDevice();
|
||||
|
||||
|
@ -33,8 +33,6 @@ public:
|
||||
*/
|
||||
static SkDeferredCanvas* Create(SkSurface* surface);
|
||||
|
||||
// static SkDeferredCanvas* Create(SkBaseDevice* device);
|
||||
|
||||
virtual ~SkDeferredCanvas();
|
||||
|
||||
/**
|
||||
|
@ -58,19 +58,24 @@ static bool valid_for_bitmap_device(const SkImageInfo& info,
|
||||
return true;
|
||||
}
|
||||
|
||||
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : fBitmap(bitmap) {
|
||||
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap)
|
||||
: INHERITED(SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType))
|
||||
, fBitmap(bitmap) {
|
||||
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
|
||||
}
|
||||
|
||||
SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) {
|
||||
return Create(info, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
}
|
||||
|
||||
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps)
|
||||
: SkBaseDevice(surfaceProps)
|
||||
, fBitmap(bitmap)
|
||||
{
|
||||
: INHERITED(surfaceProps)
|
||||
, fBitmap(bitmap) {
|
||||
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
|
||||
}
|
||||
|
||||
SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
|
||||
const SkSurfaceProps* surfaceProps) {
|
||||
const SkSurfaceProps& surfaceProps) {
|
||||
SkAlphaType newAT = origInfo.alphaType();
|
||||
if (!valid_for_bitmap_device(origInfo, &newAT)) {
|
||||
return NULL;
|
||||
@ -92,11 +97,7 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
|
||||
}
|
||||
}
|
||||
|
||||
if (surfaceProps) {
|
||||
return SkNEW_ARGS(SkBitmapDevice, (bitmap, *surfaceProps));
|
||||
} else {
|
||||
return SkNEW_ARGS(SkBitmapDevice, (bitmap));
|
||||
}
|
||||
return SkNEW_ARGS(SkBitmapDevice, (bitmap, surfaceProps));
|
||||
}
|
||||
|
||||
SkImageInfo SkBitmapDevice::imageInfo() const {
|
||||
@ -116,8 +117,8 @@ void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
|
||||
}
|
||||
|
||||
SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) {
|
||||
const SkSurfaceProps surfaceProps(0, cinfo.fPixelGeometry);
|
||||
return SkBitmapDevice::Create(cinfo.fInfo, &surfaceProps);
|
||||
const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixelGeometry);
|
||||
return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps);
|
||||
}
|
||||
|
||||
const SkBitmap& SkBitmapDevice::onAccessBitmap() {
|
||||
|
@ -1049,8 +1049,8 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
|
||||
SkBaseDevice* newDev = device->onCreateDevice(createInfo, paint);
|
||||
if (NULL == newDev) {
|
||||
// If onCreateDevice didn't succeed, try raster (e.g. PDF couldn't handle the paint)
|
||||
const SkSurfaceProps surfaceProps(0, createInfo.fPixelGeometry);
|
||||
newDev = SkBitmapDevice::Create(createInfo.fInfo, &surfaceProps);
|
||||
const SkSurfaceProps surfaceProps(fProps.flags(), createInfo.fPixelGeometry);
|
||||
newDev = SkBitmapDevice::Create(createInfo.fInfo, surfaceProps);
|
||||
if (NULL == newDev) {
|
||||
SkErrorInternals::SetError(kInternalError_SkError,
|
||||
"Unable to create device for layer.");
|
||||
|
@ -17,16 +17,6 @@
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextToPathIter.h"
|
||||
|
||||
SkBaseDevice::SkBaseDevice()
|
||||
: fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
|
||||
#ifdef SK_DEBUG
|
||||
, fAttachedToCanvas(false)
|
||||
#endif
|
||||
{
|
||||
fOrigin.setZero();
|
||||
fMetaData = NULL;
|
||||
}
|
||||
|
||||
SkBaseDevice::SkBaseDevice(const SkSurfaceProps& surfaceProps)
|
||||
: fSurfaceProps(surfaceProps)
|
||||
#ifdef SK_DEBUG
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "SkImageFilter.h"
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkChecksum.h"
|
||||
#include "SkDevice.h"
|
||||
#include "SkLazyPtr.h"
|
||||
@ -526,8 +527,6 @@ void SkImageFilter::PurgeCache() {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
|
||||
SkBaseDevice* SkImageFilter::Proxy::createDevice(int w, int h) {
|
||||
SkBaseDevice::CreateInfo cinfo(SkImageInfo::MakeN32Premul(w, h),
|
||||
SkBaseDevice::kNever_TileUsage,
|
||||
@ -535,7 +534,9 @@ SkBaseDevice* SkImageFilter::Proxy::createDevice(int w, int h) {
|
||||
true /*forImageFilter*/);
|
||||
SkBaseDevice* dev = fDevice->onCreateDevice(cinfo, NULL);
|
||||
if (NULL == dev) {
|
||||
dev = SkBitmapDevice::Create(cinfo.fInfo);
|
||||
const SkSurfaceProps surfaceProps(fDevice->fSurfaceProps.flags(),
|
||||
kUnknown_SkPixelGeometry);
|
||||
dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps);
|
||||
}
|
||||
return dev;
|
||||
}
|
||||
|
@ -112,10 +112,25 @@ static SkBitmap make_fake_bitmap(int width, int height) {
|
||||
|
||||
// TODO: should inherit from SkBaseDevice instead of SkBitmapDevice...
|
||||
SkXPSDevice::SkXPSDevice()
|
||||
: SkBitmapDevice(make_fake_bitmap(10000, 10000))
|
||||
: INHERITED(make_fake_bitmap(10000, 10000), SkSurfaceProps(0, kUnknown_SkPixelGeometry))
|
||||
, fCurrentPage(0) {
|
||||
}
|
||||
|
||||
SkXPSDevice::SkXPSDevice(IXpsOMObjectFactory* xpsFactory)
|
||||
: INHERITED(make_fake_bitmap(10000, 10000), SkSurfaceProps(0, kUnknown_SkPixelGeometry))
|
||||
, fCurrentPage(0) {
|
||||
|
||||
HRVM(CoCreateInstance(
|
||||
CLSID_XpsOMObjectFactory,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&this->fXpsFactory)),
|
||||
"Could not create factory for layer.");
|
||||
|
||||
HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas),
|
||||
"Could not create canvas for layer.");
|
||||
}
|
||||
|
||||
SkXPSDevice::~SkXPSDevice() {
|
||||
}
|
||||
|
||||
@ -2259,18 +2274,3 @@ SkBaseDevice* SkXPSDevice::onCreateDevice(const CreateInfo& info, const SkPaint*
|
||||
return new SkXPSDevice(this->fXpsFactory.get());
|
||||
}
|
||||
|
||||
SkXPSDevice::SkXPSDevice(IXpsOMObjectFactory* xpsFactory)
|
||||
: SkBitmapDevice(make_fake_bitmap(10000, 10000))
|
||||
, fCurrentPage(0) {
|
||||
|
||||
HRVM(CoCreateInstance(
|
||||
CLSID_XpsOMObjectFactory,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&this->fXpsFactory)),
|
||||
"Could not create factory for layer.");
|
||||
|
||||
HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas),
|
||||
"Could not create canvas for layer.");
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,8 @@ SkPDFDevice::SkPDFDevice(SkISize pageSize,
|
||||
SkScalar rasterDpi,
|
||||
SkPDFCanon* canon,
|
||||
bool flip)
|
||||
: fPageSize(pageSize)
|
||||
: INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry))
|
||||
, fPageSize(pageSize)
|
||||
, fContentSize(pageSize)
|
||||
, fExistingClipRegion(SkIRect::MakeSize(pageSize))
|
||||
, fAnnotations(NULL)
|
||||
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "SkAnnotation.h"
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkBitmapHeap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorFilter.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SamplePipeControllers.h"
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGPipe.h"
|
||||
#include "SkMatrix.h"
|
||||
@ -55,9 +54,7 @@ TiledPipeController::TiledPipeController(const SkBitmap& bitmap,
|
||||
|
||||
SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect);
|
||||
SkASSERT(extracted);
|
||||
SkBaseDevice* device = new SkBitmapDevice(fBitmaps[i]);
|
||||
SkCanvas* canvas = new SkCanvas(device);
|
||||
device->unref();
|
||||
SkCanvas* canvas = new SkCanvas(fBitmaps[i]);
|
||||
if (initial != NULL) {
|
||||
canvas->setMatrix(*initial);
|
||||
}
|
||||
|
@ -569,7 +569,8 @@ SkBaseDevice* SkSVGDevice::Create(const SkISize& size, SkXMLWriter* writer) {
|
||||
}
|
||||
|
||||
SkSVGDevice::SkSVGDevice(const SkISize& size, SkXMLWriter* writer)
|
||||
: fWriter(writer)
|
||||
: INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry))
|
||||
, fWriter(writer)
|
||||
, fResourceBucket(SkNEW(ResourceBucket)) {
|
||||
SkASSERT(writer);
|
||||
|
||||
|
@ -70,6 +70,8 @@ private:
|
||||
SkAutoTDelete<AutoElement> fRootElement;
|
||||
SkAutoTDelete<ResourceBucket> fResourceBucket;
|
||||
SkBitmap fLegacyBitmap;
|
||||
|
||||
typedef SkBaseDevice INHERITED;
|
||||
};
|
||||
|
||||
#endif // SkSVGDevice_DEFINED
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include "SkCanvasStateUtils.h"
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCanvasStack.h"
|
||||
#include "SkDevice.h"
|
||||
#include "SkErrorInternals.h"
|
||||
#include "SkWriter32.h"
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#include "SkDeferredCanvas.h"
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkChunkAlloc.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkDevice.h"
|
||||
#include "SkDrawFilter.h"
|
||||
#include "SkGPipe.h"
|
||||
#include "SkImage_Base.h"
|
||||
@ -283,9 +283,12 @@ private:
|
||||
bool fIsDrawingToLayer;
|
||||
size_t fMaxRecordingStorageBytes;
|
||||
size_t fPreviousStorageAllocated;
|
||||
|
||||
typedef SkBaseDevice INHERITED;
|
||||
};
|
||||
|
||||
SkDeferredDevice::SkDeferredDevice(SkSurface* surface) {
|
||||
SkDeferredDevice::SkDeferredDevice(SkSurface* surface)
|
||||
: INHERITED(surface->props()) {
|
||||
fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes;
|
||||
fNotificationClient = NULL;
|
||||
fImmediateCanvas = NULL;
|
||||
@ -537,6 +540,10 @@ private:
|
||||
};
|
||||
|
||||
SkDeferredCanvas* SkDeferredCanvas::Create(SkSurface* surface) {
|
||||
if (!surface) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkDeferredDevice> deferredDevice(SkNEW_ARGS(SkDeferredDevice, (surface)));
|
||||
return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice));
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "../src/image/SkImagePriv.h"
|
||||
#include "../src/image/SkSurface_Base.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkBitmapProcShader.h"
|
||||
#include "SkDeferredCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -440,19 +439,6 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
|
||||
}
|
||||
}
|
||||
|
||||
class MockDevice : public SkBitmapDevice {
|
||||
public:
|
||||
MockDevice(const SkBitmap& bm) : SkBitmapDevice(bm) {
|
||||
fDrawBitmapCallCount = 0;
|
||||
}
|
||||
virtual void drawBitmap(const SkDraw&, const SkBitmap&,
|
||||
const SkMatrix&, const SkPaint&) override {
|
||||
fDrawBitmapCallCount++;
|
||||
}
|
||||
|
||||
int fDrawBitmapCallCount;
|
||||
};
|
||||
|
||||
class NotificationCounter : public SkDeferredCanvas::NotificationClient {
|
||||
public:
|
||||
NotificationCounter() {
|
||||
|
@ -264,14 +264,13 @@ DEF_TEST(ImageFilter, reporter) {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter) {
|
||||
static void test_crop_rects(SkImageFilter::Proxy* proxy, skiatest::Reporter* reporter) {
|
||||
// Check that all filters offset to their absolute crop rect,
|
||||
// unaffected by the input crop rect.
|
||||
// Tests pass by not asserting.
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(100, 100);
|
||||
bitmap.eraseARGB(0, 0, 0, 0);
|
||||
SkImageFilter::Proxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
|
||||
SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80));
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60));
|
||||
@ -316,7 +315,7 @@ static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
|
||||
SkString str;
|
||||
str.printf("filter %d", static_cast<int>(i));
|
||||
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL);
|
||||
REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(&proxy, bitmap, ctx,
|
||||
REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(proxy, bitmap, ctx,
|
||||
&result, &offset), str.c_str());
|
||||
REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, str.c_str());
|
||||
}
|
||||
@ -347,11 +346,10 @@ static SkBitmap make_gradient_circle(int width, int height) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static void test_negative_blur_sigma(SkBaseDevice* device, skiatest::Reporter* reporter) {
|
||||
static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Reporter* reporter) {
|
||||
// Check that SkBlurImageFilter will accept a negative sigma, either in
|
||||
// the given arguments or after CTM application.
|
||||
int width = 32, height = 32;
|
||||
SkImageFilter::Proxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
SkScalar five = SkIntToScalar(5);
|
||||
|
||||
SkAutoTUnref<SkBlurImageFilter> positiveFilter(
|
||||
@ -367,13 +365,13 @@ static void test_negative_blur_sigma(SkBaseDevice* device, skiatest::Reporter* r
|
||||
SkBitmap positiveResult2, negativeResult2;
|
||||
SkIPoint offset;
|
||||
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL);
|
||||
positiveFilter->filterImage(&proxy, gradient, ctx, &positiveResult1, &offset);
|
||||
negativeFilter->filterImage(&proxy, gradient, ctx, &negativeResult1, &offset);
|
||||
positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset);
|
||||
negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset);
|
||||
SkMatrix negativeScale;
|
||||
negativeScale.setScale(-SK_Scalar1, SK_Scalar1);
|
||||
SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeLargest(), NULL);
|
||||
positiveFilter->filterImage(&proxy, gradient, negativeCTX, &negativeResult2, &offset);
|
||||
negativeFilter->filterImage(&proxy, gradient, negativeCTX, &positiveResult2, &offset);
|
||||
positiveFilter->filterImage(proxy, gradient, negativeCTX, &negativeResult2, &offset);
|
||||
negativeFilter->filterImage(proxy, gradient, negativeCTX, &positiveResult2, &offset);
|
||||
SkAutoLockPixels lockP1(positiveResult1);
|
||||
SkAutoLockPixels lockP2(positiveResult2);
|
||||
SkAutoLockPixels lockN1(negativeResult1);
|
||||
@ -398,10 +396,13 @@ static void test_negative_blur_sigma(SkBaseDevice* device, skiatest::Reporter* r
|
||||
}
|
||||
|
||||
DEF_TEST(TestNegativeBlurSigma, reporter) {
|
||||
SkBitmap temp;
|
||||
temp.allocN32Pixels(100, 100);
|
||||
SkBitmapDevice device(temp);
|
||||
test_negative_blur_sigma(&device, reporter);
|
||||
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
|
||||
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props));
|
||||
SkImageFilter::Proxy proxy(device, props);
|
||||
|
||||
test_negative_blur_sigma(&proxy, reporter);
|
||||
}
|
||||
|
||||
DEF_TEST(ImageFilterDrawTiled, reporter) {
|
||||
@ -768,17 +769,19 @@ DEF_TEST(ImageFilterMatrixConvolutionBorder, reporter) {
|
||||
}
|
||||
|
||||
DEF_TEST(ImageFilterCropRect, reporter) {
|
||||
SkBitmap temp;
|
||||
temp.allocN32Pixels(100, 100);
|
||||
SkBitmapDevice device(temp);
|
||||
test_crop_rects(&device, reporter);
|
||||
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
|
||||
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props));
|
||||
SkImageFilter::Proxy proxy(device, props);
|
||||
|
||||
test_crop_rects(&proxy, reporter);
|
||||
}
|
||||
|
||||
DEF_TEST(ImageFilterMatrix, reporter) {
|
||||
SkBitmap temp;
|
||||
temp.allocN32Pixels(100, 100);
|
||||
SkBitmapDevice device(temp);
|
||||
SkCanvas canvas(&device);
|
||||
SkCanvas canvas(temp);
|
||||
canvas.scale(SkIntToScalar(2), SkIntToScalar(2));
|
||||
|
||||
SkMatrix expectedMatrix = canvas.getTotalMatrix();
|
||||
@ -833,8 +836,7 @@ DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
|
||||
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(1, 1);
|
||||
SkBitmapDevice device(bitmap);
|
||||
SkCanvas canvas(&device);
|
||||
SkCanvas canvas(bitmap);
|
||||
|
||||
// The result here should be green, since the filter replaces the primitive's red interior.
|
||||
canvas.clear(0x0);
|
||||
@ -876,15 +878,14 @@ DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) {
|
||||
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint);
|
||||
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
|
||||
|
||||
SkAutoTUnref<SkImageFilter> imageFilter(
|
||||
SkPictureImageFilter::Create(picture.get()));
|
||||
SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture.get()));
|
||||
|
||||
SkBitmap result;
|
||||
SkIPoint offset;
|
||||
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), NULL);
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(2, 2);
|
||||
SkBitmapDevice device(bitmap);
|
||||
SkBitmapDevice device(bitmap, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &result, &offset));
|
||||
}
|
||||
@ -895,8 +896,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
|
||||
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(10, 10);
|
||||
SkBitmapDevice device(bitmap);
|
||||
SkCanvas canvas(&device);
|
||||
SkCanvas canvas(bitmap);
|
||||
|
||||
SkRTreeFactory factory;
|
||||
SkPictureRecorder recorder;
|
||||
@ -943,9 +943,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
|
||||
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
|
||||
}
|
||||
|
||||
static void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) {
|
||||
SkCanvas canvas(device);
|
||||
|
||||
static void test_huge_blur(SkCanvas* canvas, skiatest::Reporter* reporter) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(100, 100);
|
||||
bitmap.eraseARGB(0, 0, 0, 0);
|
||||
@ -955,14 +953,14 @@ static void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) {
|
||||
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(blur);
|
||||
canvas.drawSprite(bitmap, 0, 0, &paint);
|
||||
canvas->drawSprite(bitmap, 0, 0, &paint);
|
||||
}
|
||||
|
||||
DEF_TEST(HugeBlurImageFilter, reporter) {
|
||||
SkBitmap temp;
|
||||
temp.allocN32Pixels(100, 100);
|
||||
SkBitmapDevice device(temp);
|
||||
test_huge_blur(&device, reporter);
|
||||
SkCanvas canvas(temp);
|
||||
test_huge_blur(&canvas, reporter);
|
||||
}
|
||||
|
||||
DEF_TEST(MatrixConvolutionSanityTest, reporter) {
|
||||
@ -1019,9 +1017,8 @@ DEF_TEST(MatrixConvolutionSanityTest, reporter) {
|
||||
REPORTER_ASSERT(reporter, NULL == conv.get());
|
||||
}
|
||||
|
||||
static void test_xfermode_cropped_input(SkBaseDevice* device, skiatest::Reporter* reporter) {
|
||||
SkCanvas canvas(device);
|
||||
canvas.clear(0);
|
||||
static void test_xfermode_cropped_input(SkCanvas* canvas, skiatest::Reporter* reporter) {
|
||||
canvas->clear(0);
|
||||
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(1, 1);
|
||||
@ -1047,29 +1044,28 @@ static void test_xfermode_cropped_input(SkBaseDevice* device, skiatest::Reporter
|
||||
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(xfermodeNoFg);
|
||||
canvas.drawSprite(bitmap, 0, 0, &paint);
|
||||
canvas->drawSprite(bitmap, 0, 0, &paint);
|
||||
|
||||
uint32_t pixel;
|
||||
SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType);
|
||||
canvas.readPixels(info, &pixel, 4, 0, 0);
|
||||
canvas->readPixels(info, &pixel, 4, 0, 0);
|
||||
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
|
||||
|
||||
paint.setImageFilter(xfermodeNoBg);
|
||||
canvas.drawSprite(bitmap, 0, 0, &paint);
|
||||
canvas.readPixels(info, &pixel, 4, 0, 0);
|
||||
canvas->drawSprite(bitmap, 0, 0, &paint);
|
||||
canvas->readPixels(info, &pixel, 4, 0, 0);
|
||||
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
|
||||
|
||||
paint.setImageFilter(xfermodeNoFgNoBg);
|
||||
canvas.drawSprite(bitmap, 0, 0, &paint);
|
||||
canvas.readPixels(info, &pixel, 4, 0, 0);
|
||||
canvas->drawSprite(bitmap, 0, 0, &paint);
|
||||
canvas->readPixels(info, &pixel, 4, 0, 0);
|
||||
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
|
||||
}
|
||||
|
||||
DEF_TEST(ImageFilterNestedSaveLayer, reporter) {
|
||||
SkBitmap temp;
|
||||
temp.allocN32Pixels(50, 50);
|
||||
SkBitmapDevice device(temp);
|
||||
SkCanvas canvas(&device);
|
||||
SkCanvas canvas(temp);
|
||||
canvas.clear(0x0);
|
||||
|
||||
SkBitmap bitmap;
|
||||
@ -1119,15 +1115,15 @@ DEF_TEST(ImageFilterNestedSaveLayer, reporter) {
|
||||
DEF_TEST(XfermodeImageFilterCroppedInput, reporter) {
|
||||
SkBitmap temp;
|
||||
temp.allocN32Pixels(100, 100);
|
||||
SkBitmapDevice device(temp);
|
||||
test_xfermode_cropped_input(&device, reporter);
|
||||
SkCanvas canvas(temp);
|
||||
test_xfermode_cropped_input(&canvas, reporter);
|
||||
}
|
||||
|
||||
DEF_TEST(ComposedImageFilterOffset, reporter) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(100, 100);
|
||||
bitmap.eraseARGB(0, 0, 0, 0);
|
||||
SkBitmapDevice device(bitmap);
|
||||
SkBitmapDevice device(bitmap, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20));
|
||||
@ -1154,7 +1150,9 @@ DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {
|
||||
SkImageInfo::MakeN32Premul(100, 100),
|
||||
0,
|
||||
&gProps));
|
||||
test_crop_rects(device, reporter);
|
||||
SkImageFilter::Proxy proxy(device, gProps);
|
||||
|
||||
test_crop_rects(&proxy, reporter);
|
||||
}
|
||||
|
||||
DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) {
|
||||
@ -1167,7 +1165,9 @@ DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) {
|
||||
SkImageInfo::MakeN32Premul(100, 100),
|
||||
0,
|
||||
&gProps));
|
||||
test_huge_blur(device, reporter);
|
||||
SkCanvas canvas(device);
|
||||
|
||||
test_huge_blur(&canvas, reporter);
|
||||
}
|
||||
|
||||
DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) {
|
||||
@ -1180,7 +1180,9 @@ DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) {
|
||||
SkImageInfo::MakeN32Premul(1, 1),
|
||||
0,
|
||||
&gProps));
|
||||
test_xfermode_cropped_input(device, reporter);
|
||||
SkCanvas canvas(device);
|
||||
|
||||
test_xfermode_cropped_input(&canvas, reporter);
|
||||
}
|
||||
|
||||
DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) {
|
||||
@ -1193,6 +1195,8 @@ DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) {
|
||||
SkImageInfo::MakeN32Premul(1, 1),
|
||||
0,
|
||||
&gProps));
|
||||
test_negative_blur_sigma(device, reporter);
|
||||
SkImageFilter::Proxy proxy(device, gProps);
|
||||
|
||||
test_negative_blur_sigma(&proxy, reporter);
|
||||
}
|
||||
#endif
|
||||
|
@ -25,12 +25,13 @@ static SkBitmap make_bm(int w, int h) {
|
||||
return bm;
|
||||
}
|
||||
|
||||
// TODO: can this be derived from SkBaseDevice?
|
||||
class FakeDevice : public SkBitmapDevice {
|
||||
public:
|
||||
FakeDevice() : SkBitmapDevice(make_bm(100, 100)) { }
|
||||
FakeDevice() : INHERITED(make_bm(100, 100), SkSurfaceProps(0, kUnknown_SkPixelGeometry)) {
|
||||
}
|
||||
|
||||
virtual void drawRect(const SkDraw& draw, const SkRect& r,
|
||||
const SkPaint& paint) override {
|
||||
void drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) override {
|
||||
fLastMatrix = *draw.fMatrix;
|
||||
this->INHERITED::drawRect(draw, r, paint);
|
||||
}
|
||||
|
@ -74,10 +74,11 @@ DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) {
|
||||
glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt;
|
||||
}
|
||||
#endif
|
||||
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
|
||||
SkAutoTUnref<SkBaseDevice> device;
|
||||
if (0 == dtype) {
|
||||
device.reset(SkBitmapDevice::Create(info));
|
||||
device.reset(SkBitmapDevice::Create(info, props));
|
||||
} else {
|
||||
#if SK_SUPPORT_GPU
|
||||
GrContextFactory::GLContextType type =
|
||||
@ -89,7 +90,6 @@ DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) {
|
||||
if (NULL == ctx) {
|
||||
continue;
|
||||
}
|
||||
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
device.reset(SkGpuDevice::Create(ctx, SkSurface::kNo_Budgeted, info, 0, &props));
|
||||
#else
|
||||
continue;
|
||||
|
@ -5,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkMathPriv.h"
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkImagePriv.h"
|
||||
#include "Test.h"
|
||||
|
||||
@ -19,8 +19,7 @@ DEF_TEST(SkImageFromBitmap_extractSubset, reporter) {
|
||||
SkBitmap srcBitmap;
|
||||
srcBitmap.allocN32Pixels(gWidth, gHeight);
|
||||
srcBitmap.eraseColor(SK_ColorRED);
|
||||
SkBitmapDevice dev(srcBitmap);
|
||||
SkCanvas canvas(&dev);
|
||||
SkCanvas canvas(srcBitmap);
|
||||
SkIRect r = SkIRect::MakeXYWH(5, 5, gWidth - 5, gWidth - 5);
|
||||
SkPaint p;
|
||||
p.setColor(SK_ColorGREEN);
|
||||
@ -32,8 +31,7 @@ DEF_TEST(SkImageFromBitmap_extractSubset, reporter) {
|
||||
|
||||
SkBitmap tgt;
|
||||
tgt.allocN32Pixels(gWidth, gHeight);
|
||||
SkBitmapDevice dev(tgt);
|
||||
SkCanvas canvas(&dev);
|
||||
SkCanvas canvas(tgt);
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
canvas.drawImage(image, 0, 0, NULL);
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkMathPriv.h"
|
||||
|
Loading…
Reference in New Issue
Block a user