License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / slp / resource-loader / debug / resource-loader-debug.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "resource-loader-debug.h"
19
20 #if defined(DEBUG_ENABLED)
21
22 #include <iostream>
23 #include <sstream>
24 #include <string>
25 #include <dali/integration-api/glyph-set.h>
26
27 namespace Dali
28 {
29 namespace SlpPlatform
30 {
31 using namespace Dali::Integration;
32
33 /**
34  * Filter for resource loader debug. Change levels here to turn on debugging
35  */
36 Debug::Filter* gLoaderFilter = Debug::Filter::New(Debug::Concise, false, "LOG_RESOURCE_LOADER");
37
38
39 std::string DebugRequestList(TextResourceType::CharacterList& chars)
40 {
41   std::string textString;
42
43   for(std::size_t i=0, length=chars.size(); i<length; i++)
44   {
45     std::ostringstream oss;
46     const TextResourceType::GlyphPosition& glyph = chars[i];
47     oss << static_cast<char>(glyph.character) << "(" << glyph.xPosition << "," << glyph.yPosition
48         << " " << (glyph.quality?"Hg":"Lw") << " " << (glyph.loaded?"LD":"UN") << ") ";
49     textString.append(oss.str());
50   }
51   return textString;
52 }
53
54 std::string DebugResourceList(LoadedResource& partialResource)
55 {
56   GlyphSetPointer glyphSet = static_cast<GlyphSet*>(partialResource.resource.Get());
57   const GlyphSet::CharacterList& characterList = glyphSet->GetCharacterList();
58   std::string textString;
59
60   for(std::size_t i=0, length=characterList.size(); i<length; i++)
61   {
62     std::ostringstream oss;
63     const GlyphMetrics& gm = characterList[i].second;
64     oss << static_cast<char>(gm.code) << "(" << gm.xPosition << "," << gm.yPosition
65         << " " << (gm.quality?"H":"L") << ") ";
66     textString.append(oss.str());
67   }
68   return textString;
69 }
70
71 } //SlpPlatform
72 } //Dali
73
74 #endif