Closed Bug 989337 Opened 10 years ago Closed 10 years ago

Convert Canvas2D to typed enums and EnumeratedArray

Categories

(Core :: Graphics: Canvas2D, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31

People

(Reporter: bjacob, Assigned: bjacob)

References

Details

Attachments

(3 files)

      No description provided.
Attachment #8398515 - Attachment description: 1/3: Initial manual changes → 1/3 - Initial manual changes
Comment on attachment 8398515 [details] [diff] [review]
1/3 - Initial manual changes

Review of attachment 8398515 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/canvas/src/CanvasGradient.h
@@ +75,5 @@
>    Type mType;
>    virtual ~CanvasGradient() {}
>  };
>  
> +MOZ_FINISH_NESTED_ENUM_CLASS(CanvasGradient::Type)

This Macro seems a little oddly named to me :) But it looks correct.
Attachment #8398515 - Flags: review?(bas) → review+
Attachment #8398517 - Flags: review?(bas) → review+
Comment on attachment 8398518 [details] [diff] [review]
3/3 - final manual changes

Review of attachment 8398518 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/canvas/src/CanvasRenderingContext2D.h
@@ +916,5 @@
>  
>      nsRefPtr<gfxFontGroup> fontGroup;
> +    EnumeratedArray<Style, Style::MAX, nsRefPtr<CanvasGradient>> gradientStyles;
> +    EnumeratedArray<Style, Style::MAX, nsRefPtr<CanvasPattern>> patternStyles;
> +    EnumeratedArray<Style, Style::MAX, nscolor> colorStyles;

I wonder whether all compilers generate optimal code for this EnumeratedArray class, but I guess it doesn't matter too much.
Attachment #8398518 - Flags: review?(bas) → review+
I wouldn't worry about that at all. I've worked on a array-like container library (matrices really) and went 1000x more crazy than this and compilers these days are good at evaporating this kind of abstraction. Look at EnumeratedArray.h, it's tiny.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: