| John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 1 | /* |
| 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 Craik | d7448e6 | 2015-12-15 10:34:36 -0800 | [diff] [blame] | 18 | #include "utils/Color.h" |
| John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 19 | |
| 20 | class OvalAnimation; |
| 21 | |
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 22 | static TestScene::Registrar _Oval(TestScene::Info{"oval", "Draws 1 oval.", |
| 23 | TestScene::simpleCreateScene<OvalAnimation>}); |
| John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 24 | |
| 25 | class OvalAnimation : public TestScene { |
| 26 | public: |
| 27 | sp<RenderNode> card; |
| Stan Iliev | 06152cd | 2016-07-27 17:55:43 -0400 | [diff] [blame] | 28 | void createContent(int width, int height, Canvas& canvas) override { |
| Mike Reed | 260ab72 | 2016-10-07 15:59:20 -0400 | [diff] [blame] | 29 | canvas.drawColor(Color::White, SkBlendMode::kSrcOver); |
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 30 | card = TestUtils::createNode(0, 0, 200, 200, [](RenderProperties& props, Canvas& canvas) { |
| John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 31 | SkPaint paint; |
| 32 | paint.setAntiAlias(true); |
| Chris Craik | d7448e6 | 2015-12-15 10:34:36 -0800 | [diff] [blame] | 33 | paint.setColor(Color::Black); |
| John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 34 | canvas.drawOval(0, 0, 200, 200, paint); |
| 35 | }); |
| John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 36 | canvas.drawRenderNode(card.get()); |
| John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 37 | } |
| 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 | }; |