Closed Bug 1299164 Opened 8 years ago Closed 8 years ago

Add BufferSizeFromDimensions in addition to BufferSizeFromStrideAndHeight

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: milan, Assigned: milan)

References

Details

(Whiteboard: [gfx-noted])

Attachments

(2 files)

We have a convenient BufferSizeFromStrideAndHeight utility function that takes stride (usually width * byte count) and height. Add a utility function to take all three.
Assignee: nobody → milan
Whiteboard: [gfx-noted]
Comment on attachment 8786455 [details] Bug 1299164: Part 1. Add BufferSizeFromDimensions method to complement BufferSizeFromStrideAndHeight. https://reviewboard.mozilla.org/r/75406/#review73564 ::: gfx/2d/DataSurfaceHelpers.cpp:268 (Diff revision 1) > size_t > BufferSizeFromStrideAndHeight(int32_t aStride, > int32_t aHeight, > int32_t aExtraBytes) > { > - if (MOZ_UNLIKELY(aHeight <= 0)) { > + return BufferSizeFromDimensions(aStride, aHeight, 1, aExtraBytes); Not a huge fan of passing stride to height. Maybe we should name it stride in BufferSizeFromDimension as well? I'll leave this up to you to decide.
Attachment #8786455 - Flags: review?(bas) → review+
Comment on attachment 8786456 [details] Bug 1299164: Part 2. Use BufferSizeFromDimensions method, as well as some of the others that check for valid size. https://reviewboard.mozilla.org/r/75408/#review73566
Attachment #8786456 - Flags: review?(bas) → review+
Comment on attachment 8786455 [details] Bug 1299164: Part 1. Add BufferSizeFromDimensions method to complement BufferSizeFromStrideAndHeight. https://reviewboard.mozilla.org/r/75406/#review73564 > Not a huge fan of passing stride to height. Maybe we should name it stride in BufferSizeFromDimension as well? I'll leave this up to you to decide. I agree, the readability is important. Given that it was suffering with trying to save a few lines of "duplicated" code, and it led to an extra function call, I separated the two functions - BufferSizeFromStrideAndHeight does not call BufferSizeFromDimensions anymore. The problem above goes away and things are a bit cleaner. I don't anticipate big changes to these functions, but if we make them to one, we should make them to both.
Pushed by msreckovic@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c39ec15e7e21 Part 1. Add BufferSizeFromDimensions method to complement BufferSizeFromStrideAndHeight. r=bas https://hg.mozilla.org/integration/autoland/rev/53dc795121e1 Part 2. Use BufferSizeFromDimensions method, as well as some of the others that check for valid size. r=bas
Thanks for catching this and backing it out. I imagine it's for disallowing negative stride, but I'll double check before try/inbounding this again.
It's for Factory::CreateDrawTargetForCairoSurface returning nullptr when AllowedSurfaceSize fails (on 45680x65360 size.) I guess we were allowing that to succeed before.
In the context of print
Comment on attachment 8786456 [details] Bug 1299164: Part 2. Use BufferSizeFromDimensions method, as well as some of the others that check for valid size. https://reviewboard.mozilla.org/r/75408/#review77416
Pushed by msreckovic@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/e2d722f565d3 Part 1. Add BufferSizeFromDimensions method to complement BufferSizeFromStrideAndHeight. r=bas https://hg.mozilla.org/integration/mozilla-inbound/rev/1aecdb3b9974 Part 2. Use BufferSizeFromDimensions method, as well as some of the others that check for valid size. r=bas
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: