Bug 161818 - [Win][Direct2D] Provide Direct2D-based geometry and transform cast operations
Summary: [Win][Direct2D] Provide Direct2D-based geometry and transform cast operations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords:
Depends on:
Blocks: 161817
  Show dependency treegraph
 
Reported: 2016-09-09 14:49 PDT by Brent Fulgham
Modified: 2016-09-13 14:59 PDT (History)
7 users (show)

See Also:


Attachments
Patch (181.91 KB, patch)
2016-09-12 16:58 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (182.19 KB, patch)
2016-09-12 17:05 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (Style red due to MS naming) (191.78 KB, patch)
2016-09-13 11:24 PDT, Brent Fulgham
dino: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2016-09-09 14:49:35 PDT
As a first step for creating a Direct2D backend, make it possible to cast our existing Rect, Point, and other types to and from Direct2D native types.

Do the same for Transforms.
Comment 1 Brent Fulgham 2016-09-12 16:45:50 PDT
This patch grew to enormous size because I discovered that there were no unit tests for these functions.
Comment 2 Brent Fulgham 2016-09-12 16:58:42 PDT
Created attachment 288642 [details]
Patch
Comment 3 WebKit Commit Bot 2016-09-12 17:00:07 PDT
Attachment 288642 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/IntRect.h:179:  D2D1_RECT_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/IntRect.h:180:  D2D1_RECT_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntRectWin.cpp:59:  D2D1_RECT_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntRectWin.cpp:64:  D2D1_RECT_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/FloatSize.h:133:  D2D1_SIZE_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntPointWin.cpp:71:  D2D1_POINT_2F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntPointWin.cpp:76:  D2D1_POINT_2U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/TransformationMatrixDirect2D.cpp:48:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/TransformationMatrixDirect2D.cpp:63:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:42:  D2D_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:43:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:185:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:54:  D2D_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:55:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:370:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntSizeWin.cpp:59:  D2D1_SIZE_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntSizeWin.cpp:64:  D2D1_SIZE_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 17 in 27 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Brent Fulgham 2016-09-12 17:05:15 PDT
Created attachment 288643 [details]
Patch
Comment 5 WebKit Commit Bot 2016-09-12 17:06:57 PDT
Attachment 288643 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/IntRect.h:179:  D2D1_RECT_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/IntRect.h:180:  D2D1_RECT_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntRectWin.cpp:59:  D2D1_RECT_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntRectWin.cpp:64:  D2D1_RECT_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/FloatSize.h:133:  D2D1_SIZE_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntPointWin.cpp:71:  D2D1_POINT_2F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntPointWin.cpp:76:  D2D1_POINT_2U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/TransformationMatrixDirect2D.cpp:48:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/TransformationMatrixDirect2D.cpp:63:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:42:  D2D_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:43:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:185:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:54:  D2D_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:55:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:370:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntSizeWin.cpp:59:  D2D1_SIZE_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntSizeWin.cpp:64:  D2D1_SIZE_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 17 in 27 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Brent Fulgham 2016-09-13 11:24:07 PDT
Created attachment 288705 [details]
Patch (Style red due to MS naming)
Comment 7 WebKit Commit Bot 2016-09-13 11:25:45 PDT
Attachment 288705 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/IntRect.h:179:  D2D1_RECT_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/IntRect.h:180:  D2D1_RECT_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntRectWin.cpp:59:  D2D1_RECT_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntRectWin.cpp:64:  D2D1_RECT_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/FloatRectDirect2D.cpp:42:  D2D1_RECT_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/FloatSize.h:133:  D2D1_SIZE_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntPointWin.cpp:71:  D2D1_POINT_2F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntPointWin.cpp:76:  D2D1_POINT_2U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/FloatPointDirect2D.cpp:41:  D2D_POINT_2F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/FloatSizeDirect2D.cpp:41:  D2D1_SIZE_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/TransformationMatrixDirect2D.cpp:48:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/TransformationMatrixDirect2D.cpp:63:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:42:  D2D_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:43:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/AffineTransform.h:185:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:54:  D2D_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:55:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:370:  D2D1_MATRIX_3X2_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntSizeWin.cpp:59:  D2D1_SIZE_U is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/platform/graphics/win/IntSizeWin.cpp:64:  D2D1_SIZE_F is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 20 in 30 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Brent Fulgham 2016-09-13 11:26:37 PDT
Comment on attachment 288705 [details]
Patch (Style red due to MS naming)

Unfortunately the Direct2D types defined by Microsoft violate our coding conventions.
Comment 9 Dean Jackson 2016-09-13 12:35:20 PDT
Comment on attachment 288705 [details]
Patch (Style red due to MS naming)

View in context: https://bugs.webkit.org/attachment.cgi?id=288705&action=review

> Source/WebCore/platform/graphics/IntPoint.h:144
> +    explicit IntPoint(const D2D1_POINT_2F&); // don't do this implicitly since it's lossy

Nit: Use sentence casing and punctuation.
Comment 10 Brent Fulgham 2016-09-13 12:56:59 PDT
Committed r205871: <http://trac.webkit.org/changeset/205871>
Comment 11 Simon Fraser (smfr) 2016-09-13 13:03:18 PDT
Comment on attachment 288705 [details]
Patch (Style red due to MS naming)

View in context: https://bugs.webkit.org/attachment.cgi?id=288705&action=review

> Source/WebCore/platform/graphics/FloatRect.h:49
> +#include <d2d1.h>

Can't we forward-declare D2D1_RECT_F like we do for other platforms? This is bringing a huge header into a frequently-included WebCore header.

> Source/WebCore/platform/graphics/FloatSize.h:51
> +#include <d2d1.h>

Ditto.

> Source/WebCore/platform/graphics/IntPoint.h:37
> +#include <d2d1.h>

Again.

> Source/WebCore/platform/graphics/IntRect.h:33
> +#include <d2d1.h>

Again.

> Source/WebCore/platform/graphics/IntSize.h:37
> +#include <d2d1.h>

Again.

> Source/WebCore/platform/graphics/win/FloatPointDirect2D.cpp:31
> +#include <d2d1.h>

But the header included it!
Comment 12 Brent Fulgham 2016-09-13 13:12:26 PDT
(In reply to comment #11)
> > Source/WebCore/platform/graphics/FloatRect.h:49
> > +#include <d2d1.h>
> 
> Can't we forward-declare D2D1_RECT_F like we do for other platforms? This is
> bringing a huge header into a frequently-included WebCore header.

I did try that first, but I ran into conflicting typedefs. Our usual trick of typedefing to an opaque struct type didn't work, because they define things like:

typedef struct D2D_RECT_F {
   float ...
} D2D_RECT_F;

typedef D2D_RECT_F D2D1_RECT_F;

So, if I make my own D2D1_RECT_F, it screws up the header includes in various ways.

I might be able to define our headers and cast operators in terms of 'D2D_RECT_F', rather than 'D2D1_RECT_F'.
Comment 13 Brent Fulgham 2016-09-13 14:59:53 PDT
Follow-up patch (to get rid of header includes of <d2d1.h>) landed in r205881.

Committed r205881: <http://trac.webkit.org/changeset/205881>