Add a GeneralPattern class to Moz2D to solve the problem of writing general pattern creation functions

RESOLVED FIXED in mozilla35

Status

()

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: jwatt, Assigned: jwatt)

Tracking

Trunk
mozilla35
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 3 obsolete attachments)

Assignee

Description

5 years ago
No description provided.
Assignee

Comment 1

5 years ago
Posted patch patch (obsolete) — Splinter Review
Attachment #8495694 - Flags: review?(bas)
Assignee

Comment 2

5 years ago
An alternative to the Init* functions would be to replace them with a function that returns an address for use with the placement operator:

  Pattern* ctorAddr(PatternType aType) {
    MOZ_ASSERT(!mPattern);
    switch (aType) {
    case PatternType::COLOR:
      return mPattern = mColorPattern.addr();
    case PatternType::LINEAR_GRADIENT:
      return mPattern = mLinearGradientPattern.addr();
    case PatternType::RADIAL_GRADIENT:
      return mPattern = mRadialGradientPattern.addr();
    case PatternType::SURFACE:
      return mPattern = mSurfacePattern.addr();
    default:
      MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected pattern type");
  }

Assuming that in the general pattern creation function the GeneralPattern is aPattern, you'd then initialize a pattern like:

  ColorPattern pattern =
     new (aPattern->ctorAddr(PatternType::COLOR) ColorPattern(color);

instead of:

  ColorPattern pattern = aPattern->InitColorPattern(color);

Other than making calling code a bit more verbose, I'm not totally loving that this would mean assigning to mPattern without actually knowing that the ctorAddr caller is calling the [appropriate] ctor.
Assignee

Comment 3

5 years ago
Attachment #8495694 - Attachment is obsolete: true
Attachment #8495694 - Flags: review?(bas)
Attachment #8495762 - Flags: review?(bas)
Assignee

Comment 4

5 years ago
Attachment #8495764 - Flags: review?(bas)
Assignee

Comment 5

5 years ago
Feel free to r- this part, or just r+ the canvas part (not sure the gfxPattern changes are worth it, given that it's going to go away in the short to medium term).
Attachment #8495765 - Flags: review?(bas)
Assignee

Comment 6

5 years ago
Put in its own file, as requested on IRC.
Attachment #8495764 - Attachment is obsolete: true
Attachment #8495764 - Flags: review?(bas)
Attachment #8496448 - Flags: review?(bas)
Assignee

Comment 7

5 years ago
Attachment #8495765 - Attachment is obsolete: true
Attachment #8495765 - Flags: review?(bas)
Attachment #8496449 - Flags: review?(bas)
Attachment #8495762 - Flags: review?(bas) → review+
Attachment #8496448 - Flags: review?(bas) → review+
Attachment #8496449 - Flags: review?(bas) → review+
You need to log in before you can comment on or make changes to this bug.