diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-24 14:57:53 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-24 14:57:53 +0000 |
commit | 8b79028d27653fafcde6901affba48b987b52e43 (patch) | |
tree | 1e185b7470401cfa0c60dd8329d55a6f21910347 /src | |
parent | d4993ff3605102036f83d5834d9a022d780e5488 (diff) |
Move SkDrawLooper implementation to its own file.
It previously lived in SkPaint.cpp.
BUG=
R=reed@google.com, tomhudson@chromium.org, jbroman@chromium.org
Author: jbroman@chromium.org
Review URL: https://chromiumcodereview.appspot.com/15896004
git-svn-id: http://skia.googlecode.com/svn/trunk@9272 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkDrawLooper.cpp | 57 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 48 |
2 files changed, 57 insertions, 48 deletions
diff --git a/src/core/SkDrawLooper.cpp b/src/core/SkDrawLooper.cpp new file mode 100644 index 0000000000..79a3f015f1 --- /dev/null +++ b/src/core/SkDrawLooper.cpp @@ -0,0 +1,57 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkDrawLooper.h" +#include "SkCanvas.h" +#include "SkMatrix.h" +#include "SkPaint.h" +#include "SkRect.h" + +SK_DEFINE_INST_COUNT(SkDrawLooper) + +bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) { + SkCanvas canvas; + + this->init(&canvas); + for (;;) { + SkPaint p(paint); + if (this->next(&canvas, &p)) { + p.setLooper(NULL); + if (!p.canComputeFastBounds()) { + return false; + } + } else { + break; + } + } + return true; +} + +void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& src, + SkRect* dst) { + SkCanvas canvas; + + this->init(&canvas); + for (bool firstTime = true;; firstTime = false) { + SkPaint p(paint); + if (this->next(&canvas, &p)) { + SkRect r(src); + + p.setLooper(NULL); + p.computeFastBounds(r, &r); + canvas.getTotalMatrix().mapRect(&r); + + if (firstTime) { + *dst = r; + } else { + dst->join(r); + } + } else { + break; + } + } +} diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index c7cbce18c7..f67395970b 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -2552,51 +2552,3 @@ bool SkPaint::nothingToDraw() const { } return false; } - - -//////////// Move these to their own file soon. - -SK_DEFINE_INST_COUNT(SkDrawLooper) - -bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) { - SkCanvas canvas; - - this->init(&canvas); - for (;;) { - SkPaint p(paint); - if (this->next(&canvas, &p)) { - p.setLooper(NULL); - if (!p.canComputeFastBounds()) { - return false; - } - } else { - break; - } - } - return true; -} - -void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& src, - SkRect* dst) { - SkCanvas canvas; - - this->init(&canvas); - for (bool firstTime = true;; firstTime = false) { - SkPaint p(paint); - if (this->next(&canvas, &p)) { - SkRect r(src); - - p.setLooper(NULL); - p.computeFastBounds(r, &r); - canvas.getTotalMatrix().mapRect(&r); - - if (firstTime) { - *dst = r; - } else { - dst->join(r); - } - } else { - break; - } - } -} |