Merge branch 'devel/master' into devel/new_mesh
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / native-frame-buffer-texture.cpp
index 89ec442..7899963 100644 (file)
@@ -1,24 +1,26 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * 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
@@ -27,10 +29,9 @@ namespace Dali
 namespace Internal
 {
 
-NativeFrameBufferTexture::NativeFrameBufferTexture( NativeImagePtr nativeImage, Context& context)
+NativeFrameBufferTexture::NativeFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context)
   : FrameBufferTexture(nativeImage->GetWidth(),
                        nativeImage->GetHeight(),
-                       nativeImage->GetPixelFormat(),
                        context),
     mNativeImage(nativeImage)
 {
@@ -46,13 +47,12 @@ NativeFrameBufferTexture::~NativeFrameBufferTexture()
 
 bool NativeFrameBufferTexture::IsFullyOpaque() const
 {
-  // TODO - Should test actual texture...
   return !HasAlphaChannel();
 }
 
 bool NativeFrameBufferTexture::HasAlphaChannel() const
 {
-  return Pixel::HasAlpha(mNativeImage->GetPixelFormat());
+  return mNativeImage->RequiresBlending();
 }
 
 bool NativeFrameBufferTexture::Init()
@@ -75,29 +75,24 @@ bool NativeFrameBufferTexture::CreateGlTexture()
   if( mNativeImage->GlExtensionCreate() )
   {
     mContext.GenTextures(1, &mId);
-    mContext.ActiveTexture(GL_TEXTURE7);  // bind in unused unit so rebind works the first time
+    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_MIN_FILTER, GL_LINEAR);
-    mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     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();
 
-    if (!mFrameBufferName)
-    {
-      // generate frame and render buffer names
-      mContext.GenFramebuffers(1, &mFrameBufferName);
-      mContext.GenRenderbuffers(1, &mRenderBufferName);
+    // 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);
-    }
+    // Bind render buffer and create 16 depth buffer
+    mContext.BindRenderbuffer(GL_RENDERBUFFER, mRenderBufferName);
+    mContext.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight);
   }
   else
   {
@@ -128,7 +123,6 @@ void NativeFrameBufferTexture::GlCleanup()
   mNativeImage.Reset();
 }
 
-
 } //namespace Internal
 
 } //namespace Dali