On Thu, 2009-12-10 at 16:01 +0100, Denis Oliver Kropp wrote:
> Andre DRASZIK wrote:
> > Hi,
> > 
> > it seems, nowadays IDirectFBSurface::GetFramebufferOffset() is not very
> > useful anymore.
> > More importantly, using it can lead to various bugs as it does not
> > necessarily return an offset into framebuffer memory, and if one really
> > were to use that offset, various bad things could happen.
> > 
> > The suggestion is to replace it with
> > IDirectFBSurface::GetPhysicalAddress() which would always return the
> > physical address of the surface, no matter which surface pool it comes
> > from. See patch.
> 
> Thanks for the patch. I was mentioning that issue when the method had been
> added and was proposing the same as you did, but please use unsigned long
> to be 64bit clean.

You are right, attached is an updated version.

Cheers,
Andre'

>From f4427e3202b8833006834b5289a1142874f4c0b4 Mon Sep 17 00:00:00 2001
From: Stephen Gallimore <stephen.gallim...@st.com>
Date: Thu, 10 Dec 2009 14:35:23 +0000
Subject: [PATCH 1/1] surface: replace GetFramebufferOffset() with GetPhysicalAddress()
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

The IDirectFBSurface::GetFramebufferOffset() is not really useful anymore,
as it returns an offset into a memory pool, not necessarily into the
framebuffer memory pool.

Replace it with IDirectFBSurface::GetPhysiclAddress(), that always does what
one might expect.

Signed-off-by: André Draszik <andre.dras...@st.com>
---
 include/directfb.h                             |    8 ++++----
 proxy/dispatcher/idirectfbsurface_dispatcher.c |    8 ++++----
 proxy/requestor/idirectfbsurface_requestor.c   |    8 ++++----
 src/display/idirectfbsurface.c                 |   10 +++++-----
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/directfb.h b/include/directfb.h
index 12d38ef..de05fda 100644
--- a/include/directfb.h
+++ b/include/directfb.h
@@ -3443,13 +3443,13 @@ DEFINE_INTERFACE(   IDirectFBSurface,
      );
 
      /*
-      * Returns the framebuffer offset of a locked surface.
+      * Returns the physical address of a locked surface.
       *
-      * The surface must exist in video memory.
+      * The surface must exist in a video memory pool.
       */
