Commit 049a4d0d authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Commit Bot

webgl: Fix framebuffer readback format for software compositing

ReadBackFramebuffer assumes that the destination buffer size and format
match the source. However, this isn't true when exporting the buffer for
software compositiing since it only supports RGBA_8888, but the buffer
could be RGBA_F16.

Also fixes undefined behavior due to using the same buffer as source and
destination for SkPixmap::readPixels which does a memcpy under the hood.

Bug: 1122638
Change-Id: I887f70ea65fdf7ad215f5db22b39d0727fc3d09a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2393160
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805977}
parent 431f9d5d
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <memory> #include <memory>
#include "base/containers/span.h"
#include "base/macros.h" #include "base/macros.h"
#include "cc/layers/texture_layer_client.h" #include "cc/layers/texture_layer_client.h"
#include "cc/resources/cross_thread_shared_bitmap.h" #include "cc/resources/cross_thread_shared_bitmap.h"
...@@ -466,20 +467,12 @@ class PLATFORM_EXPORT DrawingBuffer : public cc::TextureLayerClient, ...@@ -466,20 +467,12 @@ class PLATFORM_EXPORT DrawingBuffer : public cc::TextureLayerClient,
// s_currentResourceUsePixels is updated. // s_currentResourceUsePixels is updated.
void SetSize(const IntSize&); void SetSize(const IntSize&);
// This is the order of bytes to use when doing a readback.
enum ReadbackOrder { kReadbackRGBA, kReadbackSkia };
// Helper function which does a readback from the currently-bound // Helper function which does a readback from the currently-bound
// framebuffer into a buffer of a certain size with 4-byte pixels. // framebuffer into a buffer of a certain size with 4-byte pixels.
void ReadBackFramebuffer(unsigned char* pixels, void ReadBackFramebuffer(base::span<uint8_t> pixels,
int width, SkColorType,
int height,
ReadbackOrder,
WebGLImageConversion::AlphaOp); WebGLImageConversion::AlphaOp);
// Helper function to flip a bitmap vertically.
void FlipVertically(uint8_t* data, int width, int height);
// If RGB emulation is required, then the CHROMIUM image's alpha channel // If RGB emulation is required, then the CHROMIUM image's alpha channel
// must be immediately cleared after it is bound to a texture. Nothing // must be immediately cleared after it is bound to a texture. Nothing
// should be allowed to change the alpha channel after this. // should be allowed to change the alpha channel after this.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment