Note, you __must__ use a local build and not a distributed build, and you __must__ also build with debug enabled to allow *DALI_ASSERT_DEBUG* to trigger on wrong behaviour ( Which should always be a test case failure! )
+Further note that, for the following, your gcov version must match the version of the compiler.
+
Building the tests
------------------
END_TEST;
}
-Note that **there must be no extra whitespace in the method signature** (i.e., it must violate our coding convention and follow __exactly__ this pattern: `int UtcDaliMyTestcaseName(void)`), as it's parsed by an awk script to auto-generate the testcase arrays in the main header file.
+Note that **the parentheses in the method signature must not be empty** (i.e., it must violate our coding convention and follow __exactly__ this pattern: `int UtcDaliMyTestcaseName(void)`), as it's parsed by an awk script to auto-generate the testcase arrays in the main header file. Neither may any comments on the same line contain empty parentheses.
You can contine to use the TET api, e.g. `tet_infoline`, `tet_result` and our test check methods `DALI_TEST_CHECK`, `DALI_TEST_EQUALS`, etc.
float positions01[] = { 0.f, 8.f, 16.f, 26.f, 33.f, 41.f, 45.f, 54.f, 64.0f };
Size textSize02( 80.f, 100.f );
- float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 10.0f };
+ float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 13.0f };
Size textSize03( 80.f, 100.f );
- float positions03[] = { 74.f, 69.f, 66.f, 61.f, 53.f, 51.f, 47.f, 46.f, 41.f, 31.f, 28.f, 20.f, 7.f };
+ float positions03[] = { 74.f, 69.f, 66.f, 61.f, 53.f, 51.f, 47.f, 46.f, 41.f, 31.f, 28.f, 14.f, 7.f };
Size textSize04( 80.f, 10.f );
float positions04[] = { 2.f };
"<font family='TizenSansArabic'>عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.</font>",
textSize03,
5u,
- 74u,
+ 73u,
positions03
},
{
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
END_TEST;
}
+int UtcDaliImageVisualSynchronousLoadAlphaMask(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Request image visual with a Property::Map containing an Alpha mask with synchronous loading" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
+
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+ DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION );
+
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+
+ actor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor );
+
+ // Do not wait for any EventThreadTrigger in synchronous alpha mask.
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
+
+ dummyImpl.UnregisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1 );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliImageVisualRemoteAlphaMask(void)
{
ToolkitTestApplication application;
Property::Map propertyMap;
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( "alphaMaskUrl", MASK_IMAGE );
+ propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, MASK_IMAGE );
Visual::Base visual = factory.CreateVisual( propertyMap );
DALI_TEST_CHECK( visual );
Property::Map testMap;
visual.CreatePropertyMap(testMap);
+
DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(MASK_IMAGE), TEST_LOCATION );
// For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
DummyControl actor = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+
DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
actor.SetSize( 200.f, 200.f );
END_TEST;
}
-
int UtcDaliImageVisualAlphaMaskCrop(void)
{
ToolkitTestApplication application;
// Need to reshape the glyph as the font may be different in size.
const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) );
- if( !firstPenSet || glyphToRemove.advance == 0.f )
+ if( !firstPenSet || EqualsZero( glyphToRemove.advance ) )
{
const Vector2& position = *( elidedPositionsBuffer + index );
removedGlypsWidth = -ellipsisGlyph.xBearing;
- firstPenSet = true;
+ if( !EqualsZero( firstPenX ) )
+ {
+ firstPenSet = true;
+ }
}
removedGlypsWidth += std::min( glyphToRemove.advance, ( glyphToRemove.xBearing + glyphToRemove.width ) );
void Controller::FitPointSizeforLayout( Size layoutSize )
{
const OperationsMask operations = mImpl->mOperationsPending;
- if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
+ if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) || mImpl->mTextFitContentSize != layoutSize )
{
bool actualellipsis = mImpl->mModel->mElideEnabled;
float minPointSize = mImpl->mTextFitMinSize;
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
AllocateMaskData();
// Immediately trigger the alpha mask loading (it may just get a cached value)
mMaskingData->mAlphaMaskUrl = alphaUrl;
- TextureManager& textureManager = mFactoryCache.GetTextureManager();
- mMaskingData->mAlphaMaskId = textureManager.RequestMaskLoad( alphaUrl );
}
break;
}
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Dali::Vector<char> buffer;
if ( Dali::FileLoader::ReadFile( mImageUrl.GetUrl(), buffer ) )
{
+ buffer.PushBack( '\0' );
mParsedImage = nsvgParse( buffer.Begin(), UNITS, meanDpi );
}
}
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
Devel::PixelBuffer pixelBuffer = LoadImageFromFile( url.GetUrl(), desiredSize, fittingMode, samplingMode,
orientationCorrection );
+ if( maskInfo )
+ {
+ Devel::PixelBuffer maskPixelBuffer = LoadImageFromFile( maskInfo->mAlphaMaskUrl.GetUrl(), ImageDimensions(),
+ FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, true );
+ if( maskPixelBuffer )
+ {
+ pixelBuffer.ApplyMask( maskPixelBuffer, maskInfo->mContentScaleFactor, maskInfo->mCropToMask );
+ }
+ }
if( pixelBuffer )
{
PreMultiply( pixelBuffer, preMultiplyOnLoad );
}
else
{
+ TextureId alphaMaskId = RequestMaskLoad( maskInfo->mAlphaMaskUrl );
textureId = RequestLoad( url,
- maskInfo->mAlphaMaskId,
+ alphaMaskId,
maskInfo->mContentScaleFactor,
desiredSize,
fittingMode, samplingMode,
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 4;
-const unsigned int TOOLKIT_MICRO_VERSION = 53;
+const unsigned int TOOLKIT_MICRO_VERSION = 54;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
#include <math.h>
#define NSVG_PI (3.14159265358979323846264338327f)
-#define NSVG_KAPPA90 (0.5522847493f) // Lenght proportional to radius of a cubic bezier handle for 90deg arcs.
+#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs.
#define NSVG_ALIGN_MIN 0
#define NSVG_ALIGN_MID 1
#define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0)
#define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16))
-#define NSVG_INLINE inline
+#ifdef _MSC_VER
+ #pragma warning (disable: 4996) // Switch off security warnings
+ #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
+ #ifdef __cplusplus
+ #define NSVG_INLINE inline
+ #else
+ #define NSVG_INLINE
+ #endif
+#else
+ #define NSVG_INLINE inline
+#endif
static int nsvg__isspace(char c)
shape->fill.color = attr->fillColor;
shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
} else if (attr->hasFill == 2) {
- shape->opacity *= attr->fillOpacity;
float inv[6], localBounds[4];
nsvg__xformInverse(inv, attr->xform);
nsvg__getLocalBounds(localBounds, shape, inv);
// Parse integer part
if (nsvg__isdigit(*cur)) {
// Parse digit sequence
- intPart = (double)strtoll(cur, &end, 10);
+ intPart = strtoll(cur, &end, 10);
if (cur != end) {
res = (double)intPart;
hasIntPart = 1;
// Parse optional exponent
if (*cur == 'e' || *cur == 'E') {
- int expPart = 0;
+ long expPart = 0;
cur++; // skip 'E'
expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
if (cur != end) {
}
}
// exponent
- if (*s == 'e' || *s == 'E') {
+ if ((*s == 'e' || *s == 'E') && (s[1] != 'm' && s[1] != 'x')) {
if (i < last) it[i++] = *s;
s++;
if (*s == '-' || *s == '+') {
{ "gray", NSVG_RGB(128, 128, 128) },
{ "white", NSVG_RGB(255, 255, 255) },
+/**
+ * In the original software, it needs to define "NANOSVG_ALL_COLOR_KEYWORDS" in order to support
+ * the following colors. We have removed this because we want to support all the colors.
+ */
{ "aliceblue", NSVG_RGB(240, 248, 255) },
{ "antiquewhite", NSVG_RGB(250, 235, 215) },
{ "aqua", NSVG_RGB( 0, 255, 255) },
static float nsvg__parseOpacity(const char* str)
{
- float val = nsvg__atof(str);\r
+ float val = nsvg__atof(str);
if (val < 0.0f) val = 0.0f;
if (val > 1.0f) val = 1.0f;
return val;
else if (strcmp(str, "bevel") == 0)
return NSVG_JOIN_BEVEL;
// TODO: handle inherit.
- return NSVG_CAP_BUTT;
+ return NSVG_JOIN_MITER;
}
static char nsvg__parseFillRule(const char* str)
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "width") == 0) {
- p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
+ p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
} else if (strcmp(attr[i], "height") == 0) {
- p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
+ p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
} else if (strcmp(attr[i], "viewBox") == 0) {
const char *s = attr[i + 1];
char buf[64];
return NULL;
}
+NSVGpath* nsvgDuplicatePath(NSVGpath* p)
+{
+ NSVGpath* res = NULL;
+
+ if (p == NULL)
+ return NULL;
+
+ res = (NSVGpath*)malloc(sizeof(NSVGpath));
+ if (res == NULL) goto error;
+ memset(res, 0, sizeof(NSVGpath));
+
+ res->pts = (float*)malloc(p->npts*2*sizeof(float));
+ if (res->pts == NULL) goto error;
+ memcpy(res->pts, p->pts, p->npts * sizeof(float) * 2);
+ res->npts = p->npts;
+
+ memcpy(res->bounds, p->bounds, sizeof(p->bounds));
+
+ res->closed = p->closed;
+
+ return res;
+
+error:
+ if (res != NULL) {
+ free(res->pts);
+ free(res);
+ }
+ return NULL;
+}
+
void nsvgDelete(NSVGimage* image)
{
- if (image == NULL) return;
NSVGshape *snext, *shape;
+ if (image == NULL) return;
shape = image->shapes;
while (shape != NULL) {
snext = shape->next;
// NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose
// to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
//
-// The units passed to NanoVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
+// The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
// DPI (dots-per-inch) controls how the unit conversion is done.
//
// If you don't know or care about the units stuff, "px" and 96 should get you going.
/* Example Usage:
- // Load
- SNVGImage* image;
+ // Load SVG
+ NSVGimage* image;
image = nsvgParseFromFile("test.svg", "px", 96);
printf("size: %f x %f\n", image->width, image->height);
// Use...
- for (shape = image->shapes; shape != NULL; shape = shape->next) {
- for (path = shape->paths; path != NULL; path = path->next) {
- for (i = 0; i < path->npts-1; i += 3) {
+ for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) {
+ for (NSVGpath *path = shape->paths; path != NULL; path = path->next) {
+ for (int i = 0; i < path->npts-1; i += 3) {
float* p = &path->pts[i*2];
drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]);
}
NSVG_PAINT_NONE = 0,
NSVG_PAINT_COLOR = 1,
NSVG_PAINT_LINEAR_GRADIENT = 2,
- NSVG_PAINT_RADIAL_GRADIENT = 3,
+ NSVG_PAINT_RADIAL_GRADIENT = 3
};
enum NSVGspreadType {
NSVG_SPREAD_PAD = 0,
NSVG_SPREAD_REFLECT = 1,
- NSVG_SPREAD_REPEAT = 2,
+ NSVG_SPREAD_REPEAT = 2
};
enum NSVGlineJoin {
NSVG_JOIN_MITER = 0,
NSVG_JOIN_ROUND = 1,
- NSVG_JOIN_BEVEL = 2,
+ NSVG_JOIN_BEVEL = 2
};
enum NSVGlineCap {
NSVG_CAP_BUTT = 0,
NSVG_CAP_ROUND = 1,
- NSVG_CAP_SQUARE = 2,
+ NSVG_CAP_SQUARE = 2
};
enum NSVGfillRule {
NSVG_FILLRULE_NONZERO = 0,
- NSVG_FILLRULE_EVENODD = 1,
+ NSVG_FILLRULE_EVENODD = 1
};
enum NSVGflags {
// Important note: changes the string.
NSVGimage* nsvgParse(char* input, const char* units, float dpi);
-// Deletes list of paths.
+// Duplicates a path.
+NSVGpath* nsvgDuplicatePath(NSVGpath* p);
+
+// Deletes an image.
void nsvgDelete(NSVGimage* image);
#endif // NANOSVG_H
void nsvgDeleteRasterizer(NSVGrasterizer* r)
{
- if (r == NULL) return;
-
NSVGmemPage* p;
+ if (r == NULL) return;
+
p = r->pages;
while (p != NULL) {
NSVGmemPage* next = p->next;
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this softwarue
+ * claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
/* Example Usage:
// Load SVG
- struct SNVGImage* image = nsvgParseFromFile("test.svg.");
+ NSVGimage* image;
+ image = nsvgParseFromFile("test.svg", "px", 96);
// Create rasterizer (can be used to render multiple images).
struct NSVGrasterizer* rast = nsvgCreateRasterizer();
// Allocated rasterizer context.
NSVGrasterizer* nsvgCreateRasterizer();
-// Rasterizes SVG image, returns RGBA image (premultiplied alpha)
+// Rasterizes SVG image, returns RGBA image (non-premultiplied alpha)
// r - pointer to rasterizer context
// image - pointer to image to rasterize
// tx,ty - image offset (applied after scaling)
Name: dali-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.4.53
+Version: 1.4.54
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT