aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDrawLooper.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-12 09:42:01 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-12 09:42:01 +0000
commit79fbb40bca9d815ef79b896b31ba6ee736817e0f (patch)
treee68a9d73abf9bdbef00d5facf6ca406a395527f7 /src/core/SkDrawLooper.cpp
parentad07e69d4cbd4924678f923d744dc01517bd6a78 (diff)
[WIP] Add Context to SkDrawLooper.
SkDrawLooper carries some state during draws. This CL extracts this state into a separate class Context, which is then passed by the users of SkDrawLooper into the appropriate methods. This is a step towards making SkDrawLooper immutable. BUG=skia:2141 R=scroggo@google.com, reed@google.com, sugoi@google.com Author: dominikg@chromium.org Review URL: https://codereview.chromium.org/155513012 git-svn-id: http://skia.googlecode.com/svn/trunk@13760 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkDrawLooper.cpp')
-rw-r--r--src/core/SkDrawLooper.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/core/SkDrawLooper.cpp b/src/core/SkDrawLooper.cpp
index bac2d969c0..c620cd08da 100644
--- a/src/core/SkDrawLooper.cpp
+++ b/src/core/SkDrawLooper.cpp
@@ -10,14 +10,17 @@
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkRect.h"
+#include "SkSmallAllocator.h"
-bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) {
+bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const {
SkCanvas canvas;
+ SkSmallAllocator<1, 32> allocator;
+ void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize());
- this->init(&canvas);
+ SkDrawLooper::Context* context = this->createContext(&canvas, buffer);
for (;;) {
SkPaint p(paint);
- if (this->next(&canvas, &p)) {
+ if (context->next(&canvas, &p)) {
p.setLooper(NULL);
if (!p.canComputeFastBounds()) {
return false;
@@ -30,14 +33,16 @@ bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) {
}
void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& src,
- SkRect* dst) {
+ SkRect* dst) const {
SkCanvas canvas;
+ SkSmallAllocator<1, 32> allocator;
+ void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize());
*dst = src; // catch case where there are no loops
- this->init(&canvas);
+ SkDrawLooper::Context* context = this->createContext(&canvas, buffer);
for (bool firstTime = true;; firstTime = false) {
SkPaint p(paint);
- if (this->next(&canvas, &p)) {
+ if (context->next(&canvas, &p)) {
SkRect r(src);
p.setLooper(NULL);