optimize imageshaders to use clamp for dimension==1
Bug: skia: Change-Id: I12021acb5349bd139dceee8ce46de3cfd1ff4d28 Reviewed-on: https://skia-review.googlesource.com/20698 Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
6e554e3a10
commit
587d082f50
@ -18,11 +18,19 @@
|
||||
#include "SkWriteBuffer.h"
|
||||
#include "../jumper/SkJumper.h"
|
||||
|
||||
/**
|
||||
* We are faster in clamp, so always use that tiling when we can.
|
||||
*/
|
||||
static SkShader::TileMode optimize(SkShader::TileMode tm, int dimension) {
|
||||
SkASSERT(dimension > 0);
|
||||
return dimension == 1 ? SkShader::kClamp_TileMode : tm;
|
||||
}
|
||||
|
||||
SkImageShader::SkImageShader(sk_sp<SkImage> img, TileMode tmx, TileMode tmy, const SkMatrix* matrix)
|
||||
: INHERITED(matrix)
|
||||
, fImage(std::move(img))
|
||||
, fTileModeX(tmx)
|
||||
, fTileModeY(tmy)
|
||||
, fTileModeX(optimize(tmx, fImage->width()))
|
||||
, fTileModeY(optimize(tmy, fImage->height()))
|
||||
{}
|
||||
|
||||
sk_sp<SkFlattenable> SkImageShader::CreateProc(SkReadBuffer& buffer) {
|
||||
|
Loading…
Reference in New Issue
Block a user