2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/devel-api/actors/actor-devel.h>
20 #include <dali/devel-api/common/capabilities.h>
21 #include <dali/devel-api/common/stage.h>
22 #include <dali/devel-api/rendering/renderer-devel.h>
23 #include <dali/integration-api/render-task-list-integ.h>
24 #include <dali/public-api/dali-core.h>
29 #include <dali-test-suite-utils.h>
30 #include <mesh-builder.h>
31 #include <test-trace-call-stack.h>
32 #include "test-graphics-command-buffer.h"
36 void decorated_visual_renderer_test_startup(void)
38 test_return_value = TET_UNDEF;
41 void decorated_visual_renderer_test_cleanup(void)
43 test_return_value = TET_PASS;
46 int UtcDaliDecoratedVisualRendererNew01(void)
48 TestApplication application;
50 Geometry geometry = CreateQuadGeometry();
51 Shader shader = CreateShader();
52 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
54 DALI_TEST_EQUALS((bool)renderer, true, TEST_LOCATION);
58 int UtcDaliDecoratedVisualRendererNew02(void)
60 TestApplication application;
61 DecoratedVisualRenderer renderer;
62 DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION);
66 int UtcDaliDecoratedVisualRendererCopyConstructor(void)
68 TestApplication application;
70 Geometry geometry = CreateQuadGeometry();
71 Shader shader = CreateShader();
72 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
74 DecoratedVisualRenderer rendererCopy(renderer);
75 DALI_TEST_EQUALS((bool)rendererCopy, true, TEST_LOCATION);
80 int UtcDaliDecoratedVisualRendererAssignmentOperator(void)
82 TestApplication application;
84 Geometry geometry = CreateQuadGeometry();
85 Shader shader = CreateShader();
86 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
88 DecoratedVisualRenderer renderer2;
89 DALI_TEST_EQUALS((bool)renderer2, false, TEST_LOCATION);
92 DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION);
96 int UtcDaliDecoratedVisualRendererMoveConstructor(void)
98 TestApplication application;
100 Geometry geometry = CreateQuadGeometry();
101 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
102 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
103 DALI_TEST_CHECK(renderer);
104 DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
105 DALI_TEST_EQUALS(renderer.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR), Vector3::ONE, TEST_LOCATION);
106 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Color::BLACK, TEST_LOCATION);
108 auto testColor = Vector3(1.0f, 0.0f, 1.0f);
109 auto testBorderlineColor = Vector4(1.0f, 0.0f, 1.0f, 0.5f);
110 renderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, testColor);
111 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, testBorderlineColor);
112 application.SendNotification();
113 application.Render();
114 DALI_TEST_EQUALS(renderer.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR), testColor, TEST_LOCATION);
115 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), testBorderlineColor, TEST_LOCATION);
117 DecoratedVisualRenderer move = std::move(renderer);
118 DALI_TEST_CHECK(move);
119 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
120 DALI_TEST_EQUALS(move.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR), testColor, TEST_LOCATION);
121 DALI_TEST_EQUALS(move.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), testBorderlineColor, TEST_LOCATION);
123 DALI_TEST_CHECK(!renderer);
128 int UtcDaliDecoratedVisualRendererMoveAssignment(void)
130 TestApplication application;
132 Geometry geometry = CreateQuadGeometry();
133 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
134 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
135 DALI_TEST_CHECK(renderer);
136 DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
137 DALI_TEST_EQUALS(renderer.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR), Vector3::ONE, TEST_LOCATION);
138 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Color::BLACK, TEST_LOCATION);
140 auto testColor = Vector3(1.0f, 0.0f, 1.0f);
141 auto testBorderlineColor = Vector4(1.0f, 0.0f, 1.0f, 0.5f);
142 renderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, testColor);
143 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, testBorderlineColor);
144 application.SendNotification();
145 application.Render();
146 DALI_TEST_EQUALS(renderer.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR), testColor, TEST_LOCATION);
147 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), testBorderlineColor, TEST_LOCATION);
149 DecoratedVisualRenderer move;
150 move = std::move(renderer);
151 DALI_TEST_CHECK(move);
152 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
153 DALI_TEST_EQUALS(move.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR), testColor, TEST_LOCATION);
154 DALI_TEST_EQUALS(move.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), testBorderlineColor, TEST_LOCATION);
155 DALI_TEST_CHECK(!renderer);
160 int UtcDaliDecoratedVisualRendererDownCast01(void)
162 TestApplication application;
164 Geometry geometry = CreateQuadGeometry();
165 Shader shader = CreateShader();
166 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
168 BaseHandle handle(renderer);
169 DecoratedVisualRenderer renderer2 = DecoratedVisualRenderer::DownCast(handle);
170 DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION);
174 int UtcDaliDecoratedVisualRendererDownCast02(void)
176 TestApplication application;
178 Handle handle = Handle::New(); // Create a custom object
179 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::DownCast(handle);
180 DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION);
184 // using a template to auto deduce the parameter types
185 template<typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
186 void TEST_RENDERER_PROPERTY(P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION)
188 DALI_TEST_EQUALS(renderer.GetPropertyName(enumName), stringName, LOCATION);
189 DALI_TEST_EQUALS(renderer.GetPropertyIndex(stringName), static_cast<Property::Index>(enumName), LOCATION);
190 DALI_TEST_EQUALS(renderer.GetPropertyType(enumName), type, LOCATION);
191 DALI_TEST_EQUALS(renderer.IsPropertyWritable(enumName), isWriteable, LOCATION);
192 DALI_TEST_EQUALS(renderer.IsPropertyAnimatable(enumName), isAnimateable, LOCATION);
193 DALI_TEST_EQUALS(renderer.IsPropertyAConstraintInput(enumName), isConstraintInput, LOCATION);
196 int UtcDaliDecoratedVisualRendererDefaultProperties(void)
198 TestApplication application;
199 Geometry geometry = CreateQuadGeometry();
200 Shader shader = CreateShader();
201 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
202 VisualRenderer baseVisualRenderer = VisualRenderer::New(geometry, shader);
203 Renderer baseRenderer = Renderer::New(geometry, shader);
205 DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 27, TEST_LOCATION);
206 DALI_TEST_EQUALS(baseVisualRenderer.GetPropertyCount(), 27 + 8, TEST_LOCATION);
207 DALI_TEST_EQUALS(renderer.GetPropertyCount(), 27 + 8 + 6, TEST_LOCATION);
209 TEST_RENDERER_PROPERTY(renderer, "cornerRadius", Property::VECTOR4, true, true, true, DecoratedVisualRenderer::Property::CORNER_RADIUS, TEST_LOCATION);
210 TEST_RENDERER_PROPERTY(renderer, "cornerRadiusPolicy", Property::FLOAT, true, false, true, DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, TEST_LOCATION);
211 TEST_RENDERER_PROPERTY(renderer, "borderlineWidth", Property::FLOAT, true, true, true, DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, TEST_LOCATION);
212 TEST_RENDERER_PROPERTY(renderer, "borderlineColor", Property::VECTOR4, true, true, true, DecoratedVisualRenderer::Property::BORDERLINE_COLOR, TEST_LOCATION);
213 TEST_RENDERER_PROPERTY(renderer, "borderlineOffset", Property::FLOAT, true, true, true, DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, TEST_LOCATION);
214 TEST_RENDERER_PROPERTY(renderer, "blurRadius", Property::FLOAT, true, true, true, DecoratedVisualRenderer::Property::BLUR_RADIUS, TEST_LOCATION);
219 int UtcDaliDecoratedVisualRendererAnimatedProperty01(void)
221 TestApplication application;
223 tet_infoline("Test that a decorated visual renderer property can be animated");
225 Shader shader = Shader::New("VertexSource", "FragmentSource");
226 Geometry geometry = CreateQuadGeometry();
227 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
229 Actor actor = Actor::New();
230 actor.AddRenderer(renderer);
231 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
232 application.GetScene().Add(actor);
234 Property::Index cornerRadiusIndex = DecoratedVisualRenderer::Property::CORNER_RADIUS;
235 renderer.SetProperty(cornerRadiusIndex, Vector4(1.0f, 10.0f, 5.0f, 0.0f));
237 application.SendNotification();
238 application.Render(0);
239 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(cornerRadiusIndex), Vector4(1.0f, 10.0f, 5.0f, 0.0f), 0.001f, TEST_LOCATION);
241 Animation animation = Animation::New(1.0f);
242 KeyFrames keyFrames = KeyFrames::New();
243 keyFrames.Add(0.0f, Vector4(1.0f, 0.0f, 1.0f, 0.0f));
244 keyFrames.Add(1.0f, Vector4(0.0f, 1.0f, 0.0f, 1.0f));
245 animation.AnimateBetween(Property(renderer, cornerRadiusIndex), keyFrames);
248 application.SendNotification();
249 application.Render(500);
251 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(cornerRadiusIndex), Vector4(0.5f, 0.5f, 0.5f, 0.5f), TEST_LOCATION);
253 application.Render(400);
254 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(cornerRadiusIndex), Vector4(0.1f, 0.9f, 0.1f, 0.9f), TEST_LOCATION);
256 application.Render(100);
257 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(cornerRadiusIndex), Vector4(0.f, 1.f, 0.f, 1.f), TEST_LOCATION);
258 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(cornerRadiusIndex), Vector4(0.f, 1.f, 0.f, 1.f), TEST_LOCATION);
263 int UtcDaliDecoratedVisualRendererAnimatedProperty02(void)
265 TestApplication application;
267 tet_infoline("Test that a decorated visual renderer property can be animated");
269 Shader shader = Shader::New("VertexSource", "FragmentSource");
270 Geometry geometry = CreateQuadGeometry();
271 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
273 Actor actor = Actor::New();
274 actor.AddRenderer(renderer);
275 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
276 application.GetScene().Add(actor);
278 renderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, Vector4(1.0f, 1.0f, 0.0f, 0.0f));
279 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, 1.0f);
280 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
281 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, -1.0f);
282 renderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, 0.0f);
284 application.SendNotification();
285 application.Render(0);
286 application.SendNotification();
287 application.Render(0);
288 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS), Vector4(1.0f, 1.0f, 0.0f, 0.0f), 0.001f, TEST_LOCATION);
289 DALI_TEST_EQUALS(renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), 1.0f, 0.001f, TEST_LOCATION);
290 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Vector4(1.0f, 0.0f, 0.0f, 1.0f), 0.001f, TEST_LOCATION);
291 DALI_TEST_EQUALS(renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET), -1.0f, 0.001f, TEST_LOCATION);
292 DALI_TEST_EQUALS(renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS), 0.0f, 0.001f, TEST_LOCATION);
294 Animation animation = Animation::New(1.0f);
295 animation.AnimateBy(Property(renderer, DecoratedVisualRenderer::Property::CORNER_RADIUS), Vector4(10.0f, 100.0f, 100.0f, 10.0f));
296 animation.AnimateBy(Property(renderer, DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), 10.0f);
297 animation.AnimateBy(Property(renderer, DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Vector4(-1.0f, 1.0f, 1.0f, 0.0f));
298 animation.AnimateBy(Property(renderer, DecoratedVisualRenderer::Property::BORDERLINE_OFFSET), 2.0f);
299 animation.AnimateBy(Property(renderer, DecoratedVisualRenderer::Property::BLUR_RADIUS), 20.0f);
302 application.SendNotification();
303 application.Render(500);
305 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS), Vector4(6.0f, 51.0f, 50.0f, 5.0f), 0.001f, TEST_LOCATION);
306 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), 6.0f, 0.001f, TEST_LOCATION);
307 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Vector4(0.5f, 0.5f, 0.5f, 1.0f), 0.001f, TEST_LOCATION);
308 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET), 0.0f, 0.001f, TEST_LOCATION);
309 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS), 10.0f, 0.001f, TEST_LOCATION);
311 application.Render(400);
312 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS), Vector4(10.0f, 91.0f, 90.0f, 9.0f), 0.001f, TEST_LOCATION);
313 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), 10.0f, 0.001f, TEST_LOCATION);
314 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Vector4(0.1f, 0.9f, 0.9f, 1.0f), 0.001f, TEST_LOCATION);
315 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET), 0.8f, 0.001f, TEST_LOCATION);
316 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS), 18.0f, 0.001f, TEST_LOCATION);
318 application.Render(100);
319 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS), Vector4(11.0f, 101.0f, 100.0f, 10.0f), 0.001f, TEST_LOCATION);
320 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), 11.0f, 0.001f, TEST_LOCATION);
321 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Vector4(0.0f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
322 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET), 1.0f, 0.001f, TEST_LOCATION);
323 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS), 20.0f, 0.001f, TEST_LOCATION);
325 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS), Vector4(11.0f, 101.0f, 100.0f, 10.0f), 0.001f, TEST_LOCATION);
326 DALI_TEST_EQUALS(renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), 11.0f, 0.001f, TEST_LOCATION);
327 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR), Vector4(0.0f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
328 DALI_TEST_EQUALS(renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET), 1.0f, 0.001f, TEST_LOCATION);
329 DALI_TEST_EQUALS(renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS), 20.0f, 0.001f, TEST_LOCATION);
334 struct DecoratedVisualProperties
336 DecoratedVisualProperties() = default;
338 DecoratedVisualProperties(Vector2 offset, Vector2 size, Vector2 origin, Vector2 pivot, Vector4 modes, Vector2 extraSize, Vector3 mixColor, float preMultipliedAlpha, Vector4 cornerRadius, float cornerRadiusPolicy, float borderlineWidth, Vector4 borderlineColor, float borderlineOffset, float blurRadius)
339 : mTransformOffset(offset),
340 mTransformSize(size),
341 mTransformOrigin(origin),
342 mTransformAnchorPoint(pivot),
343 mTransformOffsetSizeMode(modes),
344 mExtraSize(extraSize),
346 mPreMultipliedAlpha(preMultipliedAlpha),
347 mCornerRadius(cornerRadius),
348 mCornerRadiusPolicy(cornerRadiusPolicy),
349 mBorderlineWidth(borderlineWidth),
350 mBorderlineColor(borderlineColor),
351 mBorderlineOffset(borderlineOffset),
352 mBlurRadius(blurRadius)
356 Vector2 mTransformOffset{Vector2::ZERO};
357 Vector2 mTransformSize{Vector2::ONE};
358 Vector2 mTransformOrigin{Vector2::ZERO};
359 Vector2 mTransformAnchorPoint{Vector2::ZERO};
360 Vector4 mTransformOffsetSizeMode{Vector2::ZERO};
361 Vector2 mExtraSize{Vector2::ZERO};
362 Vector3 mMixColor{Vector3::ONE};
363 float mPreMultipliedAlpha{0.0f};
365 Vector4 mCornerRadius{Vector4::ZERO};
366 float mCornerRadiusPolicy{1.0f};
367 float mBorderlineWidth{0.0f};
368 Vector4 mBorderlineColor{Vector4::ZERO};
369 float mBorderlineOffset{0.0f};
370 float mBlurRadius{0.0f};
372 static DecoratedVisualProperties GetPropsAt(float alpha, const DecoratedVisualProperties& start, const DecoratedVisualProperties& end)
374 DecoratedVisualProperties progress;
375 progress.mTransformOffset = start.mTransformOffset + (end.mTransformOffset - start.mTransformOffset) * alpha;
376 progress.mTransformSize = start.mTransformSize + (end.mTransformSize - start.mTransformSize) * alpha;
377 progress.mExtraSize = start.mExtraSize + (end.mExtraSize - start.mExtraSize) * alpha;
378 progress.mMixColor = start.mMixColor + (end.mMixColor - start.mMixColor) * alpha;
379 progress.mCornerRadius = start.mCornerRadius + (end.mCornerRadius - start.mCornerRadius) * alpha;
380 progress.mBorderlineWidth = start.mBorderlineWidth + (end.mBorderlineWidth - start.mBorderlineWidth) * alpha;
381 progress.mBorderlineColor = start.mBorderlineColor + (end.mBorderlineColor - start.mBorderlineColor) * alpha;
382 progress.mBorderlineOffset = start.mBorderlineOffset + (end.mBorderlineOffset - start.mBorderlineOffset) * alpha;
383 progress.mBlurRadius = start.mBlurRadius + (end.mBlurRadius - start.mBlurRadius) * alpha;
385 progress.mTransformOffsetSizeMode = end.mTransformOffsetSizeMode;
386 progress.mTransformOrigin = end.mTransformOrigin;
387 progress.mTransformAnchorPoint = end.mTransformAnchorPoint;
388 progress.mPreMultipliedAlpha = end.mPreMultipliedAlpha;
389 progress.mCornerRadiusPolicy = end.mCornerRadiusPolicy;
394 void PrintDecoratedVisualProperties(const DecoratedVisualProperties& props, const std::string& prefix)
397 "%s: offset:(%5.3f, %5.3f)\n"
398 "%*c size:(%5.3f, %5.3f)\n"
399 "%*c origin:(%5.3f, %5.3f)\n"
400 "%*c anchorPoint:(%5.3f, %5.3f)\n"
401 "%*c offsetSizeMode:(%5.3f, %5.3f, %5.3f, %5.3f)\n"
402 "%*c extraSize:(%5.3f, %5.3f)\n"
403 "%*c mixColor:(%5.3f, %5.3f, %5.3f)\n"
404 "%*c preMultipliedAlpha:(%5.3f)\n"
405 "%*c cornerRadius:(%5.3f, %5.3f, %5.3f, %5.3f)\n"
406 "%*c cornerRadiusPolicy:(%5.3f)\n"
407 "%*c borderlineWidth:(%5.3f)\n"
408 "%*c borderlineColor:(%5.3f, %5.3f, %5.3f, %5.3f)\n"
409 "%*c borderlineOffset:(%5.3f)\n"
410 "%*c blurRadius:(%5.3f)\n",
412 props.mTransformOffset.x,
413 props.mTransformOffset.y,
416 props.mTransformSize.x,
417 props.mTransformSize.y,
420 props.mTransformOrigin.x,
421 props.mTransformOrigin.y,
424 props.mTransformAnchorPoint.x,
425 props.mTransformAnchorPoint.y,
428 props.mTransformOffsetSizeMode.x,
429 props.mTransformOffsetSizeMode.y,
430 props.mTransformOffsetSizeMode.z,
431 props.mTransformOffsetSizeMode.w,
443 props.mPreMultipliedAlpha,
446 props.mCornerRadius.x,
447 props.mCornerRadius.y,
448 props.mCornerRadius.z,
449 props.mCornerRadius.w,
452 props.mCornerRadiusPolicy,
455 props.mBorderlineWidth,
458 props.mBorderlineColor.x,
459 props.mBorderlineColor.y,
460 props.mBorderlineColor.z,
461 props.mBorderlineColor.w,
464 props.mBorderlineOffset,
470 void SetDecoratedVisualProperties(DecoratedVisualRenderer renderer, DecoratedVisualProperties props)
472 renderer.SetProperty(VisualRenderer::Property::TRANSFORM_OFFSET, props.mTransformOffset);
473 renderer.SetProperty(VisualRenderer::Property::TRANSFORM_SIZE, props.mTransformSize);
474 renderer.SetProperty(VisualRenderer::Property::TRANSFORM_ORIGIN, props.mTransformOrigin);
475 renderer.SetProperty(VisualRenderer::Property::TRANSFORM_ANCHOR_POINT, props.mTransformAnchorPoint);
476 renderer.SetProperty(VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE, props.mTransformOffsetSizeMode);
477 renderer.SetProperty(VisualRenderer::Property::EXTRA_SIZE, props.mExtraSize);
478 renderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, props.mMixColor);
479 renderer.SetProperty(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, props.mPreMultipliedAlpha);
481 renderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, props.mCornerRadius);
482 renderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, props.mCornerRadiusPolicy);
483 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, props.mBorderlineWidth);
484 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, props.mBorderlineColor);
485 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, props.mBorderlineOffset);
486 renderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, props.mBlurRadius);
489 void CheckEventDecoratedVisualProperties(DecoratedVisualRenderer renderer, DecoratedVisualProperties expectedProps)
491 tet_infoline("CheckEventDecoratedVisualProperties\n");
493 DecoratedVisualProperties actualProps;
494 actualProps.mTransformOffset = renderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_OFFSET);
495 actualProps.mTransformSize = renderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE);
496 actualProps.mTransformOrigin = renderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_ORIGIN);
497 actualProps.mTransformAnchorPoint = renderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_ANCHOR_POINT);
498 actualProps.mTransformOffsetSizeMode = renderer.GetProperty<Vector4>(VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE);
499 actualProps.mExtraSize = renderer.GetProperty<Vector2>(VisualRenderer::Property::EXTRA_SIZE);
500 actualProps.mMixColor = renderer.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR);
501 actualProps.mPreMultipliedAlpha = renderer.GetProperty<float>(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA);
503 actualProps.mCornerRadius = renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
504 actualProps.mCornerRadiusPolicy = renderer.GetProperty<float>(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY);
505 actualProps.mBorderlineWidth = renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
506 actualProps.mBorderlineColor = renderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
507 actualProps.mBorderlineOffset = renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
508 actualProps.mBlurRadius = renderer.GetProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS);
510 PrintDecoratedVisualProperties(actualProps, "Actual event props");
512 DALI_TEST_EQUALS(actualProps.mTransformOffset, expectedProps.mTransformOffset, TEST_LOCATION);
513 DALI_TEST_EQUALS(actualProps.mTransformSize, expectedProps.mTransformSize, TEST_LOCATION);
514 DALI_TEST_EQUALS(actualProps.mTransformOrigin, expectedProps.mTransformOrigin, TEST_LOCATION);
515 DALI_TEST_EQUALS(actualProps.mTransformAnchorPoint, expectedProps.mTransformAnchorPoint, TEST_LOCATION);
516 DALI_TEST_EQUALS(actualProps.mTransformOffsetSizeMode, expectedProps.mTransformOffsetSizeMode, TEST_LOCATION);
517 DALI_TEST_EQUALS(actualProps.mExtraSize, expectedProps.mExtraSize, TEST_LOCATION);
518 DALI_TEST_EQUALS(actualProps.mMixColor, expectedProps.mMixColor, TEST_LOCATION);
519 DALI_TEST_EQUALS(actualProps.mPreMultipliedAlpha, expectedProps.mPreMultipliedAlpha, TEST_LOCATION);
521 DALI_TEST_EQUALS(actualProps.mCornerRadius, expectedProps.mCornerRadius, TEST_LOCATION);
522 DALI_TEST_EQUALS(actualProps.mCornerRadiusPolicy, expectedProps.mCornerRadiusPolicy, TEST_LOCATION);
523 DALI_TEST_EQUALS(actualProps.mBorderlineWidth, expectedProps.mBorderlineWidth, TEST_LOCATION);
524 DALI_TEST_EQUALS(actualProps.mBorderlineColor, expectedProps.mBorderlineColor, TEST_LOCATION);
525 DALI_TEST_EQUALS(actualProps.mBorderlineOffset, expectedProps.mBorderlineOffset, TEST_LOCATION);
526 DALI_TEST_EQUALS(actualProps.mBlurRadius, expectedProps.mBlurRadius, TEST_LOCATION);
529 void CheckSceneGraphDecoratedVisualProperties(DecoratedVisualRenderer renderer, DecoratedVisualProperties expectedProps)
531 tet_infoline("CheckSceneGraphVisualProperties\n");
533 DecoratedVisualProperties actualProps;
535 actualProps.mTransformOffset = renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::TRANSFORM_OFFSET);
536 actualProps.mTransformSize = renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE);
537 actualProps.mTransformOrigin = renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::TRANSFORM_ORIGIN);
538 actualProps.mTransformAnchorPoint = renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::TRANSFORM_ANCHOR_POINT);
539 actualProps.mTransformOffsetSizeMode = renderer.GetCurrentProperty<Vector4>(VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE);
540 actualProps.mExtraSize = renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::EXTRA_SIZE);
541 actualProps.mMixColor = renderer.GetCurrentProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR);
543 actualProps.mCornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
544 actualProps.mCornerRadiusPolicy = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY);
545 actualProps.mBorderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
546 actualProps.mBorderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
547 actualProps.mBorderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
548 actualProps.mBlurRadius = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS);
550 PrintDecoratedVisualProperties(actualProps, "Actual update props");
552 DALI_TEST_EQUALS(actualProps.mTransformOffset, expectedProps.mTransformOffset, TEST_LOCATION);
553 DALI_TEST_EQUALS(actualProps.mTransformSize, expectedProps.mTransformSize, TEST_LOCATION);
554 DALI_TEST_EQUALS(actualProps.mTransformOrigin, expectedProps.mTransformOrigin, TEST_LOCATION);
555 DALI_TEST_EQUALS(actualProps.mTransformAnchorPoint, expectedProps.mTransformAnchorPoint, TEST_LOCATION);
556 DALI_TEST_EQUALS(actualProps.mTransformOffsetSizeMode, expectedProps.mTransformOffsetSizeMode, TEST_LOCATION);
557 DALI_TEST_EQUALS(actualProps.mExtraSize, expectedProps.mExtraSize, TEST_LOCATION);
558 DALI_TEST_EQUALS(actualProps.mMixColor, expectedProps.mMixColor, TEST_LOCATION);
559 DALI_TEST_EQUALS(actualProps.mPreMultipliedAlpha, expectedProps.mPreMultipliedAlpha, TEST_LOCATION);
561 DALI_TEST_EQUALS(actualProps.mCornerRadius, expectedProps.mCornerRadius, TEST_LOCATION);
562 DALI_TEST_EQUALS(actualProps.mCornerRadiusPolicy, expectedProps.mCornerRadiusPolicy, TEST_LOCATION);
563 DALI_TEST_EQUALS(actualProps.mBorderlineWidth, expectedProps.mBorderlineWidth, TEST_LOCATION);
564 DALI_TEST_EQUALS(actualProps.mBorderlineColor, expectedProps.mBorderlineColor, TEST_LOCATION);
565 DALI_TEST_EQUALS(actualProps.mBorderlineOffset, expectedProps.mBorderlineOffset, TEST_LOCATION);
566 DALI_TEST_EQUALS(actualProps.mBlurRadius, expectedProps.mBlurRadius, TEST_LOCATION);
569 void CheckUniforms(DecoratedVisualRenderer renderer, DecoratedVisualProperties props, std::vector<UniformData>& uniforms, TraceCallStack& callStack, TestGlAbstraction& gl)
571 tet_infoline("CheckUniforms\n");
573 TraceCallStack::NamedParams params;
575 tet_printf("Callback trace: \n%s\n", callStack.GetTraceString().c_str());
577 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[0].name, params));
578 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[0].name.c_str(), props.mTransformOffset));
580 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[1].name, params));
581 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[1].name.c_str(), props.mTransformSize));
583 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[2].name, params));
584 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[2].name.c_str(), props.mTransformOrigin));
586 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[3].name, params));
587 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[3].name.c_str(), props.mTransformAnchorPoint));
589 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[4].name, params));
590 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[4].name.c_str(), props.mTransformOffsetSizeMode));
592 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[5].name, params));
593 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[5].name.c_str(), props.mExtraSize));
595 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[6].name, params));
596 DALI_TEST_CHECK(gl.GetUniformValue<Vector3>(uniforms[6].name.c_str(), props.mMixColor));
598 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[7].name, params));
599 DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[7].name.c_str(), props.mPreMultipliedAlpha));
601 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[8].name, params));
602 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[8].name.c_str(), props.mCornerRadius));
604 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[9].name, params));
605 DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[9].name.c_str(), props.mCornerRadiusPolicy));
607 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[10].name, params));
608 DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[10].name.c_str(), props.mBorderlineWidth));
610 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[11].name, params));
611 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[11].name.c_str(), props.mBorderlineColor));
613 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[12].name, params));
614 DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[12].name.c_str(), props.mBorderlineOffset));
616 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[13].name, params));
617 DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[13].name.c_str(), props.mBlurRadius));
620 int UtcDaliDecoratedVisualRendererAnimatedProperty03(void)
622 TestApplication application;
623 TestGlAbstraction& gl = application.GetGlAbstraction();
624 TraceCallStack& callStack = gl.GetSetUniformTrace();
625 gl.EnableSetUniformCallTrace(true);
627 tet_infoline("Test that a decorated visual renderer property can be animated and that the uniforms are set");
629 std::vector<UniformData> customUniforms{{"offset", Property::VECTOR2},
630 {"size", Property::VECTOR2},
631 {"origin", Property::VECTOR2},
632 {"anchorPoint", Property::VECTOR2},
633 {"offsetSizeMode", Property::VECTOR4},
634 {"extraSize", Property::VECTOR2},
635 {"mixColor", Property::VECTOR3},
636 {"preMultipliedAlpha", Property::FLOAT},
637 {"cornerRadius", Property::VECTOR4},
638 {"cornerRadiusPolicy", Property::FLOAT},
639 {"borderlineWidth", Property::FLOAT},
640 {"borderlineColor", Property::VECTOR4},
641 {"borderlineOffset", Property::FLOAT},
642 {"blurRadius", Property::FLOAT}};
644 application.GetGraphicsController().AddCustomUniforms(customUniforms);
646 Shader shader = Shader::New("VertexSource", "FragmentSource");
647 Geometry geometry = CreateQuadGeometry();
648 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
650 // Add all uniform mappings
651 renderer.RegisterCornerRadiusUniform();
652 renderer.RegisterBorderlineUniform();
653 renderer.RegisterBlurRadiusUniform();
655 Actor actor = Actor::New();
656 actor.AddRenderer(renderer);
657 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
658 application.GetScene().Add(actor);
660 DecoratedVisualProperties props{Vector2(10.f, 10.f), Vector2(200.f, 100.f), Vector2(0.5f, 0.5f), Vector2(0.5f, 0.5f), Vector4::ZERO, Vector2(0.0f, 0.0f), Vector3(Color::SEA_GREEN), 0.0f, Vector4(100.0f, 10.0f, 1.0f, 0.1f), 1.0f, 20.0f, Vector4(1.0f, 0.0f, 1.0f, 0.5f), 1.0f, 10.0f};
661 DecoratedVisualProperties targetProps{Vector2(40.f, 40.f), Vector2(100.f, 200.f), Vector2(0.5f, 0.5f), Vector2(0.5f, 0.5f), Vector4::ZERO, Vector2(25.0f, 25.0f), Vector3(Color::MEDIUM_PURPLE), 0.0f, Vector4(0.2f, 2.0f, 20.0f, 200.0f), 1.0f, 40.0f, Vector4(0.0f, 0.2f, 0.0f, 1.0f), -1.0f, 2.0f};
663 SetDecoratedVisualProperties(renderer, props);
664 CheckEventDecoratedVisualProperties(renderer, props);
665 application.SendNotification();
666 application.Render(0);
667 CheckSceneGraphDecoratedVisualProperties(renderer, props);
668 CheckUniforms(renderer, props, customUniforms, callStack, gl);
670 // Set up a 1 second anim.
671 Animation animation = Animation::New(1.0f);
673 animation.AnimateTo(Property(renderer, VisualRenderer::Property::TRANSFORM_OFFSET), targetProps.mTransformOffset);
674 animation.AnimateTo(Property(renderer, VisualRenderer::Property::TRANSFORM_SIZE), targetProps.mTransformSize);
675 animation.AnimateTo(Property(renderer, VisualRenderer::Property::EXTRA_SIZE), targetProps.mExtraSize);
676 animation.AnimateTo(Property(renderer, VisualRenderer::Property::VISUAL_MIX_COLOR), targetProps.mMixColor);
678 animation.AnimateTo(Property(renderer, DecoratedVisualRenderer::Property::CORNER_RADIUS), targetProps.mCornerRadius);
679 animation.AnimateTo(Property(renderer, DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), targetProps.mBorderlineWidth);
680 animation.AnimateTo(Property(renderer, DecoratedVisualRenderer::Property::BORDERLINE_COLOR), targetProps.mBorderlineColor);
681 animation.AnimateTo(Property(renderer, DecoratedVisualRenderer::Property::BORDERLINE_OFFSET), targetProps.mBorderlineOffset);
682 animation.AnimateTo(Property(renderer, DecoratedVisualRenderer::Property::BLUR_RADIUS), targetProps.mBlurRadius);
685 CheckEventDecoratedVisualProperties(renderer, targetProps);
687 for(int i = 0; i <= 10; ++i)
689 tet_printf("\n########### Animation progress: %d%%\n\n", i * 10);
690 DecoratedVisualProperties propsProgress = DecoratedVisualProperties::GetPropsAt(0.1f * i, props, targetProps);
691 PrintDecoratedVisualProperties(propsProgress, "Expected values");
694 application.SendNotification();
695 application.Render((i == 0 ? 0 : 100));
697 CheckEventDecoratedVisualProperties(renderer, targetProps);
699 CheckSceneGraphDecoratedVisualProperties(renderer, propsProgress);
700 CheckUniforms(renderer, propsProgress, customUniforms, callStack, gl);
703 // Ensure animation finishes
704 application.SendNotification();
705 application.Render(100);
706 CheckSceneGraphDecoratedVisualProperties(renderer, targetProps);
707 CheckUniforms(renderer, targetProps, customUniforms, callStack, gl);
712 int UtcDaliDecoratedVisualRendererAnimatedProperty04(void)
714 TestApplication application;
716 tet_infoline("Test that a decorated visual renderer property can't be animated");
718 Shader shader = Shader::New("VertexSource", "FragmentSource");
719 Geometry geometry = CreateQuadGeometry();
720 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
722 Actor actor = Actor::New();
723 actor.AddRenderer(renderer);
724 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
725 application.GetScene().Add(actor);
727 Property::Index index = DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY;
728 renderer.SetProperty(index, 0.0f);
730 application.SendNotification();
731 application.Render(0);
732 DALI_TEST_EQUALS(renderer.GetProperty<float>(index), 0.0f, 0.001f, TEST_LOCATION);
734 Animation animation = Animation::New(1.0f);
735 KeyFrames keyFrames = KeyFrames::New();
736 keyFrames.Add(0.0f, 0.0f);
737 keyFrames.Add(1.0f, 1.0f);
740 animation.AnimateBetween(Property(renderer, index), keyFrames);
741 tet_result(TET_FAIL);
743 catch(DaliException& e)
745 DALI_TEST_ASSERT(e, "baseProperty && \"Property is not animatable\"", TEST_LOCATION);
751 int UtcDaliDecoratedVisualRendererAnimatedProperty05(void)
753 TestApplication application;
755 tet_infoline("Test that a parent visual renderer property can still be animated");
757 Shader shader = Shader::New("VertexSource", "FragmentSource");
758 Geometry geometry = CreateQuadGeometry();
759 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
761 Actor actor = Actor::New();
762 actor.AddRenderer(renderer);
763 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
764 application.GetScene().Add(actor);
766 Property::Index index = VisualRenderer::Property::TRANSFORM_SIZE;
767 renderer.SetProperty(index, Vector2(1.0f, 0.5f));
769 application.SendNotification();
770 application.Render(0);
771 DALI_TEST_EQUALS(renderer.GetProperty<Vector2>(index), Vector2(1.0f, 0.5f), 0.001f, TEST_LOCATION);
772 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE), Vector2(1.0f, 0.5f), 0.0001f, TEST_LOCATION);
774 Animation animation = Animation::New(1.0f);
775 KeyFrames keyFrames = KeyFrames::New();
776 keyFrames.Add(0.0f, Vector2(1.0f, 0.0f));
777 keyFrames.Add(1.0f, Vector2(0.0f, 1.0f));
778 animation.AnimateBetween(Property(renderer, index), keyFrames);
781 application.SendNotification();
783 // Test that the event side properties are set to target value of (0, 1)
784 DALI_TEST_EQUALS(renderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE), Vector2(0.0f, 1.0f), 0.0001f, TEST_LOCATION);
786 application.Render(500);
788 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector2>(index), Vector2(0.5f, 0.5f), 0.0001f, TEST_LOCATION);
789 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE), Vector2(0.5f, 0.5f), 0.0001f, TEST_LOCATION);
791 // Test that the event side properties are set to target value 0f (0, 1)
792 DALI_TEST_EQUALS(renderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE), Vector2(0.0f, 1.0f), 0.0001f, TEST_LOCATION);
794 // Complete the animation
795 application.Render(500);
797 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector2>(index), Vector2(0.0f, 1.0f), 0.0001f, TEST_LOCATION);
798 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE), Vector2(0.0f, 1.0f), 0.0001f, TEST_LOCATION);
799 DALI_TEST_EQUALS(renderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE), Vector2(0.0f, 1.0f), 0.0001f, TEST_LOCATION);
803 int UtcDaliDecoratedVisualRendererPartialUpdate(void)
805 TestApplication application(
806 TestApplication::DEFAULT_SURFACE_WIDTH,
807 TestApplication::DEFAULT_SURFACE_HEIGHT,
808 TestApplication::DEFAULT_HORIZONTAL_DPI,
809 TestApplication::DEFAULT_VERTICAL_DPI,
813 tet_infoline("Test that partial update works well when we set visual renderer's animated properties");
815 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
817 Shader shader = Shader::New("VertexSource", "FragmentSource");
818 Geometry geometry = CreateQuadGeometry();
819 DecoratedVisualRenderer renderer = DecoratedVisualRenderer::New(geometry, shader);
821 Actor actor = Actor::New();
822 actor.AddRenderer(renderer);
823 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
824 actor[Actor::Property::POSITION] = Vector3(66.0f, 66.0f, 0.0f);
825 actor[Actor::Property::SIZE] = Vector3(60.0f, 60.0f, 0.0f);
826 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
827 application.GetScene().Add(actor);
829 application.SendNotification();
831 std::vector<Rect<int>> damagedRects;
833 // Actor added, damaged rect is added size of actor
834 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
835 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
838 Rect<int> clippingRect = Rect<int>(64, 672, 64, 64); // in screen coordinates, includes 3 last frames updates
839 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
841 application.RenderWithPartialUpdate(damagedRects, clippingRect);
842 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
843 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
844 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
845 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
847 damagedRects.clear();
848 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
849 application.RenderWithPartialUpdate(damagedRects, clippingRect);
851 // Ensure the damaged rect is empty
852 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
854 // Set clippingRect as full surface now. TODO : Set valid rect if we can.
855 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
857 // Set decoration with borderline as 32 units.
858 renderer.RegisterBorderlineUniform();
859 renderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, 32.0f);
861 Property::Index index = DecoratedVisualRenderer::Property::BORDERLINE_OFFSET;
862 renderer.SetProperty(index, 1.0f);
864 // Now current actor show as 124x124 rectangle, with center position (96, 96).
865 // So, rectangle's top left position is (34, 34), and bottom right position is (158, 158).
867 application.SendNotification();
868 damagedRects.clear();
869 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
870 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
872 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(32, 640, 128, 128), damagedRects[0], TEST_LOCATION);
874 application.RenderWithPartialUpdate(damagedRects, clippingRect);
876 application.SendNotification();
877 damagedRects.clear();
878 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
879 application.RenderWithPartialUpdate(damagedRects, clippingRect);
881 // Update dummy property to damangeRect buffer aging
882 actor.SetProperty(Actor::Property::COLOR, Color::RED);
884 application.SendNotification();
885 damagedRects.clear();
886 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
887 application.RenderWithPartialUpdate(damagedRects, clippingRect);
888 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
890 // Update dummy property to damangeRect buffer aging
891 actor.SetProperty(Actor::Property::COLOR, Color::BLUE);
893 application.SendNotification();
894 damagedRects.clear();
895 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
896 application.RenderWithPartialUpdate(damagedRects, clippingRect);
897 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
899 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(32, 640, 128, 128), damagedRects[0], TEST_LOCATION);
901 application.SendNotification();
902 damagedRects.clear();
903 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
904 application.RenderWithPartialUpdate(damagedRects, clippingRect);
906 application.SendNotification();
907 damagedRects.clear();
908 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
909 application.RenderWithPartialUpdate(damagedRects, clippingRect);
911 application.SendNotification();
912 damagedRects.clear();
913 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
914 application.RenderWithPartialUpdate(damagedRects, clippingRect);
916 // 3 frame spended after change actor property. Ensure the damaged rect is empty
917 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
919 DALI_TEST_EQUALS(renderer.GetProperty<float>(index), 1.0f, 0.001f, TEST_LOCATION);
921 // Make flickered animation from 1.0f --> 0.0f --> -1.0f of borderline offset
922 // After finish the animation, actor show as 64x64 rectangle, with center position (96, 96).
923 // So, rectangle's top left position is (64, 64), and bottom right position is (128, 128).
924 Animation animation = Animation::New(1.0f);
925 KeyFrames keyFrames = KeyFrames::New();
926 keyFrames.Add(0.0f, float(1.0f));
927 keyFrames.Add(0.299f, float(1.0f));
928 keyFrames.Add(0.301f, float(0.0f));
929 keyFrames.Add(0.699f, float(0.0f));
930 keyFrames.Add(0.701f, float(-1.0f));
931 keyFrames.Add(1.0f, float(-1.0f));
932 animation.AnimateBetween(Property(renderer, index), keyFrames);
935 application.SendNotification();
936 damagedRects.clear();
937 application.PreRenderWithPartialUpdate(200, nullptr, damagedRects); // 200 ms
938 application.RenderWithPartialUpdate(damagedRects, clippingRect);
940 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(index), 1.0f, TEST_LOCATION);
942 // 302 ~ 600. TransformSize become 0.0f
943 application.SendNotification();
944 damagedRects.clear();
945 application.PreRenderWithPartialUpdate(102, nullptr, damagedRects); // 302 ms
946 application.RenderWithPartialUpdate(damagedRects, clippingRect);
948 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(index), 0.0f, TEST_LOCATION);
950 // Update dummy property to damangeRect buffer aging
951 actor.SetProperty(Actor::Property::COLOR, Color::RED);
953 application.SendNotification();
954 damagedRects.clear();
955 application.PreRenderWithPartialUpdate(16, nullptr, damagedRects); // 318 ms
956 application.RenderWithPartialUpdate(damagedRects, clippingRect);
958 // Update dummy property to damangeRect buffer aging
959 actor.SetProperty(Actor::Property::COLOR, Color::GREEN);
961 application.SendNotification();
962 damagedRects.clear();
963 application.PreRenderWithPartialUpdate(16, nullptr, damagedRects); // 334 ms
964 application.RenderWithPartialUpdate(damagedRects, clippingRect);
966 // Update dummy property to damangeRect buffer aging
967 actor.SetProperty(Actor::Property::COLOR, Color::RED);
969 application.SendNotification();
970 damagedRects.clear();
971 application.PreRenderWithPartialUpdate(16, nullptr, damagedRects); // 350 ms
972 application.RenderWithPartialUpdate(damagedRects, clippingRect);
974 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
976 // Now current actor show as 92x92 rectangle, with center position (96, 96).
977 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(48, 656, 96, 96), damagedRects[0], TEST_LOCATION);
979 application.SendNotification();
980 damagedRects.clear();
981 application.PreRenderWithPartialUpdate(250, nullptr, damagedRects); // 600 ms
982 application.RenderWithPartialUpdate(damagedRects, clippingRect);
984 // 702 ~ 1000. TransformSize become -1.0f
985 damagedRects.clear();
986 application.PreRenderWithPartialUpdate(102, nullptr, damagedRects); // 702 ms
987 application.RenderWithPartialUpdate(damagedRects, clippingRect);
989 DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(index), -1.0f, TEST_LOCATION);
991 // Update dummy property to damangeRect buffer aging
992 actor.SetProperty(Actor::Property::COLOR, Color::GREEN);
994 application.SendNotification();
995 damagedRects.clear();
996 application.PreRenderWithPartialUpdate(16, nullptr, damagedRects); // 718 ms
997 application.RenderWithPartialUpdate(damagedRects, clippingRect);
999 // Update dummy property to damangeRect buffer aging
1000 actor.SetProperty(Actor::Property::COLOR, Color::BLUE);
1002 application.SendNotification();
1003 damagedRects.clear();
1004 application.PreRenderWithPartialUpdate(16, nullptr, damagedRects); // 734 ms
1005 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1007 // Update dummy property to damangeRect buffer aging
1008 actor.SetProperty(Actor::Property::COLOR, Color::RED);
1010 application.SendNotification();
1011 damagedRects.clear();
1012 application.PreRenderWithPartialUpdate(16, nullptr, damagedRects); // 750 ms
1013 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1015 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1017 // Now current actor show as 60x60 rectangle, with center position (96, 96).
1018 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
1020 application.SendNotification();
1021 damagedRects.clear();
1022 application.PreRenderWithPartialUpdate(52, nullptr, damagedRects); // 1002 ms. animation finished.
1023 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1025 // Check finished value bake.
1026 DALI_TEST_EQUALS(renderer.GetProperty<float>(index), -1.0f, TEST_LOCATION);