Dali 3D User Interface Engine
resource-bitmap-requester.cpp
Go to the documentation of this file.
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 // CLASS HEADER
20 
21 // EXTERNAL INCLUDES
23 
24 // INTERNAL INCLUDES
25 #include "network/file-download.h"
26 #include "network/http-utils.h"
27 
28 using namespace Dali::Integration;
29 
30 namespace Dali
31 {
32 namespace TizenPlatform
33 {
34 namespace
35 {
37 {
40 };
41 }// unnamed namespace
42 
43 ResourceBitmapRequester::ResourceBitmapRequester( ResourceLoader& resourceLoader )
44 : ResourceRequesterBase( resourceLoader ),
45  mThreadImageLocal( NULL ),
46  mThreadImageRemote( NULL )
47 {
48 }
49 
51 {
52  delete mThreadImageLocal;
53  delete mThreadImageRemote;
54 }
55 
57 {
58  if( mThreadImageLocal )
59  {
61  }
62  if( mThreadImageRemote )
63  {
65  }
66 }
67 
69 {
70  if( mThreadImageLocal )
71  {
73  }
74  if( mThreadImageRemote )
75  {
77  }
78 }
79 
81 {
82  DALI_ASSERT_DEBUG( (0 != dynamic_cast<BitmapResourceType*>(request.GetType())) && "Only requsts for bitmap resources can ever be routed to ResourceBitmapRequester.\n");
83  BitmapResourceType* resType = static_cast<BitmapResourceType*>(request.GetType());
84  if( !resType )
85  {
86  return;
87  }
88 
89  // Work out what thread to decode / load the image on:
91 
92  // Work out if the resource is in memory, a file, or in a remote server:
94 
95  // if resource exists already, then it just needs decoding
96  if( request.GetResource().Get() )
97  {
99  }
100  else
101  {
102  const std::string& resourcePath = request.GetPath();
103  if( Network::IsHttpUrl( resourcePath) )
104  {
106  scheme = NETWORK_RESOURCE;
107  }
108  else
109  {
110  requestType = ResourceThreadBase::RequestLoad;
111  }
112  }
113 
114  // Dispatch the job to the right thread
115  // lazily create the thread
116  if( scheme == FILE_SYSTEM_RESOURCE )
117  {
118  if( !mThreadImageLocal )
119  {
121  }
122  mThreadImageLocal->AddRequest( request, requestType );
123  }
124  else
125  {
126  if( !mThreadImageRemote )
127  {
129  }
130  mThreadImageRemote->AddRequest( request, requestType );
131  }
132 }
133 
135 {
136  // Nothing to do
138 }
139 
141 {
142  if( mThreadImageLocal )
143  {
145  }
146  if( mThreadImageRemote )
147  {
149  }
150 }
151 
152 } // TizenPlatform
153 } // Dali
Dali Docs Home
Read more about Dali