1 #ifndef __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__
2 #define __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/integration-api/bitmap.h>
24 #include <dali/integration-api/resource-types.h>
25 #include <dali/public-api/images/image-operations.h>
26 #include <dali/public-api/common/dali-vector.h>
34 typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
37 * PlatformAbstraction is an abstract interface, used by Dali to access platform specific services.
38 * A concrete implementation must be created for each platform, and provided when creating the
39 * Dali::Integration::Core object.
41 class PlatformAbstraction
48 virtual ~PlatformAbstraction() {}
53 * @brief Determine the size of an image the resource loaders will provide when
54 * given the same image loading parameters.
56 * This is a synchronous request.
57 * This function is used to determine the size of an image before it has loaded.
58 * @param[in] filename name of the image.
59 * @param[in] size The requested size for the image.
60 * @param[in] fittingMode The method to use to map the source image to the desired
62 * @param[in] samplingMode The image filter to use if the image needs to be
63 * downsampled to the requested size.
64 * @param[in] orientationCorrection Whether to use image metadata to rotate or
65 * flip the image, e.g., from portrait to landscape.
66 * @return dimensions that image will have if it is loaded with given parameters.
68 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
69 ImageDimensions size = ImageDimensions( 0, 0 ),
70 FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT,
71 SamplingMode::Type samplingMode = SamplingMode::BOX,
72 bool orientationCorrection = true) = 0;
75 * @brief Determine the size of an image the resource loaders will provide when
76 * given the same image loading parameters.
78 * This is a synchronous request.
79 * This function is used to determine the size of an image before it has loaded.
80 * @param[in] filename name of the image.
81 * @param[in] size The requested size for the image.
82 * @param[in] fittingMode The method to use to map the source image to the desired
84 * @param[in] samplingMode The image filter to use if the image needs to be
85 * downsampled to the requested size.
86 * @param[in] orientationCorrection Whether to use image metadata to rotate or
87 * flip the image, e.g., from portrait to landscape.
88 * @return dimensions that image will have if it is loaded with given parameters.
90 virtual ImageDimensions GetClosestImageSize( ResourcePointer resourceBuffer,
91 ImageDimensions size = ImageDimensions( 0, 0 ),
92 FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT,
93 SamplingMode::Type samplingMode = SamplingMode::BOX,
94 bool orientationCorrection = true) = 0;
97 * Request a resource from the native filesystem. This is a synchronous request, i.e.
98 * it will block the main loop whilst executing. It should therefore be used sparingly.
100 * Multi-threading note: this method will be called from the main thread only i.e. not
101 * from within the Core::Render() method.
102 * @param[in] resourceType The type of resource to load
103 * @param[in] resourcePath The path to the resource
104 * @return A pointer to a ref-counted resource
106 virtual ResourcePointer LoadResourceSynchronously( const ResourceType& resourceType, const std::string& resourcePath ) = 0;
109 * Decode a buffer of data synchronously.
110 * @param[in] resourceType The type of resource to load
111 * @param[in] buffer The decoded data
112 * @param[in] bufferSize The size of the buffer used by the decoded data.
114 * @return A pointer to the decoded buffer.
116 virtual BitmapPtr DecodeBuffer( const ResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 0;
119 * Load a shader binary file into a buffer
120 * @param[in] filename The shader binary filename to load
121 * @param[out] buffer A buffer to receive the file.
122 * @result true if the file is loaded.
124 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const = 0;
127 * Save a shader binary file to the resource file system.
128 * @param[in] filename The shader binary filename to save to.
129 * @param[in] buffer A buffer to write the file from.
130 * @param[in] numbytes Size of the buffer.
131 * @result true if the file is saved, else false.
133 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const = 0;
135 }; // class PlatformAbstraction
137 } // namespace Integration
141 #endif // __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__