blob: 4ff868b9d06803935da4e4036a6679949fae93a4 [file] [log] [blame]
John Reck16c9d6a2015-11-17 15:51:08 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "TestSceneBase.h"
Chris Craikd7448e62015-12-15 10:34:36 -080018#include "utils/Color.h"
John Reck16c9d6a2015-11-17 15:51:08 -080019
20class OvalAnimation;
21
John Reck1bcacfd2017-11-03 10:12:19 -070022static TestScene::Registrar _Oval(TestScene::Info{"oval", "Draws 1 oval.",
23 TestScene::simpleCreateScene<OvalAnimation>});
John Reck16c9d6a2015-11-17 15:51:08 -080024
25class OvalAnimation : public TestScene {
26public:
27 sp<RenderNode> card;
Stan Iliev06152cd2016-07-27 17:55:43 -040028 void createContent(int width, int height, Canvas& canvas) override {
Mike Reed260ab722016-10-07 15:59:20 -040029 canvas.drawColor(Color::White, SkBlendMode::kSrcOver);
John Reck1bcacfd2017-11-03 10:12:19 -070030 card = TestUtils::createNode(0, 0, 200, 200, [](RenderProperties& props, Canvas& canvas) {
John Reck16c9d6a2015-11-17 15:51:08 -080031 SkPaint paint;
32 paint.setAntiAlias(true);
Chris Craikd7448e62015-12-15 10:34:36 -080033 paint.setColor(Color::Black);
John Reck16c9d6a2015-11-17 15:51:08 -080034 canvas.drawOval(0, 0, 200, 200, paint);
35 });
John Reck16c9d6a2015-11-17 15:51:08 -080036 canvas.drawRenderNode(card.get());
John Reck16c9d6a2015-11-17 15:51:08 -080037 }
38
39 void doFrame(int frameNr) override {
40 int curFrame = frameNr % 150;
41 card->mutateStagingProperties().setTranslationX(curFrame);
42 card->mutateStagingProperties().setTranslationY(curFrame);
43 card->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y);
44 }
45};