aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2017-12-19 09:18:59 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-19 14:51:26 +0000
commit1ad81981b0027e96ef0cecd78661ab2c22bdc4aa (patch)
tree40d0eac3564ee45234d11efc51566a3d2bcfa9f1 /samplecode
parent6613cc5186c200e053c5df9bd8f051ffba6e3564 (diff)
efficiently dash very large rectangles and very long lines
Speed up dashing when lines and rects are absurdly large. Prior to this CL, only horizontal lines were detected. The onOnceBeforeDraw changes are there to make debugging easier. Also folded in a change to handle dashing of zero length lines. R=reed@google.com, egdaniel@google.com Bug: skia:7311 Change-Id: Ia16fb124c7a78a5cc639e612fae29c879a37da1a Reviewed-on: https://skia-review.googlesource.com/84862 Commit-Queue: Cary Clark <caryclark@skia.org> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleAARects.cpp10
-rw-r--r--samplecode/SampleDither.cpp9
2 files changed, 12 insertions, 7 deletions
diff --git a/samplecode/SampleAARects.cpp b/samplecode/SampleAARects.cpp
index 942242b02e..c50c39f5af 100644
--- a/samplecode/SampleAARects.cpp
+++ b/samplecode/SampleAARects.cpp
@@ -39,14 +39,16 @@ class AARectView : public SampleView {
};
public:
AARectView() {
- fBitmap = createBitmap(N);
+ }
+protected:
+ void onOnceBeforeDraw() override {
+ fBitmap = createBitmap(N);
fWidth = N;
}
-protected:
// overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
+ bool onQuery(SkEvent* evt) override {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "AA Rects");
return true;
@@ -54,7 +56,7 @@ protected:
return this->INHERITED::onQuery(evt);
}
- virtual void onDrawContent(SkCanvas* canvas) {
+ void onDrawContent(SkCanvas* canvas) override {
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
SkPaint bluePaint;
diff --git a/samplecode/SampleDither.cpp b/samplecode/SampleDither.cpp
index fbe25ddcaa..79adc629fa 100644
--- a/samplecode/SampleDither.cpp
+++ b/samplecode/SampleDither.cpp
@@ -109,6 +109,10 @@ public:
SkScalar fAngle;
DitherView() {
+ }
+
+protected:
+ void onOnceBeforeDraw() override {
make_bm(&fBM);
make_bm(&fBMPreDither);
pre_dither(fBMPreDither);
@@ -119,9 +123,8 @@ public:
this->setBGColor(0xFF181818);
}
-protected:
// overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
+ bool onQuery(SkEvent* evt) override {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Dither");
return true;
@@ -129,7 +132,7 @@ protected:
return this->INHERITED::onQuery(evt);
}
- virtual void onDrawContent(SkCanvas* canvas) {
+ void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;
SkScalar x = SkIntToScalar(10);
SkScalar y = SkIntToScalar(10);