NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
2d_render_target_init_settings_helper.h
Go to the documentation of this file.
1 #ifndef SDK_2D_RENDER_TARGET_INIT_SETTINGS_HELPER_H_
13 #define SDK_2D_RENDER_TARGET_INIT_SETTINGS_HELPER_H_
14 
15 #include <string>
16 #include <map>
17 #include <base/inc/platform.h>
18 #include <base/inc/sdk_results.h>
19 #include <base/inc/sdk_ref_ptr.h>
23 #include "../os_specific_types.h"
24 #include "../2d_render_target_init_settings_interface.h"
25 
26 #include <base/inc/sdk_pshpack1.h>
27 
28 namespace sdk {
29 namespace gfx {
30 
33 SDK_PACK(struct SkiaFBOParameters
34 {
35  SDKUInt32 viewport_width;
36  SDKUInt32 viewport_height;
37  PixelFormats pixel_format;
38  SDKUInt32 samples_count;
39  SDKUInt32 stencil_buff_bits;
40  SDKUInt32 fbo_id;
41 });
42 
45 SDK_PACK(struct SkiaTextureParameters
46 {
47  SDKUInt32 viewport_width;
48  SDKUInt32 viewport_height;
49  PixelFormats pixel_format;
50  SDKUInt32 samples_count;
51  SDKUInt32 texture_id;
52 });
53 
58 
60 
61 {
62  public:
65  virtual SDKResult SDK_CALLTYPE SetProperty(const SDKString& id,
66  const SDKAny& value) throw() {
68  } // Property value can't be changed
69  virtual SDKResult SDK_CALLTYPE GetProperty(const SDKString& id,
70  SDKAny& value) const throw();
71 
73  virtual SDKAtomicRefCount SDK_CALLTYPE AddRef() const throw();
74  virtual SDKAtomicRefCount SDK_CALLTYPE Release() const throw();
75  virtual SDKResult SDK_CALLTYPE GetInterface(const InterfaceId& id,
76  void** obj_ptr) throw();
78 
79  // Note, that Render target supports only square pixel, that means, that
80  // DPI by Ox should be equal to DPI by Oy. In case they are not equal -
81  // maximum of both DPIs will be used
82 #if defined(SDK_OS_WIN) && defined(SDK_GRAPHICS_USE_DIRECTX_10_1) // Direct2D specific
85  const D2D1_RENDER_TARGET_PROPERTIES* common_props,
86  RenderTargetInitSettingsSP& settings) throw();
87 
90  const HWND hwnd, // HWND handle, the D2D1_HWND_RENDER_TARGET_PROPERTIES.hwnd will be ignored
91  const D2D1_HWND_RENDER_TARGET_PROPERTIES* hwnd_props, // If NULL - default settings will be used
92  const D2D1_RENDER_TARGET_PROPERTIES* common_props, // If NULL - default settings will be used
93  RenderTargetInitSettingsSP& settings) throw();
94 
97  const IDXGISurface* dxgi_surface, // DXGI surface
98  const D2D1_RENDER_TARGET_PROPERTIES* common_props, // If NULL - default settings will be used
99  RenderTargetInitSettingsSP& settings) throw();
100 #endif // SDK_OS_WIN && SDK_GRAPHICS_USE_DIRECTX_10_1
101 
104  const OpenGLGraphicsDeviceContext& context, RenderTargetInitSettingsSP& settings) throw();
105 
108  const OpenGLGraphicsDeviceContext& context,
109  const SkiaFBOParameters& fbo_parameters,
110  RenderTargetInitSettingsSP& settings) throw();
111 
114  const OpenGLGraphicsDeviceContext& context,
115  const SkiaTextureParameters& texture_parameters,
116  RenderTargetInitSettingsSP& settings) throw();
117 
120  const OSWindow& window, RenderTargetInitSettingsSP& settings) throw();
121 
124  const sdk::vis::scene::ITextureSP& texture,
125  RenderTargetInitSettingsSP& settings) throw();
126 
128  protected:
133 
134 #if defined(SDK_OS_WIN) && defined(SDK_GRAPHICS_USE_DIRECTX_10_1) // Direct2D specific properties
135  virtual SDKResult InitWithCommonD2DProperties(
137  const D2D1_RENDER_TARGET_PROPERTIES& common_props) throw();
138 #endif // SDK_OS_WIN && SDK_GRAPHICS_USE_DIRECTX_10_1
139 
141  virtual SDKResult InitWithOSGraphicsContexts(
142  const OpenGLGraphicsDeviceContext& context) throw();
143 
145  virtual SDKResult SetPropertyImpl(const wchar_t* id, const SDKAny& value) throw();
146 
147  private:
150  void operator=(const RenderTargetInitSettingsHelper&);
151 
152  private:
153  // Number of references
154  mutable SDKAtomicRefCount m_ref;
155 
156  // Properties storage
157  typedef std::map<std::wstring, sdk::SDKAnyHandler> PropertiesMap;
158  PropertiesMap m_properties;
159 
160 #if defined(SDK_OS_WIN) && defined(SDK_GRAPHICS_USE_DIRECTX_10_1)
161  // In case the render target type is RenderTarget2D_Direct2D_DXGI
162  // the references count to given object will be
163  // increased in order to hold a strong link to it, due of SDKAny does not
164  // counts references for COM objects
165  typedef SDKRefPtr<IDXGISurface> DXGISurfaceSP;
166  DXGISurfaceSP m_dxgi_surface;
167 #endif // SDK_OS_WIN && SDK_GRAPHICS_USE_DIRECTX_10_1
168 };
170 
171 } // namespace gfx
172 } // namespace sdk
173 
174 #include <base/inc/sdk_poppack.h>
175 
176 #endif // SDK_2D_RENDER_TARGET_INIT_SETTINGS_HELPER_H_
sdk::gfx::PixelFormats
PixelFormats
Supported pixel formats for render targets.
Definition: 2d_graphics_consts.h:24
sdk::gfx::RenderTargetInitSettingsHelper
Helper class, which allows to create an implementation of I2DRenderTargetInitSettings,...
Definition: 2d_render_target_init_settings_helper.h:57
sdk_results.h
A list of SDK error/return results.
sdk_ref_ptr.h
Interfaces wrapper with reference count control.
InterfaceId
Uuid InterfaceId
Definition of interface UUID.
Definition: sdk_uuid.h:45
sdk::gfx::RenderTargetInitSettingsHelper::CreateRenderTargetInitSettings
static SDKResult CreateRenderTargetInitSettings(const OpenGLGraphicsDeviceContext &context, RenderTargetInitSettingsSP &settings)
Initial settings for RenderTarget2D_SKIA_OpenGL_Context render target type.
sdk::ISDKNamedProperties::SetProperty
virtual SDKResult SDK_CALLTYPE SetProperty(const SDKString &id, const SDKAny &value)=0
Sets a property value.
SDKResult
SDKInt32 SDKResult
Type of all error or return codes which SDK functions can end with.
Definition: sdk_results.h:17
sdk::ISDKNamedProperties::GetProperty
virtual SDKResult SDK_CALLTYPE GetProperty(const SDKString &id, SDKAny &value) const =0
Retrieves a property value.
texture_interface.h
Definition of graphic texture interfaces.
SDKRefPtr
A smart pointer class for managing SDK components interface pointers.
Definition: sdk_ref_ptr.h:23
sdk_component_interface.h
Common base SDK interfaces.
platform.h
Describes the platform constants.
kSDKResult_NotImplemented
static const SDKResult kSDKResult_NotImplemented
Not implemented.
Definition: sdk_results.h:70
sdk::gfx::I2DRenderTargetInitSettings
Base interface for initialization of new Render Target.
Definition: 2d_render_target_init_settings_interface.h:56
sdk_any_handler.h
Wrappers for work with SDKAny instance.