2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/rendering/frame-buffer-impl.h>
22 #include <dali/internal/update/manager/update-manager.h>
23 #include <dali/internal/event/common/stage-impl.h>
24 #include <dali/internal/render/renderers/render-frame-buffer.h>
31 FrameBufferPtr FrameBuffer::New( unsigned int width, unsigned int height, unsigned int attachments )
33 FrameBufferPtr frameBuffer( new FrameBuffer( width, height, attachments ) );
34 frameBuffer->Initialize();
39 Render::FrameBuffer* FrameBuffer::GetRenderObject() const
44 FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments )
45 : mEventThreadServices( *Stage::GetCurrent() ),
46 mRenderObject( NULL ),
50 mAttachments( attachments )
54 void FrameBuffer::Initialize()
56 mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments );
57 AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject );
60 void FrameBuffer::AttachColorTexture( NewTexturePtr texture, unsigned int mipmapLevel, unsigned int layer )
62 if( (unsigned int)( texture->GetWidth() / ( 1 << mipmapLevel ) ) == mWidth &&
63 (unsigned int)( texture->GetHeight() / ( 1 << mipmapLevel ) ) == mHeight )
66 AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer );
70 DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" );
74 NewTexture* FrameBuffer::GetColorTexture()
79 FrameBuffer::~FrameBuffer()
81 if( EventThreadServices::IsCoreRunning() && mRenderObject )
83 RemoveFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject );
88 } // namespace Internal