Optimize SkTileImageFilter in an offset filter when possible.
If the srcRect and dstRect have the same size, tiling will have the same effect as an offset filter cropped to the intersection of srcRect and dstRect. So do that instead. BUG=569950 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1578983002 Review URL: https://codereview.chromium.org/1578983002
This commit is contained in:
parent
c63a0f8fe5
commit
05dcb4c7a9
@ -9,6 +9,7 @@
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDevice.h"
|
||||
#include "SkOffsetImageFilter.h"
|
||||
#include "SkReadBuffer.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
#include "SkMatrix.h"
|
||||
@ -21,6 +22,16 @@ SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& ds
|
||||
if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height()) {
|
||||
SkRect ir = dstRect;
|
||||
if (!ir.intersect(srcRect)) {
|
||||
return SkSafeRef(input);
|
||||
}
|
||||
CropRect cropRect(ir);
|
||||
return SkOffsetImageFilter::Create(dstRect.x() - srcRect.x(),
|
||||
dstRect.y() - srcRect.y(),
|
||||
input, &cropRect);
|
||||
}
|
||||
return new SkTileImageFilter(srcRect, dstRect, input);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user