use drawRect when drawing a bitmap with anti-aliasing on a non-msaa target
If the dest isn't pixel aligned, or if a non 90 degree rotation is present, we need to use drawRect() for drawing anti-aliased bitmaps on non-msaa targets or the edges won't be anti-aliased as intended. Note: If the bitmap size is bigger than max texture size we fall back to drawBitmapCommon. Original-Author: Henry Song <henrysong@samsung.com> Review URL: https://codereview.chromium.org/649313003
This commit is contained in:
parent
8b896e71f6
commit
367e1867b2
@ -61,3 +61,5 @@ verylargebitmap
|
||||
multipicturedraw_sierpinski_simple
|
||||
multipicturedraw_sierpinski_tiled
|
||||
|
||||
#derekf
|
||||
drawbitmapmatrix
|
||||
|
@ -1063,7 +1063,40 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
||||
}
|
||||
}
|
||||
|
||||
if (paint.getMaskFilter()){
|
||||
// If the render target is not msaa and draw is antialiased, we call
|
||||
// drawRect instead of drawing on the render target directly.
|
||||
// FIXME: the tiled bitmap code path doesn't currently support
|
||||
// anti-aliased edges, we work around that for now by drawing directly
|
||||
// if the image size exceeds maximum texture size.
|
||||
int maxTextureSize = fContext->getMaxTextureSize();
|
||||
bool directDraw = fRenderTarget->isMultisampled() ||
|
||||
!paint.isAntiAlias() ||
|
||||
bitmap.width() > maxTextureSize ||
|
||||
bitmap.height() > maxTextureSize;
|
||||
|
||||
// we check whether dst rect are pixel aligned
|
||||
if (!directDraw) {
|
||||
bool staysRect = fContext->getMatrix().rectStaysRect();
|
||||
|
||||
if (staysRect) {
|
||||
SkRect rect;
|
||||
SkRect dstRect = SkRect::MakeXYWH(0, 0, dstSize.fWidth, dstSize.fHeight);
|
||||
fContext->getMatrix().mapRect(&rect, dstRect);
|
||||
const SkScalar *scalars = rect.asScalars();
|
||||
bool isDstPixelAligned = true;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!SkScalarIsInt(scalars[i])) {
|
||||
isDstPixelAligned = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isDstPixelAligned)
|
||||
directDraw = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (paint.getMaskFilter() || !directDraw) {
|
||||
// Convert the bitmap to a shader so that the rect can be drawn
|
||||
// through drawRect, which supports mask filters.
|
||||
SkBitmap tmp; // subset of bitmap, if necessary
|
||||
|
Loading…
Reference in New Issue
Block a user