Revert "Move new mesh API to devel-api"
[platform/core/uifw/dali-core.git] / dali / internal / event / actor-attachments / renderer-attachment-impl.cpp
1 /*
2  * Copyright (c) 2015 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
19 #include <dali/internal/event/actor-attachments/renderer-attachment-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/common/event-thread-services.h>
23 #include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
24 #include <dali/internal/update/manager/update-manager.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 RendererAttachmentPtr RendererAttachment::New( EventThreadServices& eventThreadServices, const SceneGraph::Node& parentNode, Renderer& renderer )
33 {
34   RendererAttachmentPtr attachment( new RendererAttachment( eventThreadServices ) );
35
36   if( attachment )
37   {
38     attachment->Initialize( eventThreadServices, parentNode, renderer );
39   }
40   return attachment;
41 }
42
43 void RendererAttachment::Initialize( EventThreadServices& eventThreadServices, const SceneGraph::Node& parentNode, Renderer& renderer )
44 {
45   SceneGraph::RendererAttachment* sceneObject = renderer.GetRendererSceneObject();
46
47   // Takes ownership of scene object
48   AttachToNodeMessage( eventThreadServices.GetUpdateManager(), parentNode, sceneObject );
49
50   // Connect to renderer
51   mRendererConnector.Set( renderer, false );
52
53   // Keep raw pointer for message passing
54   mSceneObject = sceneObject;
55 }
56
57 RendererAttachment::RendererAttachment( EventThreadServices& eventThreadServices )
58 : RenderableAttachment(eventThreadServices),
59   mSceneObject(NULL)
60 {
61 }
62
63 RendererAttachment::~RendererAttachment()
64 {
65 }
66
67 const SceneGraph::RendererAttachment& RendererAttachment::GetSceneObject() const
68 {
69   DALI_ASSERT_DEBUG( mSceneObject != NULL );
70   return *mSceneObject;
71 }
72
73 void RendererAttachment::OnStageConnection2()
74 {
75   mRendererConnector.OnStageConnect();
76 }
77
78 void RendererAttachment::OnStageDisconnection2()
79 {
80   mRendererConnector.OnStageDisconnect();
81 }
82
83 } // namespace Internal
84
85 } // namespace Dali