-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Impl SkFilterOptions for raster-images
Maintains the old and new code-paths: - if the shader was made with explicit filteroptions, use those - if not, infer the filteroptions from the filterquality enum (and the legacy heuristics of sniffing/snapping the ctm) In either case, the bulk of the onProgram() is shared, driving off the (possibly computed locally) filteroptions. bench looks sort like we expect: 509.28 filteroptions_sampling_0_mipmap_0 8888 495.76 filteroptions_sampling_0_mipmap_1 8888 642.52 filteroptions_sampling_0_mipmap_2 8888 942.40 filteroptions_sampling_1_mipmap_0 8888 976.94 filteroptions_sampling_1_mipmap_1 8888 1686.34 filteroptions_sampling_1_mipmap_2 8888 Bug: skia:10344 Change-Id: I77a79f79f640986fdd6b14f163c1a03462c55dc0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297561 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
- Loading branch information
1 parent
9f82148
commit f8a6b5b
Showing
12 changed files
with
546 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2012 Google Inc. | ||
* | ||
* Use of this source code is governed by a BSD-style license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
|
||
#include "bench/Benchmark.h" | ||
#include "include/core/SkCanvas.h" | ||
#include "include/core/SkPaint.h" | ||
#include "include/core/SkShader.h" | ||
#include "include/core/SkString.h" | ||
#include "tools/Resources.h" | ||
|
||
class FilteringBench : public Benchmark { | ||
public: | ||
FilteringBench(SkFilterOptions options) : fOptions(options) { | ||
fName.printf("filteroptions_sampling_%d_mipmap_%d", | ||
(int)options.fSampling, (int)options.fMipmap); | ||
} | ||
|
||
protected: | ||
const char* onGetName() override { | ||
return fName.c_str(); | ||
} | ||
|
||
void onDelayedSetup() override { | ||
auto img = GetResourceAsImage("images/ship.png"); | ||
// need to force raster since lazy doesn't support filteroptions yet | ||
img = img->makeRasterImage(); | ||
|
||
fRect = SkRect::MakeIWH(img->width(), img->height()); | ||
fShader = img->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, fOptions); | ||
} | ||
|
||
void onDraw(int loops, SkCanvas* canvas) override { | ||
// scale so we will trigger lerping between levels if we mipmapping | ||
canvas->scale(0.75f, 0.75f); | ||
|
||
SkPaint paint; | ||
paint.setShader(fShader); | ||
for (int i = 0; i < loops; ++i) { | ||
for (int j = 0; j < 10; ++j) { | ||
canvas->drawRect(fRect, paint); | ||
} | ||
} | ||
} | ||
|
||
private: | ||
SkString fName; | ||
SkRect fRect; | ||
sk_sp<SkShader> fShader; | ||
SkFilterOptions fOptions; | ||
|
||
typedef Benchmark INHERITED; | ||
}; | ||
|
||
DEF_BENCH( return new FilteringBench({SkSamplingMode::kLinear, SkMipmapMode::kLinear}); ) | ||
DEF_BENCH( return new FilteringBench({SkSamplingMode::kLinear, SkMipmapMode::kNearest}); ) | ||
DEF_BENCH( return new FilteringBench({SkSamplingMode::kLinear, SkMipmapMode::kNone}); ) | ||
|
||
DEF_BENCH( return new FilteringBench({SkSamplingMode::kNearest, SkMipmapMode::kLinear}); ) | ||
DEF_BENCH( return new FilteringBench({SkSamplingMode::kNearest, SkMipmapMode::kNearest}); ) | ||
DEF_BENCH( return new FilteringBench({SkSamplingMode::kNearest, SkMipmapMode::kNone}); ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.