116c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck/* 216c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * Copyright (C) 2015 The Android Open Source Project 316c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * 416c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * Licensed under the Apache License, Version 2.0 (the "License"); 516c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * you may not use this file except in compliance with the License. 616c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * You may obtain a copy of the License at 716c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * 816c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * http://www.apache.org/licenses/LICENSE-2.0 916c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * 1016c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * Unless required by applicable law or agreed to in writing, software 1116c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * distributed under the License is distributed on an "AS IS" BASIS, 1216c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1316c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * See the License for the specific language governing permissions and 1416c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck * limitations under the License. 1516c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck */ 1616c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck 1716c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck#include "TestSceneBase.h" 1816c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck 1916c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reckclass ShadowGrid2Animation; 2016c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck 2127e58b4f54d693ff1db7ab2edb5d47ca296c1278Chris Craikstatic TestScene::Registrar _ShadowGrid2(TestScene::Info{ 2216c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck "shadowgrid2", 2316c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck "A dense grid of rounded rects that cast a shadow. This is a higher CPU load " 2416c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck "variant of shadowgrid. Very high CPU load, high GPU load.", 2527e58b4f54d693ff1db7ab2edb5d47ca296c1278Chris Craik TestScene::simpleCreateScene<ShadowGrid2Animation> 2616c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck}); 2716c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck 2816c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reckclass ShadowGrid2Animation : public TestScene { 2916c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reckpublic: 3016c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck std::vector< sp<RenderNode> > cards; 3116c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck void createContent(int width, int height, TestCanvas& canvas) override { 3216c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck canvas.drawColor(0xFFFFFFFF, SkXfermode::kSrcOver_Mode); 3316c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck canvas.insertReorderBarrier(true); 3416c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck 3516c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck for (int x = dp(8); x < (width - dp(58)); x += dp(58)) { 3616c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck for (int y = dp(8); y < (height - dp(58)); y += dp(58)) { 3716c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck sp<RenderNode> card = createCard(x, y, dp(50), dp(50)); 3816c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck canvas.drawRenderNode(card.get()); 3916c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck cards.push_back(card); 4016c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck } 4116c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck } 4216c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck 4316c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck canvas.insertReorderBarrier(false); 4416c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck } 4516c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck void doFrame(int frameNr) override { 4616c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck int curFrame = frameNr % 150; 4716c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck for (size_t ci = 0; ci < cards.size(); ci++) { 4816c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck cards[ci]->mutateStagingProperties().setTranslationX(curFrame); 4916c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck cards[ci]->mutateStagingProperties().setTranslationY(curFrame); 5016c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck cards[ci]->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y); 5116c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck } 5216c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck } 5316c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reckprivate: 5416c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck sp<RenderNode> createCard(int x, int y, int width, int height) { 5516c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck return TestUtils::createNode(x, y, x + width, y + height, 5616c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck [width, height](RenderProperties& props, TestCanvas& canvas) { 5716c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck props.setElevation(dp(16)); 5816c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck props.mutableOutline().setRoundRect(0, 0, width, height, dp(6), 1); 5916c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck props.mutableOutline().setShouldClip(true); 6016c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck canvas.drawColor(0xFFEEEEEE, SkXfermode::kSrcOver_Mode); 6116c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck }); 6216c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck } 6316c9d6a92e1b86d448c00c52a1630f3e71e6df76John Reck}; 64