$(internal_src_dir)/render/gl-resources/frame-buffer-texture.cpp \
$(internal_src_dir)/render/gl-resources/gl-call-debug.cpp \
$(internal_src_dir)/render/gl-resources/gpu-buffer.cpp \
- $(internal_src_dir)/render/gl-resources/native-frame-buffer-texture.cpp \
$(internal_src_dir)/render/gl-resources/native-texture.cpp \
$(internal_src_dir)/render/gl-resources/texture.cpp \
$(internal_src_dir)/render/gl-resources/texture-factory.cpp \
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-#include <dali/internal/render/gl-resources/native-frame-buffer-texture.h>
#include <dali/internal/render/gl-resources/texture-cache.h>
#include <dali/internal/render/renderers/scene-graph-renderer.h>
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
// INTERNAL INCLUDES
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/texture-units.h>
#include <dali/integration-api/debug.h>
FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Context& context)
: Texture( context,
- width, height,
width, height ),
mFrameBufferName(0),
mRenderBufferName(0),
mStencilBufferName(0),
mPixelFormat(Pixel::RGBA8888),
- mBufferFormat(RenderBuffer::COLOR)
+ mBufferFormat(RenderBuffer::COLOR),
+ mNativeImage(NULL)
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, Context& context)
: Texture( context,
- width, height,
width, height ),
mFrameBufferName(0),
mRenderBufferName(0),
mStencilBufferName(0),
mPixelFormat( pixelFormat ),
- mBufferFormat(RenderBuffer::COLOR)
+ mBufferFormat(RenderBuffer::COLOR),
+ mNativeImage(NULL)
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat, Context& context)
: Texture( context,
- width, height,
width, height ),
mFrameBufferName(0),
mRenderBufferName(0),
mStencilBufferName(0),
mPixelFormat( pixelFormat ),
- mBufferFormat( bufferFormat )
+ mBufferFormat( bufferFormat ),
+ mNativeImage(NULL)
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
}
+FrameBufferTexture::FrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context )
+: Texture( context,
+ nativeImage->GetWidth(), nativeImage->GetHeight() ),
+ mFrameBufferName(0),
+ mRenderBufferName(0),
+ mStencilBufferName(0),
+ mPixelFormat( Pixel::RGBA8888 ), // Not really used for nativeImage
+ mBufferFormat(RenderBuffer::COLOR_DEPTH),
+ mNativeImage( nativeImage )
+{
+ DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "NativeFrameBufferTexture created 0x%x\n", &nativeImage );
+}
+
FrameBufferTexture::~FrameBufferTexture()
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
bool FrameBufferTexture::IsFullyOpaque() const
{
- return true;
+ return !HasAlphaChannel();
}
bool FrameBufferTexture::HasAlphaChannel() const
{
+ if( mNativeImage )
+ {
+ return mNativeImage->RequiresBlending();
+ }
+
return false;
}
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
+ if( mNativeImage &&
+ !mNativeImage->GlExtensionCreate() )
+ {
+ DALI_LOG_ERROR( "Error creating native image!" );
+ return false;
+ }
+
mContext.GenTextures(1, &mId);
mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); // bind in unused unit so rebind works the first time
mContext.Bind2dTexture(mId);
mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- // Assign memory for texture in GL memory space
- GLenum pixelFormat = GL_RGBA;
- GLenum pixelDataType = GL_UNSIGNED_BYTE;
- Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);
+ if( mNativeImage )
+ {
+ // platform specific implementation decides on what GL extension to use
+ mNativeImage->TargetTexture();
+ }
+ else
+ {
+ // Assign memory for texture in GL memory space
+ GLenum pixelFormat = GL_RGBA;
+ GLenum pixelDataType = GL_UNSIGNED_BYTE;
+ Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);
- mContext.TexImage2D(GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, NULL);
+ mContext.TexImage2D(GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, NULL);
+ }
// generate frame and render buffer names
mContext.GenFramebuffers(1, &mFrameBufferName);
mContext.DeleteRenderbuffers(1, &mStencilBufferName );
mStencilBufferName = 0;
}
+
+ if( mNativeImage )
+ {
+ mNativeImage->GlExtensionDestroy();
+ mNativeImage.Reset();
+ }
}
} //namespace Internal
FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat, Context& context);
/**
+ * Creates a new texture object
+ * @param[in] nativeImage The NativeImage
+ * @param context The GL context
+ */
+ FrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context );
+
+ /**
* Destructor.
*/
virtual ~FrameBufferTexture();
unsigned int mStencilBufferName;
Pixel::Format mPixelFormat;
RenderBuffer::Format mBufferFormat;
+ NativeImageInterfacePtr mNativeImage; ///< For native FBOs only
/**
* @copydoc Texture::CreateGlTexture
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/gl-resources/native-frame-buffer-texture.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-NativeFrameBufferTexture::NativeFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context)
- : FrameBufferTexture(nativeImage->GetWidth(),
- nativeImage->GetHeight(),
- context),
- mNativeImage(nativeImage)
-{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "NativeFrameBufferTexture created 0x%x\n", &nativeImage );
-}
-
-NativeFrameBufferTexture::~NativeFrameBufferTexture()
-{
- DALI_LOG_INFO (Debug::Filter::gImage, Debug::General, "NativeFrameBufferTexture destroyed\n");
- // GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed
- // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
-}
-
-bool NativeFrameBufferTexture::IsFullyOpaque() const
-{
- return !HasAlphaChannel();
-}
-
-bool NativeFrameBufferTexture::HasAlphaChannel() const
-{
- return mNativeImage->RequiresBlending();
-}
-
-bool NativeFrameBufferTexture::Init()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-
- bool status( true ); // assume success
- if( mFrameBufferName == 0 )
- {
- status = CreateGlTexture();
- }
-
- return status;
-}
-
-bool NativeFrameBufferTexture::CreateGlTexture()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-
- if( mNativeImage->GlExtensionCreate() )
- {
- mContext.GenTextures(1, &mId);
- mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); // bind in unused unit so rebind works the first time
- mContext.Bind2dTexture(mId);
-
- mContext.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data
-
- mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- // platform specific implementation decides on what GL extension to use
- mNativeImage->TargetTexture();
-
- // generate frame and render buffer names
- mContext.GenFramebuffers(1, &mFrameBufferName);
- mContext.GenRenderbuffers(1, &mRenderBufferName);
-
- // Bind render buffer and create 16 depth buffer
- mContext.BindRenderbuffer(GL_RENDERBUFFER, mRenderBufferName);
- mContext.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight);
- }
- else
- {
- DALI_LOG_ERROR( "Error creating native image!" );
- }
-
- return mId != 0;
-}
-
-void NativeFrameBufferTexture::GlCleanup()
-{
- Texture::GlCleanup();
-
- if (mFrameBufferName != 0)
- {
- mContext.DeleteFramebuffers(1, &mFrameBufferName );
- mFrameBufferName = 0;
- }
-
- if (mRenderBufferName != 0)
- {
- mContext.DeleteRenderbuffers(1, &mRenderBufferName );
- mRenderBufferName = 0;
- }
-
- mNativeImage->GlExtensionDestroy();
-
- mNativeImage.Reset();
-}
-
-} //namespace Internal
-
-} //namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_FRAME_BUFFER_NATIVE_IMAGE_TEXTURE_H__
-#define __DALI_INTERNAL_FRAME_BUFFER_NATIVE_IMAGE_TEXTURE_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-// INTERNAL INCLUDES
-#include <dali/internal/render/gl-resources/texture.h>
-#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/**
- * Frame Buffer Texture created from NativeImage.
- * Used as a frame buffer for RenderTask
- */
-class NativeFrameBufferTexture : public FrameBufferTexture
-{
-public:
- /**
- * Creates a new texture object
- * @param[in] nativeImage The NativeImage
- * @param context The GL context
- */
- NativeFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context);
-
- /**
- * Destructor.
- */
- virtual ~NativeFrameBufferTexture();
-
- /**
- * @copydoc Texture::IsFullyOpaque
- */
- virtual bool IsFullyOpaque() const;
-
- /**
- * @copydoc Texture::HasAlphaChannel
- */
- virtual bool HasAlphaChannel() const;
-
- /**
- * @copydoc Texture::Init
- */
- virtual bool Init();
-
-protected:
- /**
- * @copydoc Texture::CreateGlTexture
- */
- virtual bool CreateGlTexture();
-
- /**
- * @copydoc Texture::GlCleanup
- */
- virtual void GlCleanup();
-
-private:
- NativeImageInterfacePtr mNativeImage; ///< reference to NativeImage the Texture was created from
-
-}; // class NativeFrameBufferTexture
-
-} //namespace Internal
-
-} //namespace Dali
-
-#endif // header
-
#include <dali/internal/render/gl-resources/compressed-bitmap-texture.h>
#include <dali/internal/render/gl-resources/native-texture.h>
#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-#include <dali/internal/render/gl-resources/native-frame-buffer-texture.h>
namespace Dali
Internal::Texture* NewFrameBufferTexture( NativeImageInterfacePtr nativeImage,
Context& context )
{
- NativeFrameBufferTexture* texture = new NativeFrameBufferTexture(nativeImage, context);
+ FrameBufferTexture* texture = new FrameBufferTexture(nativeImage, context);
if (!texture->Init())
{
delete texture;
{
}
+Texture::Texture(Context& context,
+ unsigned int width,
+ unsigned int height)
+: mContext(context),
+ mId(0),
+ mSamplerBitfield( 0 ),
+ mWidth(width),
+ mHeight(height),
+ mImageWidth(width),
+ mImageHeight(height)
+{
+}
+
Texture::~Texture()
{
// GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed