blob: 7ef82a7ff6e504641e87706bf5cfeaaf3d2ec1fa [file] [log] [blame]
Chris Craikb565df12015-10-05 13:00:52 -07001/*
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 */
Chris Craik5e00c7c2016-07-06 16:10:09 -070016
17#pragma once
Chris Craikb565df12015-10-05 13:00:52 -070018
Nolan Scobie2163e412022-10-24 19:57:43 -040019#include <AutoBackendTextureRelease.h>
Chris Craik161f54b2015-11-05 11:08:52 -080020#include <DisplayList.h>
Chris Craikb565df12015-10-05 13:00:52 -070021#include <Matrix.h>
Greg Daniel98c78dad2017-01-04 14:45:56 -050022#include <Properties.h>
Chris Craik0a24b142015-10-19 17:10:19 -070023#include <Rect.h>
Chris Craikb565df12015-10-05 13:00:52 -070024#include <RenderNode.h>
sergeyvc1c54062016-10-19 18:47:26 -070025#include <hwui/Bitmap.h>
Stan Iliev500a0c32016-10-26 10:30:09 -040026#include <pipeline/skia/SkiaRecordingCanvas.h>
Derek Sollenberger28a4d992018-09-20 13:37:24 -040027#include <private/hwui/DrawGlInfo.h>
Chris Craik0a24b142015-10-19 17:10:19 -070028#include <renderstate/RenderState.h>
29#include <renderthread/RenderThread.h>
Chris Craikb565df12015-10-05 13:00:52 -070030
Kevin Lubick1175dc02022-02-28 12:41:27 -050031#include <SkBitmap.h>
32#include <SkColor.h>
33#include <SkImageInfo.h>
34#include <SkRefCnt.h>
35
John Reck283bb462018-12-13 16:40:14 -080036#include <gtest/gtest.h>
Chris Craikb565df12015-10-05 13:00:52 -070037#include <memory>
Stan Ilievaaa9e832019-09-17 14:07:23 -040038#include <unordered_map>
Chris Craikb565df12015-10-05 13:00:52 -070039
Kevin Lubick1175dc02022-02-28 12:41:27 -050040class SkCanvas;
41class SkMatrix;
42class SkPath;
43struct SkRect;
44
Chris Craikb565df12015-10-05 13:00:52 -070045namespace android {
46namespace uirenderer {
47
John Reck1bcacfd2017-11-03 10:12:19 -070048#define EXPECT_MATRIX_APPROX_EQ(a, b) EXPECT_TRUE(TestUtils::matricesAreApproxEqual(a, b))
Chris Craikb565df12015-10-05 13:00:52 -070049
John Reck1bcacfd2017-11-03 10:12:19 -070050#define EXPECT_RECT_APPROX_EQ(a, b) \
51 EXPECT_TRUE(MathUtils::areEqual((a).left, (b).left) && \
52 MathUtils::areEqual((a).top, (b).top) && \
53 MathUtils::areEqual((a).right, (b).right) && \
54 MathUtils::areEqual((a).bottom, (b).bottom));
Chris Craik6fe991e52015-10-20 09:39:42 -070055
John Reck1bcacfd2017-11-03 10:12:19 -070056#define EXPECT_CLIP_RECT(expRect, clipStatePtr) \
57 EXPECT_NE(nullptr, (clipStatePtr)) << "Op is unclipped"; \
58 if ((clipStatePtr)->mode == ClipMode::Rectangle) { \
59 EXPECT_EQ((expRect), reinterpret_cast<const ClipRect*>(clipStatePtr)->rect); \
60 } else { \
61 ADD_FAILURE() << "ClipState not a rect"; \
62 }
Greg Daniel98c78dad2017-01-04 14:45:56 -050063
Alec Mouri219997a2023-05-23 17:25:19 +000064#define INNER_PIPELINE_TEST(test_case_name, test_name, pipeline, functionCall) \
65 TEST(test_case_name, test_name##_##pipeline) { \
66 RenderPipelineType oldType = Properties::getRenderPipelineType(); \
67 Properties::overrideRenderPipelineType(RenderPipelineType::pipeline); \
68 functionCall; \
69 Properties::overrideRenderPipelineType(oldType); \
Greg Daniel98c78dad2017-01-04 14:45:56 -050070 };
71
Greg Daniel98c78dad2017-01-04 14:45:56 -050072#define INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name, pipeline) \
John Reck1bcacfd2017-11-03 10:12:19 -070073 INNER_PIPELINE_TEST(test_case_name, test_name, pipeline, \
74 TestUtils::runOnRenderThread( \
75 test_case_name##_##test_name##_RenderThreadTest::doTheThing))
Greg Daniel98c78dad2017-01-04 14:45:56 -050076
Chris Craik98787e62015-11-13 10:55:30 -080077/**
78 * Like gtest's TEST, but runs on the RenderThread, and 'renderThread' is passed, in top level scope
79 * (for e.g. accessing its RenderState)
80 */
Alec Mouri219997a2023-05-23 17:25:19 +000081#define RENDERTHREAD_TEST(test_case_name, test_name) \
82 class test_case_name##_##test_name##_RenderThreadTest { \
83 public: \
84 static void doTheThing(renderthread::RenderThread& renderThread); \
85 }; \
86 INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name, SkiaGL); \
87 /* Temporarily disabling Vulkan until we can figure out a way to stub out the driver */ \
88 /* INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name, SkiaVulkan); */ \
89 void test_case_name##_##test_name##_RenderThreadTest::doTheThing( \
John Reck1bcacfd2017-11-03 10:12:19 -070090 renderthread::RenderThread& renderThread)
Greg Daniel98c78dad2017-01-04 14:45:56 -050091
92/**
Greg Daniel98c78dad2017-01-04 14:45:56 -050093 * Like RENDERTHREAD_TEST, but only runs with the Skia RenderPipelineTypes
94 */
Alec Mouri219997a2023-05-23 17:25:19 +000095#define RENDERTHREAD_SKIA_PIPELINE_TEST(test_case_name, test_name) \
96 class test_case_name##_##test_name##_RenderThreadTest { \
97 public: \
98 static void doTheThing(renderthread::RenderThread& renderThread); \
99 }; \
100 INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name, SkiaGL); \
101 /* Temporarily disabling Vulkan until we can figure out a way to stub out the driver */ \
102 /* INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name, SkiaVulkan); */ \
103 void test_case_name##_##test_name##_RenderThreadTest::doTheThing( \
John Reck1bcacfd2017-11-03 10:12:19 -0700104 renderthread::RenderThread& renderThread)
Chris Craik98787e62015-11-13 10:55:30 -0800105
Chris Craik37413282016-05-12 17:48:51 -0700106/**
107 * Sets a property value temporarily, generally for the duration of a test, restoring the previous
108 * value when going out of scope.
109 *
110 * Can be used e.g. to test behavior only active while Properties::debugOverdraw is enabled.
111 */
112template <typename T>
113class ScopedProperty {
114public:
John Reck1bcacfd2017-11-03 10:12:19 -0700115 ScopedProperty(T& property, T newValue) : mPropertyPtr(&property), mOldValue(property) {
Chris Craik37413282016-05-12 17:48:51 -0700116 property = newValue;
117 }
John Reck1bcacfd2017-11-03 10:12:19 -0700118 ~ScopedProperty() { *mPropertyPtr = mOldValue; }
119
Chris Craik37413282016-05-12 17:48:51 -0700120private:
121 T* mPropertyPtr;
122 T mOldValue;
123};
124
Chris Craikb565df12015-10-05 13:00:52 -0700125class TestUtils {
126public:
Chris Craik76ace112015-10-29 12:46:19 -0700127 class SignalingDtor {
128 public:
John Reck1bcacfd2017-11-03 10:12:19 -0700129 SignalingDtor() : mSignal(nullptr) {}
130 explicit SignalingDtor(int* signal) : mSignal(signal) {}
131 void setSignal(int* signal) { mSignal = signal; }
Chris Craik76ace112015-10-29 12:46:19 -0700132 ~SignalingDtor() {
133 if (mSignal) {
134 (*mSignal)++;
135 }
136 }
John Reck1bcacfd2017-11-03 10:12:19 -0700137
Chris Craik76ace112015-10-29 12:46:19 -0700138 private:
139 int* mSignal;
140 };
141
John Reck2de950d2017-01-25 10:58:30 -0800142 class MockTreeObserver : public TreeObserver {
143 public:
144 virtual void onMaybeRemovedFromTree(RenderNode* node) {}
145 };
146
Chris Craikb565df12015-10-05 13:00:52 -0700147 static bool matricesAreApproxEqual(const Matrix4& a, const Matrix4& b) {
148 for (int i = 0; i < 16; i++) {
149 if (!MathUtils::areEqual(a[i], b[i])) {
150 return false;
151 }
152 }
153 return true;
154 }
155
sergeyvaed7f582016-10-14 16:30:21 -0700156 static sk_sp<Bitmap> createBitmap(int width, int height,
John Reck1bcacfd2017-11-03 10:12:19 -0700157 SkColorType colorType = kN32_SkColorType) {
sergeyvaed7f582016-10-14 16:30:21 -0700158 SkImageInfo info = SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType);
sergeyvfc9999502016-10-17 13:07:38 -0700159 return Bitmap::allocateHeapBitmap(info);
sergeyvaed7f582016-10-14 16:30:21 -0700160 }
161
162 static sk_sp<Bitmap> createBitmap(int width, int height, SkBitmap* outBitmap) {
163 SkImageInfo info = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
164 outBitmap->setInfo(info);
Leon Scroggins IIIf51a80d2017-07-12 10:46:35 -0400165 return Bitmap::allocateHeapBitmap(outBitmap);
sergeyvaed7f582016-10-14 16:30:21 -0700166 }
167
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800168 static sp<DeferredLayerUpdater> createTextureLayerUpdater(
Greg Daniel98c78dad2017-01-04 14:45:56 -0500169 renderthread::RenderThread& renderThread);
170
171 static sp<DeferredLayerUpdater> createTextureLayerUpdater(
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800172 renderthread::RenderThread& renderThread, uint32_t width, uint32_t height,
Chris Craik243e85b2016-03-25 15:26:11 -0700173 const SkMatrix& transform);
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800174
John Reck1bcacfd2017-11-03 10:12:19 -0700175 static sp<RenderNode> createNode(
176 int left, int top, int right, int bottom,
Stan Iliev06152cd2016-07-27 17:55:43 -0400177 std::function<void(RenderProperties& props, Canvas& canvas)> setup) {
Chris Craikb565df12015-10-05 13:00:52 -0700178 sp<RenderNode> node = new RenderNode();
John Reck16c9d6a2015-11-17 15:51:08 -0800179 RenderProperties& props = node->mutateStagingProperties();
180 props.setLeftTopRightBottom(left, top, right, bottom);
181 if (setup) {
John Reck1bcacfd2017-11-03 10:12:19 -0700182 std::unique_ptr<Canvas> canvas(
183 Canvas::create_recording_canvas(props.getWidth(), props.getHeight()));
Stan Iliev06152cd2016-07-27 17:55:43 -0400184 setup(props, *canvas.get());
John Reck2e48df32021-01-19 18:06:05 -0500185 canvas->finishRecording(node.get());
Stan Iliev06152cd2016-07-27 17:55:43 -0400186 }
187 node->setPropertyFieldsDirty(0xFFFFFFFF);
188 return node;
189 }
190
John Reck1bcacfd2017-11-03 10:12:19 -0700191 template <class RecordingCanvasType>
192 static sp<RenderNode> createNode(
193 int left, int top, int right, int bottom,
Stan Iliev06152cd2016-07-27 17:55:43 -0400194 std::function<void(RenderProperties& props, RecordingCanvasType& canvas)> setup) {
Stan Iliev06152cd2016-07-27 17:55:43 -0400195 sp<RenderNode> node = new RenderNode();
196 RenderProperties& props = node->mutateStagingProperties();
197 props.setLeftTopRightBottom(left, top, right, bottom);
198 if (setup) {
199 RecordingCanvasType canvas(props.getWidth(), props.getHeight());
John Reck16c9d6a2015-11-17 15:51:08 -0800200 setup(props, canvas);
John Reck2de950d2017-01-25 10:58:30 -0800201 node->setStagingDisplayList(canvas.finishRecording());
Chris Craik0b7e8242015-10-28 16:50:44 -0700202 }
John Reck16c9d6a2015-11-17 15:51:08 -0800203 node->setPropertyFieldsDirty(0xFFFFFFFF);
Chris Craik0b7e8242015-10-28 16:50:44 -0700204 return node;
205 }
Chris Craikb565df12015-10-05 13:00:52 -0700206
John Reck1bcacfd2017-11-03 10:12:19 -0700207 static void recordNode(RenderNode& node, std::function<void(Canvas&)> contentCallback) {
208 std::unique_ptr<Canvas> canvas(Canvas::create_recording_canvas(
John Reck283bb462018-12-13 16:40:14 -0800209 node.stagingProperties().getWidth(), node.stagingProperties().getHeight(), &node));
John Reck1bcacfd2017-11-03 10:12:19 -0700210 contentCallback(*canvas.get());
John Reck2e48df32021-01-19 18:06:05 -0500211 canvas->finishRecording(&node);
Chris Craikb565df12015-10-05 13:00:52 -0700212 }
213
John Reck1bcacfd2017-11-03 10:12:19 -0700214 static sp<RenderNode> createSkiaNode(
215 int left, int top, int right, int bottom,
216 std::function<void(RenderProperties& props, skiapipeline::SkiaRecordingCanvas& canvas)>
217 setup,
John Reckbe671952021-01-13 22:39:32 -0500218 const char* name = nullptr,
219 std::unique_ptr<skiapipeline::SkiaDisplayList> displayList = nullptr) {
Stan Iliev500a0c32016-10-26 10:30:09 -0400220 sp<RenderNode> node = new RenderNode();
221 if (name) {
222 node->setName(name);
223 }
224 RenderProperties& props = node->mutateStagingProperties();
225 props.setLeftTopRightBottom(left, top, right, bottom);
226 if (displayList) {
John Reckbe671952021-01-13 22:39:32 -0500227 node->setStagingDisplayList(DisplayList(std::move(displayList)));
Stan Iliev500a0c32016-10-26 10:30:09 -0400228 }
229 if (setup) {
230 std::unique_ptr<skiapipeline::SkiaRecordingCanvas> canvas(
John Reck1bcacfd2017-11-03 10:12:19 -0700231 new skiapipeline::SkiaRecordingCanvas(nullptr, props.getWidth(),
232 props.getHeight()));
Stan Iliev500a0c32016-10-26 10:30:09 -0400233 setup(props, *canvas.get());
John Reck2e48df32021-01-19 18:06:05 -0500234 canvas->finishRecording(node.get());
Stan Iliev500a0c32016-10-26 10:30:09 -0400235 }
236 node->setPropertyFieldsDirty(0xFFFFFFFF);
237 TestUtils::syncHierarchyPropertiesAndDisplayList(node);
238 return node;
239 }
240
Chris Craik8d1f2122015-11-24 16:40:09 -0800241 /**
242 * Forces a sync of a tree of RenderNode, such that every descendant will have its staging
243 * properties and DisplayList moved to the render copies.
244 *
245 * Note: does not check dirtiness bits, so any non-staging DisplayLists will be discarded.
246 * For this reason, this should generally only be called once on a tree.
247 */
Chris Craik161f54b2015-11-05 11:08:52 -0800248 static void syncHierarchyPropertiesAndDisplayList(sp<RenderNode>& node) {
249 syncHierarchyPropertiesAndDisplayListImpl(node.get());
Chris Craikb565df12015-10-05 13:00:52 -0700250 }
Chris Craik0a24b142015-10-19 17:10:19 -0700251
Chris Craik9cd1bbe2016-04-14 16:08:25 -0700252 static sp<RenderNode>& getSyncedNode(sp<RenderNode>& node) {
253 syncHierarchyPropertiesAndDisplayList(node);
254 return node;
John Reck7db5ffb2016-01-15 13:17:09 -0800255 }
256
Chris Craik0b7e8242015-10-28 16:50:44 -0700257 typedef std::function<void(renderthread::RenderThread& thread)> RtCallback;
Chris Craik0a24b142015-10-19 17:10:19 -0700258
259 class TestTask : public renderthread::RenderTask {
260 public:
John Reck1bcacfd2017-11-03 10:12:19 -0700261 explicit TestTask(RtCallback rtCallback) : rtCallback(rtCallback) {}
Chris Craik0a24b142015-10-19 17:10:19 -0700262 virtual ~TestTask() {}
John Recke5da4ef2016-01-14 12:34:46 -0800263 virtual void run() override;
Chris Craik0a24b142015-10-19 17:10:19 -0700264 RtCallback rtCallback;
265 };
266
267 /**
268 * NOTE: requires surfaceflinger to run, otherwise this method will wait indefinitely.
269 */
270 static void runOnRenderThread(RtCallback rtCallback) {
271 TestTask task(rtCallback);
John Reck1bcacfd2017-11-03 10:12:19 -0700272 renderthread::RenderThread::getInstance().queue().runSync([&]() { task.run(); });
Chris Craik0a24b142015-10-19 17:10:19 -0700273 }
John Reck16c9d6a2015-11-17 15:51:08 -0800274
John Reck283bb462018-12-13 16:40:14 -0800275 static void runOnRenderThreadUnmanaged(RtCallback rtCallback) {
276 auto& rt = renderthread::RenderThread::getInstance();
277 rt.queue().runSync([&]() { rtCallback(rt); });
278 }
279
280
John Reck1bcacfd2017-11-03 10:12:19 -0700281 static bool isRenderThreadRunning() { return renderthread::RenderThread::hasInstance(); }
John Reck283bb462018-12-13 16:40:14 -0800282 static pid_t getRenderThreadTid() { return renderthread::RenderThread::getInstance().getTid(); }
John Reck38e0c322015-11-10 12:19:17 -0800283
John Reck16c9d6a2015-11-17 15:51:08 -0800284 static SkColor interpolateColor(float fraction, SkColor start, SkColor end);
285
Mike Reedf6d86ac2019-01-18 14:13:23 -0500286 static void drawUtf8ToCanvas(Canvas* canvas, const char* text, const Paint& paint, float x,
John Reck1bcacfd2017-11-03 10:12:19 -0700287 float y);
Chris Craika1717272015-11-19 13:02:43 -0800288
Mike Reedf6d86ac2019-01-18 14:13:23 -0500289 static void drawUtf8ToCanvas(Canvas* canvas, const char* text, const Paint& paint,
John Reck1bcacfd2017-11-03 10:12:19 -0700290 const SkPath& path);
Chris Craikd7448e62015-12-15 10:34:36 -0800291
Derek Sollenberger79abbf22016-03-24 11:07:19 -0400292 static std::unique_ptr<uint16_t[]> asciiToUtf16(const char* str);
sergeyvdccca442016-03-21 15:38:21 -0700293
Stan Iliev021693b2016-10-17 16:26:15 -0400294 static SkColor getColor(const sk_sp<SkSurface>& surface, int x, int y);
295
Stan Iliev52771272016-11-17 09:54:38 -0500296 static SkRect getClipBounds(const SkCanvas* canvas);
297 static SkRect getLocalClipBounds(const SkCanvas* canvas);
298
Nolan Scobie2163e412022-10-24 19:57:43 -0400299 static int getUsageCount(const AutoBackendTextureRelease* textureRelease) {
300 EXPECT_NE(nullptr, textureRelease);
301 return textureRelease->mUsageCount;
302 }
303
John Reck283bb462018-12-13 16:40:14 -0800304 struct CallCounts {
305 int sync = 0;
306 int contextDestroyed = 0;
307 int destroyed = 0;
John Reckfaa1b0a2021-05-13 10:28:38 -0400308 int removeOverlays = 0;
John Reck283bb462018-12-13 16:40:14 -0800309 int glesDraw = 0;
John Reck20a4d682023-07-11 17:11:51 -0400310 int vkInitialize = 0;
311 int vkDraw = 0;
312 int vkPostDraw = 0;
John Reck283bb462018-12-13 16:40:14 -0800313 };
314
John Reckaa4c9822020-06-25 17:14:13 -0700315 static void expectOnRenderThread(const std::string_view& function = "unknown") {
316 EXPECT_EQ(gettid(), TestUtils::getRenderThreadTid()) << "Called on wrong thread: " << function;
317 }
John Reck283bb462018-12-13 16:40:14 -0800318
John Reck20a4d682023-07-11 17:11:51 -0400319 static int createMockFunctor() {
320 const auto renderMode = WebViewFunctor_queryPlatformRenderMode();
321 return WebViewFunctor_create(nullptr, createMockFunctorCallbacks(renderMode), renderMode);
322 }
323
324 static WebViewFunctorCallbacks createMockFunctorCallbacks(RenderMode mode) {
John Reck283bb462018-12-13 16:40:14 -0800325 auto callbacks = WebViewFunctorCallbacks{
326 .onSync =
Bo Liud6668e72018-12-14 19:37:41 -0800327 [](int functor, void* client_data, const WebViewSyncData& data) {
John Reckaa4c9822020-06-25 17:14:13 -0700328 expectOnRenderThread("onSync");
John Reck283bb462018-12-13 16:40:14 -0800329 sMockFunctorCounts[functor].sync++;
330 },
331 .onContextDestroyed =
Bo Liud6668e72018-12-14 19:37:41 -0800332 [](int functor, void* client_data) {
John Reckaa4c9822020-06-25 17:14:13 -0700333 expectOnRenderThread("onContextDestroyed");
John Reck283bb462018-12-13 16:40:14 -0800334 sMockFunctorCounts[functor].contextDestroyed++;
335 },
336 .onDestroyed =
Bo Liud6668e72018-12-14 19:37:41 -0800337 [](int functor, void* client_data) {
John Reckaa4c9822020-06-25 17:14:13 -0700338 expectOnRenderThread("onDestroyed");
John Reck283bb462018-12-13 16:40:14 -0800339 sMockFunctorCounts[functor].destroyed++;
340 },
John Reckfaa1b0a2021-05-13 10:28:38 -0400341 .removeOverlays =
342 [](int functor, void* data,
343 void (*mergeTransaction)(ASurfaceTransaction*)) {
344 expectOnRenderThread("removeOverlays");
345 sMockFunctorCounts[functor].removeOverlays++;
346 },
John Reck283bb462018-12-13 16:40:14 -0800347 };
348 switch (mode) {
349 case RenderMode::OpenGL_ES:
Vasiliy Telezhnikov6b237642020-11-12 18:14:58 -0500350 callbacks.gles.draw = [](int functor, void* client_data, const DrawGlInfo& params,
351 const WebViewOverlayData& overlay_params) {
John Reckaa4c9822020-06-25 17:14:13 -0700352 expectOnRenderThread("draw");
John Reck283bb462018-12-13 16:40:14 -0800353 sMockFunctorCounts[functor].glesDraw++;
354 };
355 break;
John Reck20a4d682023-07-11 17:11:51 -0400356 case RenderMode::Vulkan:
357 callbacks.vk.initialize = [](int functor, void* data,
358 const VkFunctorInitParams& params) {
359 expectOnRenderThread("initialize");
360 sMockFunctorCounts[functor].vkInitialize++;
361 };
362 callbacks.vk.draw = [](int functor, void* data, const VkFunctorDrawParams& params,
363 const WebViewOverlayData& overlayParams) {
364 expectOnRenderThread("draw");
365 sMockFunctorCounts[functor].vkDraw++;
366 };
367 callbacks.vk.postDraw = [](int functor, void* data) {
368 expectOnRenderThread("postDraw");
369 sMockFunctorCounts[functor].vkPostDraw++;
370 };
371 break;
John Reck283bb462018-12-13 16:40:14 -0800372 }
373 return callbacks;
374 }
375
376 static CallCounts& countsForFunctor(int functor) { return sMockFunctorCounts[functor]; }
377
Chris Craik161f54b2015-11-05 11:08:52 -0800378private:
John Reck283bb462018-12-13 16:40:14 -0800379 static std::unordered_map<int, CallCounts> sMockFunctorCounts;
380
Chris Craik161f54b2015-11-05 11:08:52 -0800381 static void syncHierarchyPropertiesAndDisplayListImpl(RenderNode* node) {
John Reck2de950d2017-01-25 10:58:30 -0800382 MarkAndSweepRemoved observer(nullptr);
Chris Craik161f54b2015-11-05 11:08:52 -0800383 node->syncProperties();
John Reck3afd6372017-01-30 10:15:48 -0800384 if (node->mNeedsDisplayListSync) {
385 node->mNeedsDisplayListSync = false;
386 node->syncDisplayList(observer, nullptr);
387 }
John Reckbe671952021-01-13 22:39:32 -0500388 auto& displayList = node->getDisplayList();
Chris Craik161f54b2015-11-05 11:08:52 -0800389 if (displayList) {
John Reckbe671952021-01-13 22:39:32 -0500390 displayList.updateChildren([](RenderNode* child) {
391 syncHierarchyPropertiesAndDisplayListImpl(child);
392 });
Chris Craik161f54b2015-11-05 11:08:52 -0800393 }
394 }
395
John Reck1bcacfd2017-11-03 10:12:19 -0700396}; // class TestUtils
Chris Craikb565df12015-10-05 13:00:52 -0700397
398} /* namespace uirenderer */
399} /* namespace android */