diff options
author | Chris Craik <ccraik@google.com> | 2015-12-02 14:50:25 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-12-02 15:25:10 -0800 |
commit | 8160f20b0aca8c6595d4b385d673f59b6bcd16a4 (patch) | |
tree | 581bd7ae88d7ad352fc03e00d5175ccbfdd140bc /libs/hwui/tests/common/scenes/RectGridAnimation.cpp | |
parent | 54fa17f667c285a5c9225e238c8132dfe830ef36 (diff) |
Reorganize hwui test directories
Now test-only common files reside in tests/common, and each test
executable type (macrobench, microbench, and unit) has a subdir there.
This change means the shared lib no longer has test code in it, and
sets up a means for scenes to be shared between tests.
Change-Id: I37b081f6977300e03fdd961b8e6439fde730605e
Diffstat (limited to 'libs/hwui/tests/common/scenes/RectGridAnimation.cpp')
-rw-r--r-- | libs/hwui/tests/common/scenes/RectGridAnimation.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/libs/hwui/tests/common/scenes/RectGridAnimation.cpp b/libs/hwui/tests/common/scenes/RectGridAnimation.cpp new file mode 100644 index 000000000000..a1f04d67c785 --- /dev/null +++ b/libs/hwui/tests/common/scenes/RectGridAnimation.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "TestSceneBase.h" + +class RectGridAnimation; + +static Benchmark _RectGrid(BenchmarkInfo{ + "rectgrid", + "A dense grid of 1x1 rects that should visually look like a single rect. " + "Low CPU/GPU load.", + simpleCreateScene<RectGridAnimation> +}); + +class RectGridAnimation : public TestScene { +public: + sp<RenderNode> card; + void createContent(int width, int height, TestCanvas& canvas) override { + canvas.drawColor(0xFFFFFFFF, SkXfermode::kSrcOver_Mode); + canvas.insertReorderBarrier(true); + + card = TestUtils::createNode(50, 50, 250, 250, + [](RenderProperties& props, TestCanvas& canvas) { + canvas.drawColor(0xFFFF00FF, SkXfermode::kSrcOver_Mode); + + SkRegion region; + for (int xOffset = 0; xOffset < 200; xOffset+=2) { + for (int yOffset = 0; yOffset < 200; yOffset+=2) { + region.op(xOffset, yOffset, xOffset + 1, yOffset + 1, SkRegion::kUnion_Op); + } + } + + SkPaint paint; + paint.setColor(0xff00ffff); + canvas.drawRegion(region, paint); + }); + canvas.drawRenderNode(card.get()); + + canvas.insertReorderBarrier(false); + } + void doFrame(int frameNr) override { + int curFrame = frameNr % 150; + card->mutateStagingProperties().setTranslationX(curFrame); + card->mutateStagingProperties().setTranslationY(curFrame); + card->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y); + } +}; |