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
This commit is contained in:
parent
d4993ff360
commit
8b79028d27
@ -70,6 +70,7 @@
|
||||
'<(skia_src_path)/core/SkDeviceProfile.cpp',
|
||||
'<(skia_src_path)/core/SkDither.cpp',
|
||||
'<(skia_src_path)/core/SkDraw.cpp',
|
||||
'<(skia_src_path)/core/SkDrawLooper.cpp',
|
||||
'<(skia_src_path)/core/SkDrawProcs.h',
|
||||
'<(skia_src_path)/core/SkEdgeBuilder.cpp',
|
||||
'<(skia_src_path)/core/SkEdgeClipper.cpp',
|
||||
|
57
src/core/SkDrawLooper.cpp
Normal file
57
src/core/SkDrawLooper.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user