<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>116542</bug_id>
          
          <creation_ts>2013-05-21 08:45:46 -0700</creation_ts>
          <short_desc>[BlackBerry] Don&apos;t use reinterpret_cast to convert to TransformationMatrix</short_desc>
          <delta_ts>2014-01-09 21:08:27 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit BlackBerry</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jakob Petsovits">jpetsovits</reporter>
          <assigned_to name="Jakob Petsovits">jpetsovits</assigned_to>
          <cc>andersca</cc>
    
    <cc>anilsson</cc>
    
    <cc>commit-queue</cc>
    
    <cc>rwlbuis</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>891795</commentid>
    <comment_count>0</comment_count>
    <who name="Jakob Petsovits">jpetsovits</who>
    <bug_when>2013-05-21 08:45:46 -0700</bug_when>
    <thetext>We&apos;re currently using reinterpret_cast in WebPageCompositor::render() to convert from a BlackBerry::Platform::TransformationMatrix to a WebCore::TransformationMatrix. This is especially bad since the BlackBerry::Platform one uses column-major storage and the WebCore one stores its values in row-major layout. It basically only worked because so far we&apos;re using an extremely limited subset of potential transformation matrices.

Fixed by the patch below.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>891797</commentid>
    <comment_count>1</comment_count>
      <attachid>202435</attachid>
    <who name="Jakob Petsovits">jpetsovits</who>
    <bug_when>2013-05-21 08:48:42 -0700</bug_when>
    <thetext>Created attachment 202435
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>891922</commentid>
    <comment_count>2</comment_count>
    <who name="Arvid Nilsson">anilsson</who>
    <bug_when>2013-05-21 11:45:14 -0700</bug_when>
    <thetext>While the reinterpret_cast may be ugly, I don&apos;t agree that WebCore::TransformationMatrix is row major - I think the commit message is misleading. TransformationMatrix order was swapped by Chromium devs quite a while ago.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>891923</commentid>
    <comment_count>3</comment_count>
    <who name="Arvid Nilsson">anilsson</who>
    <bug_when>2013-05-21 11:48:52 -0700</bug_when>
    <thetext>I also note that the range of transformation matrices used by CSS3 Transforms is not at all limited, and converts successfully to BB::P::TransformationMatrix every frame. It&apos;s then passed directly to OpenGL down in platform, and OpenGL expects column major matrices (according to some accounts, not 100% sure about GL ES2 actually)...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>891954</commentid>
    <comment_count>4</comment_count>
    <who name="Jakob Petsovits">jpetsovits</who>
    <bug_when>2013-05-21 12:48:35 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; While the reinterpret_cast may be ugly, I don&apos;t agree that WebCore::TransformationMatrix is row major - I think the commit message is misleading. TransformationMatrix order was swapped by Chromium devs quite a while ago.

My math is not great, but let me get the facts together here.

(1) http://en.wikipedia.org/wiki/Row-major_order row-major order means that an array of
1 2 3
4 5 6
is laid out in memory as { { 1, 2, 3 }, { 4, 5, 6 } }. That means the element with value 4 is located at m_matrix[1][0].

(2) According to the handy graphic at http://en.wikipedia.org/wiki/Matrix_%28mathematics%29 and its caption, a matrix descriptor a(2,1) represents the element in the second row, first column of the matrix.

(3) Wolfram Alpha, http://en.wikipedia.org/wiki/Translation_%28geometry%29 as well as your favourite math textbook state that translation elements are on the right edge of a 4x4 matrix, starting with x from the top. That means x translation is at a(1,4), y is at a(2,4) and z at a(3,4).

(4) For the x and y translation elements, aliased as methods e() and f(), WebCore::TransformationMatrix returns m_matrix[3][0] and m_matrix[3][1]. In a row-major matrix, these values would correspond to a(4,1) and a(4,2). However according to (3) this is not the case, and therefore WebCore::TransformationMatrix is column-major. (i.e. you&apos;re right)

(5) WebCore::TransformationMatrix::m14() returns m_matrix[0][3], which means WebCore&apos;s matrix accessor methods are an outright misnomer, or confusing at best.

(6) The BlackBerry::Platform::TransformationMatrix constructor assigns its arguments in the same order and with the same names as WebCore::TransformationMatrix, but then assigns them to the mathematically correct position instead. As determined above, mathematically correct means codewise incorrect. Consequently, I&apos;ll go off to change BlackBerry::Platform instead and will hopefully figure out what to do about the mIJ() accessor naming.

It seems this patch won&apos;t be necessary, then. Let me confirm and close later if this is the case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>891995</commentid>
    <comment_count>5</comment_count>
    <who name="Arvid Nilsson">anilsson</who>
    <bug_when>2013-05-21 13:54:45 -0700</bug_when>
    <thetext>I&apos;m probably guilty of the BB::P::TransformationMatrix constructor being wrong - because of all the reinterpret_cast going on, it was probably dead code until now...
.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>202435</attachid>
            <date>2013-05-21 08:48:42 -0700</date>
            <delta_ts>2013-05-21 20:07:51 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-116542-20130521154719.patch</filename>
            <type>text/plain</type>
            <size>2504</size>
            <attacher name="Jakob Petsovits">jpetsovits</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTQ5NjI0CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L2Js
YWNrYmVycnkvQ2hhbmdlTG9nIGIvU291cmNlL1dlYktpdC9ibGFja2JlcnJ5L0NoYW5nZUxvZwpp
bmRleCA3ZjczYmZjN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BoaWNzOjpHTEVTMkNvbnRleHQqKQo=
</data>
<flag name="review"
          id="223844"
          type_id="1"
          status="+"
          setter="andersca"
    />
    <flag name="commit-queue"
          id="223845"
          type_id="3"
          status="-"
          setter="jpetsovits"
    />
          </attachment>
      

    </bug>

</bugzilla>