Closed Bug 983591 Opened 10 years ago Closed 10 years ago

Add a Moz2d helper to copy pixels from a B8G8R8X8 surface to a packed B8G8R8 array

Categories

(Core :: Graphics, defect)

31 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31

People

(Reporter: jwatt, Assigned: jwatt)

References

Details

Attachments

(1 file)

For bug 950372 I need a Moz2d helper to copy pixels from a B8G8R8A8 surface to a packed B8G8R8 array.
Attached patch patchSplinter Review
Attachment #8391135 - Flags: review?(bas)
Summary: Add a Moz2d helper to copy pixels from a B8G8R8A8 surface to a packed B8G8R8 array → Add a Moz2d helper to copy pixels from a B8G8R8X8 surface to a packed B8G8R8 array
Comment on attachment 8391135 [details] [diff] [review]
patch

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

::: gfx/2d/DataSurfaceHelpers.cpp
@@ +117,5 @@
> +  }
> +
> +  IntSize size = aSurface->GetSize();
> +
> +  uint8_t* imageBuffer = new (std::nothrow) uint8_t[size.width * size.height * 3 * sizeof(uint8_t)];

Hrm, I'm personally not a big fan of just returning pointers with ownership to the outside world like this. Perhaps we should support a B8G8R8 packed DataSourceSurface type?
(In reply to Bas Schouten (:bas.schouten) from comment #2)
> Hrm, I'm personally not a big fan of just returning pointers with ownership
> to the outside world like this. Perhaps we should support a B8G8R8 packed
> DataSourceSurface type?

That wouldn't actually meet my usecases, where the calling code actually wants to have ownership of the buffer, not just a pointer into packed data that it does not own. It would be wasteful to create a B8G8R8 packed DataSourceSurface and pack the pixels into its buffer, and then have to allocate another packed buffer and copy the data.
And note SurfaceToPackedBGRA gives precedent to doing this.
Attachment #8391135 - Flags: review?(bas) → review+
https://hg.mozilla.org/mozilla-central/rev/ea0518320f9f
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
for (int col = 0; col < aSrcSize.height; ++col) {

should be

for (int col = 0; col < aSrcSize.width; ++col) {
Oops! Do you want me to put up a patch to fix that, or have you fixed it elsewhere and you were you just noting that here for completeness?
I haven't fixed it yet.
Depends on: 1172964
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: