9821cdef55de2e58026af7f7172bafb3f71fa35e
[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 Flora License, Version 1.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://floralicense.org/license/
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 #include "resource-loader-debug.h"
18
19 #if defined(DEBUG_ENABLED)
20
21 #include <iostream>
22 #include <sstream>
23 #include <string>
24 #include <dali/integration-api/glyph-set.h>
25
26 namespace Dali
27 {
28 namespace SlpPlatform
29 {
30 using namespace Dali::Integration;
31
32 /**
33  * Filter for resource loader debug. Change levels here to turn on debugging
34  */
35 Debug::Filter* gLoaderFilter = Debug::Filter::New(Debug::Concise, false, "LOG_RESOURCE_LOADER");
36
37
38 std::string DebugRequestList(TextResourceType::CharacterList& chars)
39 {
40   std::string textString;
41
42   for(std::size_t i=0, length=chars.size(); i<length; i++)
43   {
44     std::ostringstream oss;
45     const TextResourceType::GlyphPosition& glyph = chars[i];
46     oss << static_cast<char>(glyph.character) << "(" << glyph.xPosition << "," << glyph.yPosition
47         << " " << (glyph.quality?"Hg":"Lw") << " " << (glyph.loaded?"LD":"UN") << ") ";
48     textString.append(oss.str());
49   }
50   return textString;
51 }
52
53 std::string DebugResourceList(LoadedResource& partialResource)
54 {
55   GlyphSetPointer glyphSet = static_cast<GlyphSet*>(partialResource.resource.Get());
56   const GlyphSet::CharacterList& characterList = glyphSet->GetCharacterList();
57   std::string textString;
58
59   for(std::size_t i=0, length=characterList.size(); i<length; i++)
60   {
61     std::ostringstream oss;
62     const GlyphMetrics& gm = characterList[i].second;
63     oss << static_cast<char>(gm.code) << "(" << gm.xPosition << "," << gm.yPosition
64         << " " << (gm.quality?"H":"L") << ") ";
65     textString.append(oss.str());
66   }
67   return textString;
68 }
69
70 } //SlpPlatform
71 } //Dali
72
73 #endif