aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-14 10:06:42 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-14 10:06:42 +0000
commit74ba2f62dce1998bd6555291ab0a5330c276301d (patch)
tree556057da3c66e8f07bae380572e3742154bf04a9 /tests
parent02d6f546161e2c98d69066373cec3f54f3c46252 (diff)
Builder class for SkLayerDrawLooper.
SkLayerDrawLooper provides methods like addLayer() to build up a linked list of layers. Working towards making this class immutable, this patch introduces the SkLayerDrawLooperBuilder class which is used to accumulate all the layers first. Once all layers are in place, it creates a new SkLayerDrawLooper object and hands over the list of layers to that object. For now we keep the addLayer methods in SkLayerDrawLooper so we don't break Chrome and Blink when this is landed. Once we've updated all users, we can remove the methods. BUG=skia:2141 R=reed@google.com, scroggo@google.com, mtklein@google.com, reed@chromium.org Author: dominikg@chromium.org Review URL: https://codereview.chromium.org/133813005 git-svn-id: http://skia.googlecode.com/svn/trunk@13448 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/LayerDrawLooperTest.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/LayerDrawLooperTest.cpp b/tests/LayerDrawLooperTest.cpp
index a1319a50de..8f8a6b6eb0 100644
--- a/tests/LayerDrawLooperTest.cpp
+++ b/tests/LayerDrawLooperTest.cpp
@@ -35,21 +35,22 @@ private:
};
static void test_frontToBack(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkLayerDrawLooper> looper(SkNEW(SkLayerDrawLooper));
+ SkLayerDrawLooper::Builder looperBuilder;
SkLayerDrawLooper::LayerInfo layerInfo;
// Add the front layer, with the defaults.
- (void)looper->addLayer(layerInfo);
+ (void)looperBuilder.addLayer(layerInfo);
// Add the back layer, with some layer info set.
layerInfo.fOffset.set(10.0f, 20.0f);
layerInfo.fPaintBits |= SkLayerDrawLooper::kXfermode_Bit;
- SkPaint* layerPaint = looper->addLayer(layerInfo);
+ SkPaint* layerPaint = looperBuilder.addLayer(layerInfo);
layerPaint->setXfermodeMode(SkXfermode::kSrc_Mode);
FakeDevice device;
SkCanvas canvas(&device);
SkPaint paint;
+ SkAutoTUnref<SkLayerDrawLooper> looper(looperBuilder.detachLooper());
looper->init(&canvas);
// The back layer should come first.
@@ -72,21 +73,22 @@ static void test_frontToBack(skiatest::Reporter* reporter) {
}
static void test_backToFront(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkLayerDrawLooper> looper(SkNEW(SkLayerDrawLooper));
+ SkLayerDrawLooper::Builder looperBuilder;
SkLayerDrawLooper::LayerInfo layerInfo;
// Add the back layer, with the defaults.
- (void)looper->addLayerOnTop(layerInfo);
+ (void)looperBuilder.addLayerOnTop(layerInfo);
// Add the front layer, with some layer info set.
layerInfo.fOffset.set(10.0f, 20.0f);
layerInfo.fPaintBits |= SkLayerDrawLooper::kXfermode_Bit;
- SkPaint* layerPaint = looper->addLayerOnTop(layerInfo);
+ SkPaint* layerPaint = looperBuilder.addLayerOnTop(layerInfo);
layerPaint->setXfermodeMode(SkXfermode::kSrc_Mode);
FakeDevice device;
SkCanvas canvas(&device);
SkPaint paint;
+ SkAutoTUnref<SkLayerDrawLooper> looper(looperBuilder.detachLooper());
looper->init(&canvas);
// The back layer should come first.
@@ -109,21 +111,22 @@ static void test_backToFront(skiatest::Reporter* reporter) {
}
static void test_mixed(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkLayerDrawLooper> looper(SkNEW(SkLayerDrawLooper));
+ SkLayerDrawLooper::Builder looperBuilder;
SkLayerDrawLooper::LayerInfo layerInfo;
// Add the back layer, with the defaults.
- (void)looper->addLayer(layerInfo);
+ (void)looperBuilder.addLayer(layerInfo);
// Add the front layer, with some layer info set.
layerInfo.fOffset.set(10.0f, 20.0f);
layerInfo.fPaintBits |= SkLayerDrawLooper::kXfermode_Bit;
- SkPaint* layerPaint = looper->addLayerOnTop(layerInfo);
+ SkPaint* layerPaint = looperBuilder.addLayerOnTop(layerInfo);
layerPaint->setXfermodeMode(SkXfermode::kSrc_Mode);
FakeDevice device;
SkCanvas canvas(&device);
SkPaint paint;
+ SkAutoTUnref<SkLayerDrawLooper> looper(looperBuilder.detachLooper());
looper->init(&canvas);
// The back layer should come first.