Remove SK_LEGACY_XFORM_CANVAS_IN_PICTURE_IMAGES

Chrome no longer uses this.

Bug: skia:
Change-Id: I245c592a040cd113e9bd3ddd1e582d27070baee1
Reviewed-on: https://skia-review.googlesource.com/c/162740
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Brian Osman 2018-10-16 13:56:05 -04:00 committed by Skia Commit-Bot
parent cb3d087e71
commit af119e58dc

View File

@ -52,30 +52,13 @@ SkPictureImageGenerator::SkPictureImageGenerator(const SkImageInfo& info, sk_sp<
bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
const Options& opts) {
// TODO: Stop using xform canvas and simplify this code once rasterization works the same way
#ifdef SK_LEGACY_XFORM_CANVAS_IN_PICTURE_IMAGES
bool useXformCanvas = /* kIgnore == behavior && */ info.colorSpace();
#else
bool useXformCanvas = false;
#endif
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
SkImageInfo canvasInfo = useXformCanvas ? info.makeColorSpace(nullptr) : info;
std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(canvasInfo, pixels, rowBytes,
&props);
std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, pixels, rowBytes, &props);
if (!canvas) {
return false;
}
canvas->clear(0);
SkCanvas* canvasPtr = canvas.get();
std::unique_ptr<SkCanvas> xformCanvas;
if (useXformCanvas) {
xformCanvas = SkCreateColorSpaceXformCanvas(canvas.get(), info.refColorSpace());
canvasPtr = xformCanvas.get();
}
canvasPtr->drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
canvas->drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
return true;
}
@ -101,36 +84,19 @@ SkImageGenerator::MakeFromPicture(const SkISize& size, sk_sp<SkPicture> picture,
sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture(
GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, bool willNeedMipMaps) {
SkASSERT(ctx);
// TODO: Stop using xform canvas and simplify this code once rasterization works the same way
#ifdef SK_LEGACY_XFORM_CANVAS_IN_PICTURE_IMAGES
bool useXformCanvas = /* behavior == kIgnore && */ info.colorSpace();
#else
bool useXformCanvas = false;
#endif
//
// TODO: respect the usage, by possibly creating a different (pow2) surface
//
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
SkImageInfo surfaceInfo = useXformCanvas ? info.makeColorSpace(nullptr) : info;
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo,
0, kTopLeft_GrSurfaceOrigin, &props,
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, info, 0,
kTopLeft_GrSurfaceOrigin, &props,
willNeedMipMaps));
if (!surface) {
return nullptr;
}
SkCanvas* canvas = surface->getCanvas();
std::unique_ptr<SkCanvas> xformCanvas;
if (useXformCanvas) {
xformCanvas = SkCreateColorSpaceXformCanvas(canvas, info.refColorSpace());
canvas = xformCanvas.get();
}
SkMatrix matrix = fMatrix;
matrix.postTranslate(-origin.x(), -origin.y());
canvas->clear(0); // does NewRenderTarget promise to do this for us?
canvas->drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull());
surface->getCanvas()->clear(0);
surface->getCanvas()->drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull());
sk_sp<SkImage> image(surface->makeImageSnapshot());
if (!image) {
return nullptr;