RESOLVED FIXED 159679
Move the pixel data of ImageFrame to a separate class named ImageBackingStore
https://bugs.webkit.org/show_bug.cgi?id=159679
Summary Move the pixel data of ImageFrame to a separate class named ImageBackingStore
Said Abou-Hallawa
Reported 2016-07-12 10:21:23 PDT
The goal is to have one class for the ImageFrame. Currently we have two very similar implementations: one is defined for non CG ports "ImageFrame", which is defined in /platform/image-decoders/ImageDecoder.h, and the second is "FrameData", which is defined in platform/graphics/BitmapImage.h. We begin by moving the pixel data manipulation part in ImageFrame into a separate class and then make it optional (allocated on demand). So for the CG case, BitmapPixels object will not be allocated because all the decoding is done by CG.
Attachments
Patch (124.32 KB, patch)
2016-07-12 10:23 PDT, Said Abou-Hallawa
no flags
Patch (124.27 KB, patch)
2016-07-12 10:44 PDT, Said Abou-Hallawa
no flags
Patch (124.78 KB, patch)
2016-07-12 11:14 PDT, Said Abou-Hallawa
no flags
Patch (124.79 KB, patch)
2016-07-12 11:25 PDT, Said Abou-Hallawa
no flags
Patch (124.82 KB, patch)
2016-07-12 11:35 PDT, Said Abou-Hallawa
no flags
Patch (124.83 KB, patch)
2016-07-12 12:05 PDT, Said Abou-Hallawa
no flags
Patch (125.20 KB, patch)
2016-07-12 12:34 PDT, Said Abou-Hallawa
no flags
Patch (125.20 KB, patch)
2016-07-12 12:42 PDT, Said Abou-Hallawa
no flags
Patch (131.69 KB, patch)
2016-07-12 13:04 PDT, Said Abou-Hallawa
no flags
Patch (142.22 KB, patch)
2016-07-12 14:48 PDT, Said Abou-Hallawa
no flags
Patch (142.22 KB, patch)
2016-07-12 14:55 PDT, Said Abou-Hallawa
no flags
Patch (141.90 KB, patch)
2016-07-12 15:29 PDT, Said Abou-Hallawa
no flags
Patch (141.90 KB, patch)
2016-07-12 15:59 PDT, Said Abou-Hallawa
no flags
Patch (141.95 KB, patch)
2016-07-12 16:08 PDT, Said Abou-Hallawa
no flags
Patch for review (46.75 KB, patch)
2016-07-12 16:51 PDT, Said Abou-Hallawa
no flags
Patch (42.82 KB, patch)
2016-09-09 12:03 PDT, Said Abou-Hallawa
no flags
Patch (42.92 KB, patch)
2016-09-09 12:31 PDT, Said Abou-Hallawa
no flags
Patch (42.92 KB, patch)
2016-09-09 12:37 PDT, Said Abou-Hallawa
no flags
Patch (44.53 KB, patch)
2016-09-09 16:18 PDT, Said Abou-Hallawa
no flags
Patch (55.93 KB, patch)
2016-09-09 17:02 PDT, Said Abou-Hallawa
no flags
Patch (55.95 KB, patch)
2016-09-09 17:40 PDT, Said Abou-Hallawa
no flags
Patch (55.97 KB, patch)
2016-09-09 17:50 PDT, Said Abou-Hallawa
no flags
Patch (55.99 KB, patch)
2016-09-09 18:01 PDT, Said Abou-Hallawa
no flags
Patch (56.00 KB, patch)
2016-09-09 18:11 PDT, Said Abou-Hallawa
no flags
Patch (55.28 KB, patch)
2016-09-09 18:35 PDT, Said Abou-Hallawa
no flags
Patch (55.28 KB, patch)
2016-09-09 18:46 PDT, Said Abou-Hallawa
no flags
Patch (55.33 KB, patch)
2016-09-09 19:08 PDT, Said Abou-Hallawa
no flags
Patch (60.87 KB, patch)
2016-09-12 12:16 PDT, Said Abou-Hallawa
no flags
Patch (60.87 KB, patch)
2016-09-12 13:12 PDT, Said Abou-Hallawa
no flags
Patch (67.30 KB, patch)
2016-09-12 15:44 PDT, Said Abou-Hallawa
no flags
Said Abou-Hallawa
Comment 1 2016-07-12 10:23:58 PDT
Said Abou-Hallawa
Comment 2 2016-07-12 10:44:06 PDT
Said Abou-Hallawa
Comment 3 2016-07-12 11:14:13 PDT
Said Abou-Hallawa
Comment 4 2016-07-12 11:25:39 PDT
Said Abou-Hallawa
Comment 5 2016-07-12 11:35:17 PDT
Said Abou-Hallawa
Comment 6 2016-07-12 12:05:25 PDT
Said Abou-Hallawa
Comment 7 2016-07-12 12:34:00 PDT
Said Abou-Hallawa
Comment 8 2016-07-12 12:42:15 PDT
Said Abou-Hallawa
Comment 9 2016-07-12 13:04:03 PDT
Said Abou-Hallawa
Comment 10 2016-07-12 14:48:45 PDT
Said Abou-Hallawa
Comment 11 2016-07-12 14:55:44 PDT
Said Abou-Hallawa
Comment 12 2016-07-12 15:29:02 PDT
Said Abou-Hallawa
Comment 13 2016-07-12 15:59:10 PDT
Said Abou-Hallawa
Comment 14 2016-07-12 16:08:59 PDT
Said Abou-Hallawa
Comment 15 2016-07-12 16:51:14 PDT
Created attachment 283469 [details] Patch for review
Said Abou-Hallawa
Comment 16 2016-09-09 12:03:15 PDT
Said Abou-Hallawa
Comment 17 2016-09-09 12:31:04 PDT
Said Abou-Hallawa
Comment 18 2016-09-09 12:37:50 PDT
Said Abou-Hallawa
Comment 19 2016-09-09 16:18:00 PDT
Said Abou-Hallawa
Comment 20 2016-09-09 17:02:32 PDT
Said Abou-Hallawa
Comment 21 2016-09-09 17:40:55 PDT
Said Abou-Hallawa
Comment 22 2016-09-09 17:50:08 PDT
Said Abou-Hallawa
Comment 23 2016-09-09 18:01:40 PDT
Said Abou-Hallawa
Comment 24 2016-09-09 18:11:31 PDT
Said Abou-Hallawa
Comment 25 2016-09-09 18:35:59 PDT
Said Abou-Hallawa
Comment 26 2016-09-09 18:46:38 PDT
Said Abou-Hallawa
Comment 27 2016-09-09 19:08:09 PDT
Carlos Garcia Campos
Comment 28 2016-09-12 00:46:04 PDT
Comment on attachment 288475 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=288475&action=review I ran the tests for GTK+ and got mostly the same results, so I don't think this is introducing any regression. > Source/WebCore/platform/graphics/ImageBackingStore.h:38 > +class ImageBackingStore { > +public: This could probably be fast allocated. > Source/WebCore/platform/graphics/ImageBackingStore.h:47 > + static std::unique_ptr<ImageBackingStore> create(const IntSize& size, bool premultiplyAlpha) > + { > + return std::make_unique<ImageBackingStore>(size, premultiplyAlpha); > + } > + > + static std::unique_ptr<ImageBackingStore> create(const ImageBackingStore& other) > + { > + return std::make_unique<ImageBackingStore>(other); > + } Do we need create methods if they just call macke_unique and constructors are public? > Source/WebCore/platform/graphics/ImageBackingStore.h:49 > + ImageBackingStore(const IntSize& size, bool premultiplyAlpha = true) So, premultiplyAlpha is optional here but not in the create method. > Source/WebCore/platform/graphics/ImageBackingStore.h:59 > + if (this == &other) > + return; I don't understand this. > Source/WebCore/platform/graphics/ImageBackingStore.h:71 > + { > + if (!m_pixels.tryReserveCapacity(size.area())) Is it ok to set an empty size? otherwise I would add an assert here. > Source/WebCore/platform/graphics/ImageBackingStore.h:89 > + IntSize size() const { return m_size; } Could we return const IntSize& here? > Source/WebCore/platform/graphics/ImageBackingStore.h:90 > + IntRect frameRect() const { return m_frameRect; } And const IntRect& here? > Source/WebCore/platform/image-decoders/ImageDecoder.h:93 > + IntSize size() const { return m_backingStore->size(); } const IntSize& ? > Source/WebCore/platform/image-decoders/ImageDecoder.h:110 > + void setBackingStore(const ImageBackingStore*); Where is this implemented? > Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp:38 > +NativeImagePtr ImageBackingStore::image() const > +{ > + return adoptRef(cairo_image_surface_create_for_data( > + reinterpret_cast<unsigned char*>(const_cast<RGBA32*>(m_pixelsPtr)), > + CAIRO_FORMAT_ARGB32, size().width(), size().height(), size().width() * sizeof(RGBA32))); > +} So, I guess we can remove ImageDecoderCairo.cpp now.
Said Abou-Hallawa
Comment 29 2016-09-12 12:16:14 PDT
Said Abou-Hallawa
Comment 30 2016-09-12 12:25:21 PDT
Comment on attachment 288475 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=288475&action=review Thanks for the code review and for verifying the layout tests. >> Source/WebCore/platform/graphics/ImageBackingStore.h:38 >> +public: > > This could probably be fast allocated. Done. >> Source/WebCore/platform/graphics/ImageBackingStore.h:47 >> + } > > Do we need create methods if they just call macke_unique and constructors are public? Done. Constructors became private and I have to abandon calling std::make_unique() since it requires the constructor to be public. >> Source/WebCore/platform/graphics/ImageBackingStore.h:49 >> + ImageBackingStore(const IntSize& size, bool premultiplyAlpha = true) > > So, premultiplyAlpha is optional here but not in the create method. Done. The premultiplyAlpha is now optional in both the constructor and the create method. >> Source/WebCore/platform/graphics/ImageBackingStore.h:59 >> + return; > > I don't understand this. You are right. This constructor was originally implemented as an assignment operator. I forgot to change its body to be suitable for a copy constructor. >> Source/WebCore/platform/graphics/ImageBackingStore.h:71 >> + if (!m_pixels.tryReserveCapacity(size.area())) > > Is it ok to set an empty size? otherwise I would add an assert here. A check for !size.isEmpty() its added to this if-statment. >> Source/WebCore/platform/image-decoders/ImageDecoder.h:93 >> + IntSize size() const { return m_backingStore->size(); } > > const IntSize& ? Done. >> Source/WebCore/platform/image-decoders/ImageDecoder.h:110 >> + void setBackingStore(const ImageBackingStore*); > > Where is this implemented? setBackingStore() is not implemented and this declaration is not needed. >> Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp:38 >> +} > > So, I guess we can remove ImageDecoderCairo.cpp now. You are right. ImageDecoderCairo.cpp is now deleted.
Said Abou-Hallawa
Comment 31 2016-09-12 13:12:21 PDT
Simon Fraser (smfr)
Comment 32 2016-09-12 14:32:35 PDT
Comment on attachment 288604 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=288604&action=review > Source/WebCore/platform/graphics/ImageBackingStore.h:37 > +class ImageBackingStore { I'm surprised that this class doesn't pad rowBytes to some multiple of 4 or 8 bytes. > Source/WebCore/platform/graphics/ImageBackingStore.h:85 > + size_t rectWidthInBytes = rect.width() * sizeof(RGBA32); This is normally called rowBytes > Source/WebCore/platform/graphics/ImageBackingStore.h:98 > + size_t rectWidthInBytes = rect.width() * sizeof(RGBA32); Ditto. > Source/WebCore/platform/graphics/ImageBackingStore.h:107 > + RGBA32* at(int x, int y) const I don't like this name. > Source/WebCore/platform/graphics/ImageBackingStore.h:112 > + void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsigned a) I would call this setPixel() > Source/WebCore/platform/graphics/ImageBackingStore.h:127 > + void overRGBA(RGBA32* dest, unsigned r, unsigned g, unsigned b, unsigned a) I don't like this name.
Said Abou-Hallawa
Comment 33 2016-09-12 15:44:29 PDT
WebKit Commit Bot
Comment 34 2016-09-12 16:54:02 PDT
Comment on attachment 288626 [details] Patch Clearing flags on attachment: 288626 Committed r205841: <http://trac.webkit.org/changeset/205841>
WebKit Commit Bot
Comment 35 2016-09-12 16:54:09 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.