1 #ifndef __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__
2 #define __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__
5 * Copyright (c) 2018 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>
33 typedef uint32_t ResourceId;
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 * @brief Determine the size of an image the resource loaders will provide when
49 * given the same image loading parameters.
51 * This is a synchronous request.
52 * This function is used to determine the size of an image before it has loaded.
53 * @param[in] filename name of the image.
54 * @param[in] size The requested size for the image.
55 * @param[in] fittingMode The method to use to map the source image to the desired
57 * @param[in] samplingMode The image filter to use if the image needs to be
58 * downsampled to the requested size.
59 * @param[in] orientationCorrection Whether to use image metadata to rotate or
60 * flip the image, e.g., from portrait to landscape.
61 * @return dimensions that image will have if it is loaded with given parameters.
63 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
64 ImageDimensions size = ImageDimensions( 0, 0 ),
65 FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT,
66 SamplingMode::Type samplingMode = SamplingMode::BOX,
67 bool orientationCorrection = true) = 0;
70 * @brief Determine the size of an image the resource loaders will provide when
71 * given the same image loading parameters.
73 * This is a synchronous request.
74 * This function is used to determine the size of an image before it has loaded.
75 * @param[in] filename name of the image.
76 * @param[in] size The requested size for the image.
77 * @param[in] fittingMode The method to use to map the source image to the desired
79 * @param[in] samplingMode The image filter to use if the image needs to be
80 * downsampled to the requested size.
81 * @param[in] orientationCorrection Whether to use image metadata to rotate or
82 * flip the image, e.g., from portrait to landscape.
83 * @return dimensions that image will have if it is loaded with given parameters.
85 virtual ImageDimensions GetClosestImageSize( ResourcePointer resourceBuffer,
86 ImageDimensions size = ImageDimensions( 0, 0 ),
87 FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT,
88 SamplingMode::Type samplingMode = SamplingMode::BOX,
89 bool orientationCorrection = true) = 0;
92 * Request an image from the native filesystem. This is a synchronous request, i.e.
93 * it will block the main loop whilst executing.
95 * Multi-threading note: this method will be called from the main thread only i.e. not
96 * from within the Core::Render() method.
97 * @param[in] resourceType The type of resource to load
98 * @param[in] resourcePath The path to the resource
99 * @return A pointer to a ref-counted resource
101 virtual ResourcePointer LoadImageSynchronously( const BitmapResourceType& resourceType, const std::string& resourcePath ) = 0;
104 * Decode a buffer of data synchronously.
105 * @param[in] resourceType The type of resource to load
106 * @param[in] buffer The decoded data
107 * @param[in] bufferSize The size of the buffer used by the decoded data.
109 * @return A pointer to the decoded buffer.
111 virtual BitmapPtr DecodeBuffer( const BitmapResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 0;
114 * Load a shader binary file into a buffer
115 * @param[in] filename The shader binary filename to load
116 * @param[out] buffer A buffer to receive the file.
117 * @result true if the file is loaded.
119 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< uint8_t >& buffer ) const = 0;
122 * Save a shader binary file to the resource file system.
123 * @param[in] filename The shader binary filename to save to.
124 * @param[in] buffer A buffer to write the file from.
125 * @param[in] numbytes Size of the buffer.
126 * @result true if the file is saved, else false.
128 virtual bool SaveShaderBinaryFile( const std::string& filename, const uint8_t * buffer, uint32_t numBytes ) const = 0;
133 * Virtual destructor.
135 virtual ~PlatformAbstraction() {}
137 }; // class PlatformAbstraction
139 } // namespace Integration
143 #endif // __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__