blob: 8ab2b16601c38b508807df1af3ce57c8db8510ea [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>
Kevin Lubick09a77092023-10-31 14:58:26 +000033#include <SkFont.h>
Kevin Lubick1175dc02022-02-28 12:41:27 -050034#include <SkImageInfo.h>
35#include <SkRefCnt.h>
36
John Reck283bb462018-12-13 16:40:14 -080037#include <gtest/gtest.h>
Chris Craikb565df12015-10-05 13:00:52 -070038#include <memory>
Stan Ilievaaa9e832019-09-17 14:07:23 -040039#include <unordered_map>
Chris Craikb565df12015-10-05 13:00:52 -070040
Kevin Lubick1175dc02022-02-28 12:41:27 -050041class SkCanvas;
42class SkMatrix;
43class SkPath;
44struct SkRect;
45
Chris Craikb565df12015-10-05 13:00:52 -070046namespace android {
47namespace uirenderer {
48
John Reck1bcacfd2017-11-03 10:12:19 -070049#define EXPECT_MATRIX_APPROX_EQ(a, b) EXPECT_TRUE(TestUtils::matricesAreApproxEqual(a, b))
Chris Craikb565df12015-10-05 13:00:52 -070050
John Reck1bcacfd2017-11-03 10:12:19 -070051#define EXPECT_RECT_APPROX_EQ(a, b) \
52 EXPECT_TRUE(MathUtils::areEqual((a).left, (b).left) && \
53 MathUtils::areEqual((a).top, (b).top) && \
54 MathUtils::areEqual((a).right, (b).right) && \
55 MathUtils::areEqual((a).bottom, (b).bottom));
Chris Craik6fe991e52015-10-20 09:39:42 -070056
John Reck1bcacfd2017-11-03 10:12:19 -070057#define EXPECT_CLIP_RECT(expRect, clipStatePtr) \
58 EXPECT_NE(nullptr, (clipStatePtr)) << "Op is unclipped"; \
59 if ((clipStatePtr)->mode == ClipMode::Rectangle) { \
60 EXPECT_EQ((expRect), reinterpret_cast<const ClipRect*>(clipStatePtr)->rect); \
61 } else { \
62 ADD_FAILURE() << "ClipState not a rect"; \
63 }
Greg Daniel98c78dad2017-01-04 14:45:56 -050064
John Reck1efef7b2023-07-17 23:29:30 -040065#define INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name) \
66 TEST(test_case_name, test_name) { \
67 TestUtils::runOnRenderThread(test_case_name##_##test_name##_RenderThreadTest::doTheThing); \
68 }
Greg Daniel98c78dad2017-01-04 14:45:56 -050069
Chris Craik98787e62015-11-13 10:55:30 -080070/**
71 * Like gtest's TEST, but runs on the RenderThread, and 'renderThread' is passed, in top level scope
72 * (for e.g. accessing its RenderState)
73 */
Alec Mouri219997a2023-05-23 17:25:19 +000074#define RENDERTHREAD_TEST(test_case_name, test_name) \
75 class test_case_name##_##test_name##_RenderThreadTest { \
76 public: \
77 static void doTheThing(renderthread::RenderThread& renderThread); \
78 }; \
John Reck1efef7b2023-07-17 23:29:30 -040079 INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name); \
Alec Mouri219997a2023-05-23 17:25:19 +000080 /* Temporarily disabling Vulkan until we can figure out a way to stub out the driver */ \
81 /* INNER_PIPELINE_RENDERTHREAD_TEST(test_case_name, test_name, SkiaVulkan); */ \
82 void test_case_name##_##test_name##_RenderThreadTest::doTheThing( \
John Reck1bcacfd2017-11-03 10:12:19 -070083 renderthread::RenderThread& renderThread)
Chris Craik98787e62015-11-13 10:55:30 -080084
Chris Craik37413282016-05-12 17:48:51 -070085/**
86 * Sets a property value temporarily, generally for the duration of a test, restoring the previous
87 * value when going out of scope.
88 *
89 * Can be used e.g. to test behavior only active while Properties::debugOverdraw is enabled.
90 */
91template <typename T>
92class ScopedProperty {
93public:
John Reck1bcacfd2017-11-03 10:12:19 -070094 ScopedProperty(T& property, T newValue) : mPropertyPtr(&property), mOldValue(property) {
Chris Craik37413282016-05-12 17:48:51 -070095 property = newValue;
96 }
John Reck1bcacfd2017-11-03 10:12:19 -070097 ~ScopedProperty() { *mPropertyPtr = mOldValue; }
98
Chris Craik37413282016-05-12 17:48:51 -070099private:
100 T* mPropertyPtr;
101 T mOldValue;
102};
103
Chris Craikb565df12015-10-05 13:00:52 -0700104class TestUtils {
105public:
Chris Craik76ace112015-10-29 12:46:19 -0700106 class SignalingDtor {
107 public:
John Reck1bcacfd2017-11-03 10:12:19 -0700108 SignalingDtor() : mSignal(nullptr) {}
109 explicit SignalingDtor(int* signal) : mSignal(signal) {}
110 void setSignal(int* signal) { mSignal = signal; }
Chris Craik76ace112015-10-29 12:46:19 -0700111 ~SignalingDtor() {
112 if (mSignal) {
113 (*mSignal)++;
114 }
115 }
John Reck1bcacfd2017-11-03 10:12:19 -0700116
Chris Craik76ace112015-10-29 12:46:19 -0700117 private:
118 int* mSignal;
119 };
120
John Reck2de950d2017-01-25 10:58:30 -0800121 class MockTreeObserver : public TreeObserver {
122 public:
123 virtual void onMaybeRemovedFromTree(RenderNode* node) {}
124 };
125
Chris Craikb565df12015-10-05 13:00:52 -0700126 static bool matricesAreApproxEqual(const Matrix4& a, const Matrix4& b) {
127 for (int i = 0; i < 16; i++) {
128 if (!MathUtils::areEqual(a[i], b[i])) {
129 return false;
130 }
131 }
132 return true;
133 }
134
sergeyvaed7f582016-10-14 16:30:21 -0700135 static sk_sp<Bitmap> createBitmap(int width, int height,
John Reck1bcacfd2017-11-03 10:12:19 -0700136 SkColorType colorType = kN32_SkColorType) {
sergeyvaed7f582016-10-14 16:30:21 -0700137 SkImageInfo info = SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType);
sergeyvfc9999502016-10-17 13:07:38 -0700138 return Bitmap::allocateHeapBitmap(info);
sergeyvaed7f582016-10-14 16:30:21 -0700139 }
140
141 static sk_sp<Bitmap> createBitmap(int width, int height, SkBitmap* outBitmap) {
142 SkImageInfo info = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
143 outBitmap->setInfo(info);
Leon Scroggins IIIf51a80d2017-07-12 10:46:35 -0400144 return Bitmap::allocateHeapBitmap(outBitmap);
sergeyvaed7f582016-10-14 16:30:21 -0700145 }
146
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800147 static sp<DeferredLayerUpdater> createTextureLayerUpdater(
Greg Daniel98c78dad2017-01-04 14:45:56 -0500148 renderthread::RenderThread& renderThread);
149
150 static sp<DeferredLayerUpdater> createTextureLayerUpdater(
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800151 renderthread::RenderThread& renderThread, uint32_t width, uint32_t height,
Chris Craik243e85b2016-03-25 15:26:11 -0700152 const SkMatrix& transform);
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800153
John Reck1bcacfd2017-11-03 10:12:19 -0700154 static sp<RenderNode> createNode(
155 int left, int top, int right, int bottom,
Stan Iliev06152cd2016-07-27 17:55:43 -0400156 std::function<void(RenderProperties& props, Canvas& canvas)> setup) {
Chris Craikb565df12015-10-05 13:00:52 -0700157 sp<RenderNode> node = new RenderNode();
John Reck16c9d6a2015-11-17 15:51:08 -0800158 RenderProperties& props = node->mutateStagingProperties();
159 props.setLeftTopRightBottom(left, top, right, bottom);
160 if (setup) {
John Reck1bcacfd2017-11-03 10:12:19 -0700161 std::unique_ptr<Canvas> canvas(
162 Canvas::create_recording_canvas(props.getWidth(), props.getHeight()));
Stan Iliev06152cd2016-07-27 17:55:43 -0400163 setup(props, *canvas.get());
John Reck2e48df32021-01-19 18:06:05 -0500164 canvas->finishRecording(node.get());
Stan Iliev06152cd2016-07-27 17:55:43 -0400165 }
166 node->setPropertyFieldsDirty(0xFFFFFFFF);
167 return node;
168 }
169
John Reck1bcacfd2017-11-03 10:12:19 -0700170 template <class RecordingCanvasType>
171 static sp<RenderNode> createNode(
172 int left, int top, int right, int bottom,
Stan Iliev06152cd2016-07-27 17:55:43 -0400173 std::function<void(RenderProperties& props, RecordingCanvasType& canvas)> setup) {
Stan Iliev06152cd2016-07-27 17:55:43 -0400174 sp<RenderNode> node = new RenderNode();
175 RenderProperties& props = node->mutateStagingProperties();
176 props.setLeftTopRightBottom(left, top, right, bottom);
177 if (setup) {
178 RecordingCanvasType canvas(props.getWidth(), props.getHeight());
John Reck16c9d6a2015-11-17 15:51:08 -0800179 setup(props, canvas);
John Reck2de950d2017-01-25 10:58:30 -0800180 node->setStagingDisplayList(canvas.finishRecording());
Chris Craik0b7e8242015-10-28 16:50:44 -0700181 }
John Reck16c9d6a2015-11-17 15:51:08 -0800182 node->setPropertyFieldsDirty(0xFFFFFFFF);
Chris Craik0b7e8242015-10-28 16:50:44 -0700183 return node;
184 }
Chris Craikb565df12015-10-05 13:00:52 -0700185
John Reck1bcacfd2017-11-03 10:12:19 -0700186 static void recordNode(RenderNode& node, std::function<void(Canvas&)> contentCallback) {
187 std::unique_ptr<Canvas> canvas(Canvas::create_recording_canvas(
John Reck283bb462018-12-13 16:40:14 -0800188 node.stagingProperties().getWidth(), node.stagingProperties().getHeight(), &node));
John Reck1bcacfd2017-11-03 10:12:19 -0700189 contentCallback(*canvas.get());
John Reck2e48df32021-01-19 18:06:05 -0500190 canvas->finishRecording(&node);
Chris Craikb565df12015-10-05 13:00:52 -0700191 }
192
John Reck1bcacfd2017-11-03 10:12:19 -0700193 static sp<RenderNode> createSkiaNode(
194 int left, int top, int right, int bottom,
195 std::function<void(RenderProperties& props, skiapipeline::SkiaRecordingCanvas& canvas)>
196 setup,
John Reckbe671952021-01-13 22:39:32 -0500197 const char* name = nullptr,
198 std::unique_ptr<skiapipeline::SkiaDisplayList> displayList = nullptr) {
Stan Iliev500a0c32016-10-26 10:30:09 -0400199 sp<RenderNode> node = new RenderNode();
200 if (name) {
201 node->setName(name);
202 }
203 RenderProperties& props = node->mutateStagingProperties();
204 props.setLeftTopRightBottom(left, top, right, bottom);
205 if (displayList) {
John Reckbe671952021-01-13 22:39:32 -0500206 node->setStagingDisplayList(DisplayList(std::move(displayList)));
Stan Iliev500a0c32016-10-26 10:30:09 -0400207 }
208 if (setup) {
209 std::unique_ptr<skiapipeline::SkiaRecordingCanvas> canvas(
John Reck1bcacfd2017-11-03 10:12:19 -0700210 new skiapipeline::SkiaRecordingCanvas(nullptr, props.getWidth(),
211 props.getHeight()));
Stan Iliev500a0c32016-10-26 10:30:09 -0400212 setup(props, *canvas.get());
John Reck2e48df32021-01-19 18:06:05 -0500213 canvas->finishRecording(node.get());
Stan Iliev500a0c32016-10-26 10:30:09 -0400214 }
215 node->setPropertyFieldsDirty(0xFFFFFFFF);
216 TestUtils::syncHierarchyPropertiesAndDisplayList(node);
217 return node;
218 }
219
Chris Craik8d1f2122015-11-24 16:40:09 -0800220 /**
221 * Forces a sync of a tree of RenderNode, such that every descendant will have its staging
222 * properties and DisplayList moved to the render copies.
223 *
224 * Note: does not check dirtiness bits, so any non-staging DisplayLists will be discarded.
225 * For this reason, this should generally only be called once on a tree.
226 */
Chris Craik161f54b2015-11-05 11:08:52 -0800227 static void syncHierarchyPropertiesAndDisplayList(sp<RenderNode>& node) {
228 syncHierarchyPropertiesAndDisplayListImpl(node.get());
Chris Craikb565df12015-10-05 13:00:52 -0700229 }
Chris Craik0a24b142015-10-19 17:10:19 -0700230
Chris Craik9cd1bbe2016-04-14 16:08:25 -0700231 static sp<RenderNode>& getSyncedNode(sp<RenderNode>& node) {
232 syncHierarchyPropertiesAndDisplayList(node);
233 return node;
John Reck7db5ffb2016-01-15 13:17:09 -0800234 }
235
Chris Craik0b7e8242015-10-28 16:50:44 -0700236 typedef std::function<void(renderthread::RenderThread& thread)> RtCallback;
Chris Craik0a24b142015-10-19 17:10:19 -0700237
238 class TestTask : public renderthread::RenderTask {
239 public:
John Reck1bcacfd2017-11-03 10:12:19 -0700240 explicit TestTask(RtCallback rtCallback) : rtCallback(rtCallback) {}
Chris Craik0a24b142015-10-19 17:10:19 -0700241 virtual ~TestTask() {}
John Recke5da4ef2016-01-14 12:34:46 -0800242 virtual void run() override;
Chris Craik0a24b142015-10-19 17:10:19 -0700243 RtCallback rtCallback;
244 };
245
246 /**
247 * NOTE: requires surfaceflinger to run, otherwise this method will wait indefinitely.
248 */
249 static void runOnRenderThread(RtCallback rtCallback) {
250 TestTask task(rtCallback);
John Reck1bcacfd2017-11-03 10:12:19 -0700251 renderthread::RenderThread::getInstance().queue().runSync([&]() { task.run(); });
Chris Craik0a24b142015-10-19 17:10:19 -0700252 }
John Reck16c9d6a2015-11-17 15:51:08 -0800253
John Reck283bb462018-12-13 16:40:14 -0800254 static void runOnRenderThreadUnmanaged(RtCallback rtCallback) {
255 auto& rt = renderthread::RenderThread::getInstance();
256 rt.queue().runSync([&]() { rtCallback(rt); });
257 }
258
259
John Reck1bcacfd2017-11-03 10:12:19 -0700260 static bool isRenderThreadRunning() { return renderthread::RenderThread::hasInstance(); }
John Reck283bb462018-12-13 16:40:14 -0800261 static pid_t getRenderThreadTid() { return renderthread::RenderThread::getInstance().getTid(); }
John Reck38e0c322015-11-10 12:19:17 -0800262
John Reck16c9d6a2015-11-17 15:51:08 -0800263 static SkColor interpolateColor(float fraction, SkColor start, SkColor end);
264
Mike Reedf6d86ac2019-01-18 14:13:23 -0500265 static void drawUtf8ToCanvas(Canvas* canvas, const char* text, const Paint& paint, float x,
John Reck1bcacfd2017-11-03 10:12:19 -0700266 float y);
Chris Craika1717272015-11-19 13:02:43 -0800267
Mike Reedf6d86ac2019-01-18 14:13:23 -0500268 static void drawUtf8ToCanvas(Canvas* canvas, const char* text, const Paint& paint,
John Reck1bcacfd2017-11-03 10:12:19 -0700269 const SkPath& path);
Chris Craikd7448e62015-12-15 10:34:36 -0800270
Derek Sollenberger79abbf22016-03-24 11:07:19 -0400271 static std::unique_ptr<uint16_t[]> asciiToUtf16(const char* str);
sergeyvdccca442016-03-21 15:38:21 -0700272
Stan Iliev021693b2016-10-17 16:26:15 -0400273 static SkColor getColor(const sk_sp<SkSurface>& surface, int x, int y);
274
Stan Iliev52771272016-11-17 09:54:38 -0500275 static SkRect getClipBounds(const SkCanvas* canvas);
276 static SkRect getLocalClipBounds(const SkCanvas* canvas);
277
Nolan Scobie2163e412022-10-24 19:57:43 -0400278 static int getUsageCount(const AutoBackendTextureRelease* textureRelease) {
279 EXPECT_NE(nullptr, textureRelease);
280 return textureRelease->mUsageCount;
281 }
282
John Reck283bb462018-12-13 16:40:14 -0800283 struct CallCounts {
284 int sync = 0;
285 int contextDestroyed = 0;
286 int destroyed = 0;
John Reckfaa1b0a2021-05-13 10:28:38 -0400287 int removeOverlays = 0;
John Reck283bb462018-12-13 16:40:14 -0800288 int glesDraw = 0;
John Reck20a4d682023-07-11 17:11:51 -0400289 int vkInitialize = 0;
290 int vkDraw = 0;
291 int vkPostDraw = 0;
John Reck283bb462018-12-13 16:40:14 -0800292 };
293
John Reckaa4c9822020-06-25 17:14:13 -0700294 static void expectOnRenderThread(const std::string_view& function = "unknown") {
295 EXPECT_EQ(gettid(), TestUtils::getRenderThreadTid()) << "Called on wrong thread: " << function;
296 }
John Reck283bb462018-12-13 16:40:14 -0800297
John Reck20a4d682023-07-11 17:11:51 -0400298 static int createMockFunctor() {
299 const auto renderMode = WebViewFunctor_queryPlatformRenderMode();
300 return WebViewFunctor_create(nullptr, createMockFunctorCallbacks(renderMode), renderMode);
301 }
302
303 static WebViewFunctorCallbacks createMockFunctorCallbacks(RenderMode mode) {
John Reck283bb462018-12-13 16:40:14 -0800304 auto callbacks = WebViewFunctorCallbacks{
305 .onSync =
Bo Liud6668e72018-12-14 19:37:41 -0800306 [](int functor, void* client_data, const WebViewSyncData& data) {
John Reckaa4c9822020-06-25 17:14:13 -0700307 expectOnRenderThread("onSync");
Alec Mourie5792782024-07-18 03:59:51 +0000308 std::scoped_lock lock(sMutex);
John Reck283bb462018-12-13 16:40:14 -0800309 sMockFunctorCounts[functor].sync++;
310 },
311 .onContextDestroyed =
Bo Liud6668e72018-12-14 19:37:41 -0800312 [](int functor, void* client_data) {
John Reckaa4c9822020-06-25 17:14:13 -0700313 expectOnRenderThread("onContextDestroyed");
Alec Mourie5792782024-07-18 03:59:51 +0000314 std::scoped_lock lock(sMutex);
John Reck283bb462018-12-13 16:40:14 -0800315 sMockFunctorCounts[functor].contextDestroyed++;
316 },
317 .onDestroyed =
Bo Liud6668e72018-12-14 19:37:41 -0800318 [](int functor, void* client_data) {
John Reckaa4c9822020-06-25 17:14:13 -0700319 expectOnRenderThread("onDestroyed");
Alec Mourie5792782024-07-18 03:59:51 +0000320 std::scoped_lock lock(sMutex);
John Reck283bb462018-12-13 16:40:14 -0800321 sMockFunctorCounts[functor].destroyed++;
322 },
John Reckfaa1b0a2021-05-13 10:28:38 -0400323 .removeOverlays =
324 [](int functor, void* data,
325 void (*mergeTransaction)(ASurfaceTransaction*)) {
326 expectOnRenderThread("removeOverlays");
Alec Mourie5792782024-07-18 03:59:51 +0000327 std::scoped_lock lock(sMutex);
John Reckfaa1b0a2021-05-13 10:28:38 -0400328 sMockFunctorCounts[functor].removeOverlays++;
329 },
John Reck283bb462018-12-13 16:40:14 -0800330 };
331 switch (mode) {
332 case RenderMode::OpenGL_ES:
Vasiliy Telezhnikov6b237642020-11-12 18:14:58 -0500333 callbacks.gles.draw = [](int functor, void* client_data, const DrawGlInfo& params,
334 const WebViewOverlayData& overlay_params) {
John Reckaa4c9822020-06-25 17:14:13 -0700335 expectOnRenderThread("draw");
Alec Mourie5792782024-07-18 03:59:51 +0000336 std::scoped_lock lock(sMutex);
John Reck283bb462018-12-13 16:40:14 -0800337 sMockFunctorCounts[functor].glesDraw++;
338 };
339 break;
John Reck20a4d682023-07-11 17:11:51 -0400340 case RenderMode::Vulkan:
341 callbacks.vk.initialize = [](int functor, void* data,
342 const VkFunctorInitParams& params) {
343 expectOnRenderThread("initialize");
Alec Mourie5792782024-07-18 03:59:51 +0000344 std::scoped_lock lock(sMutex);
John Reck20a4d682023-07-11 17:11:51 -0400345 sMockFunctorCounts[functor].vkInitialize++;
346 };
347 callbacks.vk.draw = [](int functor, void* data, const VkFunctorDrawParams& params,
348 const WebViewOverlayData& overlayParams) {
349 expectOnRenderThread("draw");
Alec Mourie5792782024-07-18 03:59:51 +0000350 std::scoped_lock lock(sMutex);
John Reck20a4d682023-07-11 17:11:51 -0400351 sMockFunctorCounts[functor].vkDraw++;
352 };
353 callbacks.vk.postDraw = [](int functor, void* data) {
354 expectOnRenderThread("postDraw");
Alec Mourie5792782024-07-18 03:59:51 +0000355 std::scoped_lock lock(sMutex);
John Reck20a4d682023-07-11 17:11:51 -0400356 sMockFunctorCounts[functor].vkPostDraw++;
357 };
358 break;
John Reck283bb462018-12-13 16:40:14 -0800359 }
360 return callbacks;
361 }
362
Alec Mourie5792782024-07-18 03:59:51 +0000363 static CallCounts copyCountsForFunctor(int functor) {
364 std::scoped_lock lock(sMutex);
365 return sMockFunctorCounts[functor];
366 }
John Reck283bb462018-12-13 16:40:14 -0800367
Kevin Lubick09a77092023-10-31 14:58:26 +0000368 static SkFont defaultFont();
369
Chris Craik161f54b2015-11-05 11:08:52 -0800370private:
Alec Mourie5792782024-07-18 03:59:51 +0000371 // guards sMockFunctorCounts
372 static std::mutex sMutex;
John Reck283bb462018-12-13 16:40:14 -0800373 static std::unordered_map<int, CallCounts> sMockFunctorCounts;
374
Chris Craik161f54b2015-11-05 11:08:52 -0800375 static void syncHierarchyPropertiesAndDisplayListImpl(RenderNode* node) {
John Reck2de950d2017-01-25 10:58:30 -0800376 MarkAndSweepRemoved observer(nullptr);
Chris Craik161f54b2015-11-05 11:08:52 -0800377 node->syncProperties();
John Reck3afd6372017-01-30 10:15:48 -0800378 if (node->mNeedsDisplayListSync) {
379 node->mNeedsDisplayListSync = false;
380 node->syncDisplayList(observer, nullptr);
381 }
John Reckbe671952021-01-13 22:39:32 -0500382 auto& displayList = node->getDisplayList();
Chris Craik161f54b2015-11-05 11:08:52 -0800383 if (displayList) {
John Reckbe671952021-01-13 22:39:32 -0500384 displayList.updateChildren([](RenderNode* child) {
385 syncHierarchyPropertiesAndDisplayListImpl(child);
386 });
Chris Craik161f54b2015-11-05 11:08:52 -0800387 }
388 }
389
John Reck1bcacfd2017-11-03 10:12:19 -0700390}; // class TestUtils
Chris Craikb565df12015-10-05 13:00:52 -0700391
392} /* namespace uirenderer */
393} /* namespace android */