John Reck | 7db5ffb | 2016-01-15 13:17:09 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 "BakedOpRenderer.h" |
| 18 | #include "BakedOpDispatcher.h" |
| 19 | #include "FrameBuilder.h" |
| 20 | #include "LayerUpdateQueue.h" |
| 21 | #include "RecordingCanvas.h" |
| 22 | #include "tests/common/TestUtils.h" |
| 23 | |
| 24 | #include <gtest/gtest.h> |
| 25 | |
| 26 | using namespace android; |
| 27 | using namespace android::uirenderer; |
| 28 | |
| 29 | const LayerUpdateQueue sEmptyLayerUpdateQueue; |
Chris Craik | 6e068c01 | 2016-01-15 16:15:30 -0800 | [diff] [blame^] | 30 | const FrameBuilder::LightGeometry sLightGeometery = { {100, 100, 100}, 50}; |
| 31 | const BakedOpRenderer::LightInfo sLightInfo = { 128, 128 }; |
John Reck | 7db5ffb | 2016-01-15 13:17:09 -0800 | [diff] [blame] | 32 | |
| 33 | RENDERTHREAD_TEST(LeakCheck, saveLayerUnclipped_simple) { |
| 34 | auto node = TestUtils::createNode(0, 0, 200, 200, |
| 35 | [](RenderProperties& props, RecordingCanvas& canvas) { |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 36 | canvas.saveLayerAlpha(10, 10, 190, 190, 128, (SaveFlags::Flags)(0)); |
John Reck | 7db5ffb | 2016-01-15 13:17:09 -0800 | [diff] [blame] | 37 | canvas.drawRect(0, 0, 200, 200, SkPaint()); |
| 38 | canvas.restore(); |
| 39 | }); |
John Reck | 7db5ffb | 2016-01-15 13:17:09 -0800 | [diff] [blame] | 40 | RenderState& renderState = renderThread.renderState(); |
| 41 | Caches& caches = Caches::getInstance(); |
| 42 | |
| 43 | FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeWH(200, 200), 200, 200, |
Chris Craik | 6e068c01 | 2016-01-15 16:15:30 -0800 | [diff] [blame^] | 44 | TestUtils::createSyncedNodeList(node), sLightGeometery, nullptr); |
| 45 | BakedOpRenderer renderer(caches, renderState, true, sLightInfo); |
John Reck | 7db5ffb | 2016-01-15 13:17:09 -0800 | [diff] [blame] | 46 | frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer); |
| 47 | } |