New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GPU Process] [Filters] Make PixelBuffer an abstract class #1261
[GPU Process] [Filters] Make PixelBuffer an abstract class #1261
Conversation
a401f0e
to
e75e0ff
Compare
|
||
namespace WebCore { | ||
|
||
class Uint8ClampedPixelBuffer : public PixelBuffer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uint8ClampedPixelBuffer is a bit of a mouthful. How about ByteArrayPixelBuffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the class was changed.
@@ -1116,7 +1117,7 @@ class CloneSerializer : CloneBase { | |||
return; | |||
} | |||
|
|||
auto arrayBuffer = pixelBuffer->data().possiblySharedBuffer(); | |||
auto arrayBuffer = downcast<Uint8ClampedPixelBuffer>(*pixelBuffer).data().possiblySharedBuffer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know it's a Uint8ClampedPixelBuffer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should be of type ByteArrayPixelBuffer since we are passing the default ImageBufferAllocator to getPixelBuffer(). But I changed the if-statement which comes before this code fromif (!pixelBuffer)
to if (!is<ByteArrayPixelBuffer>(pixelBuffer))
to make it clear that this is what we expect.
@@ -766,7 +766,8 @@ RefPtr<ImageData> HTMLCanvasElement::getImageData() | |||
if (is<WebGLRenderingContextBase>(m_context)) { | |||
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) | |||
ResourceLoadObserver::shared().logCanvasRead(document()); | |||
return ImageData::create(downcast<WebGLRenderingContextBase>(*m_context).paintRenderingResultsToPixelBuffer()); | |||
auto pixelBuffer = downcast<WebGLRenderingContextBase>(*m_context).paintRenderingResultsToPixelBuffer(); | |||
return ImageData::create(static_pointer_cast<Uint8ClampedPixelBuffer>(WTFMove(pixelBuffer))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we know that WebGLRenderingContextBase will return a Uint8ClampedPixelBuffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should be of type ByteArrayPixelBuffer because GraphicsContextGLANGLE::readPixelsForPaintResults() calls ByteArrayPixelBuffer::tryCreate() for the returned PixelBuffer. But I added the new if-statement before this casting
if (!is<ByteArrayPixelBuffer>(pixelBuffer))
return nullptr;
to make it clear that this is the expectation.
|
||
Ref<JSC::Uint8ClampedArray>&& takeData() { return WTFMove(m_data); } | ||
virtual uint8_t* bytes() const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every call to item() now calls the bytes() virtual function. I think this would be a measurable performance hit for filter effect code that can do this inside tight loops.
Also since item() is exported, it won't be inlined.
Can we fetch the start pointer once via a virtual function at creation time, and after that just index off it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right.
I changed ByteArrayPixelBuffer to pass the raw data pointer and the sizeInBytes to the PixelBuffer constructor and I made the methods bytes()
and sizeInBytes()
non virtual. I think I can't call virtual methods from the base class constructor.
return create(format, size, data.releaseNonNull()); | ||
} | ||
|
||
RefPtr<Uint8ClampedPixelBuffer> Uint8ClampedPixelBuffer::tryCreateForDecoding(const PixelBufferFormat& format, const IntSize& size, unsigned dataByteLength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not new, but it's not clear to me how a "for decoding" buffer is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tryCreateForDecoding()
was renamed to tryCreate()
e75e0ff
to
fb00f36
Compare
fb00f36
to
bfadc14
Compare
bfadc14
to
48e7647
Compare
48e7647
to
8d8ee87
Compare
8d8ee87
to
76d7b2f
Compare
Committed r295227 (251282@main): https://commits.webkit.org/251282@main Reviewed commits have been landed. Closing PR #1261 and removing active labels. |
76d7b2f