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.

Cheers,
Andre'

>From 17f2a2ba4034d27aea3ad1ed6882d298bf1c52b9 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 7/7] 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 |    6 +++---
 proxy/requestor/idirectfbsurface_requestor.c   |    6 +++---
 src/display/idirectfbsurface.c                 |   10 +++++-----
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/directfb.h b/include/directfb.h
index 12d38ef..fd4381e 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
+          int              *addr
      );
 
      /*
diff --git a/proxy/dispatcher/idirectfbsurface_dispatcher.c b/proxy/dispatcher/idirectfbsurface_dispatcher.c
index bd58500..9339ac2 100644
--- a/proxy/dispatcher/idirectfbsurface_dispatcher.c
+++ b/proxy/dispatcher/idirectfbsurface_dispatcher.c
@@ -251,8 +251,8 @@ IDirectFBSurface_Dispatcher_Lock( IDirectFBSurface *thiz,
 }
 
 static DFBResult
-IDirectFBSurface_Dispatcher_GetFramebufferOffset( IDirectFBSurface *thiz,
-                                                  int              *offset )
+IDirectFBSurface_Dispatcher_GetPhysicalAddress( IDirectFBSurface *thiz,
+                                                int              *addr )
 {
      DIRECT_INTERFACE_GET_DATA(IDirectFBSurface_Dispatcher)
 
@@ -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..4b16693 100644
--- a/proxy/requestor/idirectfbsurface_requestor.c
+++ b/proxy/requestor/idirectfbsurface_requestor.c
@@ -408,8 +408,8 @@ IDirectFBSurface_Requestor_Lock( IDirectFBSurface *thiz,
 }
 
 static DFBResult
-IDirectFBSurface_Requestor_GetFramebufferOffset( IDirectFBSurface *thiz,
-                                                 int              *offset )
+IDirectFBSurface_Requestor_GetPhysicalAddress( IDirectFBSurface *thiz,
+                                               int              *addr )
 {
      DIRECT_INTERFACE_GET_DATA(IDirectFBSurface_Requestor)
 
@@ -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..689e362 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,
+                                     int              *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