-     DFBResult (*GetFramebufferOffset) (
+     DFBResult (*GetPhysicalAddress) (
           IDirectFBSurface *thiz,
-          int              *offset
+          unsigned long    *addr
      );
 
      /*
diff --git a/proxy/dispatcher/idirectfbsurface_dispatcher.c b/proxy/dispatcher/idirectfbsurface_dispatcher.c
index bd58500..cab5316 100644
--- a/proxy/dispatcher/idirectfbsurface_dispatcher.c
+++ b/proxy/dispatcher/idirectfbsurface_dispatcher.c
@@ -251,12 +251,12 @@ IDirectFBSurface_Dispatcher_Lock( IDirectFBSurface *thiz,
 }
 
 static DFBResult
-IDirectFBSurface_Dispatcher_GetFramebufferOffset( IDirectFBSurface *thiz,
-                                                  int              *offset )
+IDirectFBSurface_Dispatcher_GetPhysicalAddress( IDirectFBSurface *thiz,
+                                                unsigned long    *addr )
 {
      DIRECT_INTERFACE_GET_DATA(IDirectFBSurface_Dispatcher)
 
-     if (!offset)
+     if (!addr)
           return DFB_INVARG;
 
      return DFB_UNIMPLEMENTED;
@@ -1710,7 +1710,7 @@ Construct( IDirectFBSurface *thiz,
      thiz->SetAlphaRamp = IDirectFBSurface_Dispatcher_SetAlphaRamp;
 
      thiz->Lock = IDirectFBSurface_Dispatcher_Lock;
-     thiz->GetFramebufferOffset = IDirectFBSurface_Dispatcher_GetFramebufferOffset;
+     thiz->GetPhysicalAddress = IDirectFBSurface_Dispatcher_GetPhysicalAddress;
      thiz->Unlock = IDirectFBSurface_Dispatcher_Unlock;
      thiz->Flip = IDirectFBSurface_Dispatcher_Flip;
      thiz->SetField = IDirectFBSurface_Dispatcher_SetField;
diff --git a/proxy/requestor/idirectfbsurface_requestor.c b/proxy/requestor/idirectfbsurface_requestor.c
index 105f542..732f890 100644
--- a/proxy/requestor/idirectfbsurface_requestor.c
+++ b/proxy/requestor/idirectfbsurface_requestor.c
@@ -408,12 +408,12 @@ IDirectFBSurface_Requestor_Lock( IDirectFBSurface *thiz,
 }
 
 static DFBResult
-IDirectFBSurface_Requestor_GetFramebufferOffset( IDirectFBSurface *thiz,
-                                                 int              *offset )
+IDirectFBSurface_Requestor_GetPhysicalAddress( IDirectFBSurface *thiz,
+                                               unsigned long    *addr )
 {
      DIRECT_INTERFACE_GET_DATA(IDirectFBSurface_Requestor)
 
-     if (!offset)
+     if (!addr)
           return DFB_INVARG;
 
      D_UNIMPLEMENTED();
@@ -1198,7 +1198,7 @@ Construct( IDirectFBSurface *thiz,
      thiz->SetAlphaRamp = IDirectFBSurface_Requestor_SetAlphaRamp;
 
      thiz->Lock = IDirectFBSurface_Requestor_Lock;
-     thiz->GetFramebufferOffset = IDirectFBSurface_Requestor_GetFramebufferOffset;
+     thiz->GetPhysicalAddress = IDirectFBSurface_Requestor_GetPhysicalAddress;
      thiz->Unlock = IDirectFBSurface_Requestor_Unlock;
      thiz->Flip = IDirectFBSurface_Requestor_Flip;
      thiz->SetField = IDirectFBSurface_Requestor_SetField;
diff --git a/src/display/idirectfbsurface.c b/src/display/idirectfbsurface.c
index c532849..cc5af8a 100644
--- a/src/display/idirectfbsurface.c
+++ b/src/display/idirectfbsurface.c
@@ -462,15 +462,15 @@ IDirectFBSurface_Lock( IDirectFBSurface *thiz,
 }
 
 static DFBResult
-IDirectFBSurface_GetFramebufferOffset( IDirectFBSurface *thiz,
-                                       int *offset )
+IDirectFBSurface_GetPhysicalAddress( IDirectFBSurface *thiz,
+                                     unsigned long    *addr )
 {
      DIRECT_INTERFACE_GET_DATA(IDirectFBSurface)
 
      if (!data->surface)
           return DFB_DESTROYED;
 
-     if (!offset)
+     if (!addr)
           return DFB_INVARG;
 
      if (!data->locked)
@@ -481,7 +481,7 @@ IDirectFBSurface_GetFramebufferOffset( IDirectFBSurface *thiz,
           return DFB_UNSUPPORTED;
      }
 
-     *offset = data->lock.offset;
+     *addr = data->lock.phys;
 
      return DFB_OK;
 }
@@ -2809,7 +2809,7 @@ DFBResult IDirectFBSurface_Construct( IDirectFBSurface       *thiz,
      thiz->SetAlphaRamp = IDirectFBSurface_SetAlphaRamp;
 
      thiz->Lock = IDirectFBSurface_Lock;
-     thiz->GetFramebufferOffset = IDirectFBSurface_GetFramebufferOffset;
+     thiz->GetPhysicalAddress = IDirectFBSurface_GetPhysicalAddress;
      thiz->Unlock = IDirectFBSurface_Unlock;
      thiz->Flip = IDirectFBSurface_Flip;
      thiz->SetField = IDirectFBSurface_SetField;
-- 
1.6.3.3

_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to