1 #ifndef __DALI_PEPPER_INTERNAL_OUTPUT_H__
2 #define __DALI_PEPPER_INTERNAL_OUTPUT_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.
22 #include <pepper-dali/internal/output.h>
23 #include <pepper-dali/internal/object.h>
26 #include <dali/public-api/common/intrusive-ptr.h>
27 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/object/base-object.h>
29 #include <dali/public-api/signals/connection-tracker.h>
30 #include <dali/integration-api/adaptors/thread-synchronization-interface.h>
31 #include <pepper-output-backend.h>
34 #include <dali/public-api/adaptor-framework/timer.h>
46 typedef IntrusivePtr<Output> OutputPtr;
48 class Output : public BaseObject, public ConnectionTracker, public ThreadSynchronizationInterface
52 static OutputPtr New( Pepper::Compositor compositor, Application application, Pepper::Input input );
54 static void OnDestroy( void* data );
55 static int32_t OnGetSubpixelOrder( void* data );
56 static const char* OnGetMakerName( void* data );
57 static const char* OnGetModelName( void* data );
58 static int OnGetModeCount( void* data );
59 static void OnGetMode( void* data, int index, pepper_output_mode_t* mode );
60 static pepper_bool_t OnSetMode( void* data, const pepper_output_mode_t* mode );
61 static void OnAssignPlanes( void* data, const pepper_list_t* viewList );
62 static void OnStartRepaintLoop( void* data );
63 static void OnRepaint( void* data, const pepper_list_t* planeList );
64 static void OnAttachSurface( void* data, pepper_surface_t* surface, int* width, int* height );
65 static void OnFlushSurface( void* data, pepper_surface_t* surface, pepper_bool_t* keepBuffer );
69 Pepper::Output::OutputSignalType& ObjectViewAddedSignal();
70 Pepper::Output::OutputSignalType& ObjectViewDeletedSignal();
75 * Construct a new Output.
80 * A reference counted object may only be deleted by calling Unreference()
85 * Second-phase constructor. Must be called immediately after creating a new Output;
87 void Initialize( Pepper::Compositor& compositor, Application application, Pepper::Input input );
89 void OnResize( Application& application );
91 void OnObjectViewAdded( Pepper::Object object, Pepper::ObjectView objectView );
92 void OnObjectViewDeleted( Pepper::Object object, Pepper::ObjectView objectView );
94 private: // From ThreadSynchronizationInterface
96 /////////////////////////////////////////////////////////////////////////////////////////////////
97 // Called by the Event Thread if post-rendering is required
98 /////////////////////////////////////////////////////////////////////////////////////////////////
101 * @copydoc ThreadSynchronizationInterface::PostRenderComplete()
103 virtual void PostRenderComplete();
105 /////////////////////////////////////////////////////////////////////////////////////////////////
106 //// Called by the Render Thread if post-rendering is required
107 /////////////////////////////////////////////////////////////////////////////////////////////////
110 * @copydoc ThreadSynchronizationInterface::PostRenderStarted()
112 virtual void PostRenderStarted();
115 * @copydoc ThreadSynchronizationInterface::PostRenderStarted()
117 virtual void PostRenderWaitForCompletion();
120 bool OnRenderFinishTimerTick();
125 Output( const Output& );
128 Output& operator=( const Output& rhs );
132 Pepper::Compositor mCompositor;
136 Pepper::Input mInput;
137 std::vector<Pepper::Object> mObjectList;
139 pepper_output_t* mOutput;
140 pepper_plane_t* mPrimaryPlane;
143 Pepper::Output::OutputSignalType mObjectViewAddedSignal;
144 Pepper::Output::OutputSignalType mObjectViewDeletedSignal;
146 bool mRepaintRequest;
149 Timer mRenderFinishTimer;
152 } // namespace Internal
154 // Helpers for public-api forwarding methods
156 inline Pepper::Internal::Output& GetImplementation( Pepper::Output& output )
158 DALI_ASSERT_ALWAYS( output && "Output handle is empty" );
160 BaseObject& handle = output.GetBaseObject();
162 return static_cast< Internal::Output& >( handle );
165 inline const Pepper::Internal::Output& GetImplementation( const Pepper::Output& output )
167 DALI_ASSERT_ALWAYS( output && "Output handle is empty" );
169 const BaseObject& handle = output.GetBaseObject();
171 return static_cast< const Internal::Output& >( handle );
174 } // namespace Pepper
178 #endif // __DALI_PEPPER_INTERNAL_OUTPUT_H__