[Webkit-unassigned] [Bug 44127] [chromium] Thumbnails not generated for GPU Rendered Pages

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Aug 19 12:38:37 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=44127





--- Comment #11 from Vangelis Kokkevis <vangelis at chromium.org>  2010-08-19 12:38:37 PST ---
(From update of attachment 64877)
> diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
> index ad3ea90fa97c706ed4ce0ea385d2c93998d925cc..0ad1ee5530eed1141cb54f4fe61aa03a059a9c50 100644
> --- a/WebCore/ChangeLog
> +++ b/WebCore/ChangeLog
> @@ -1,3 +1,16 @@
> +2010-08-19  W. James MacLean  <wjmaclean at chromium.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        [chromium] Thumbnails not generated for GPU Rendered Pages
> +        https://bugs.webkit.org/show_bug.cgi?id=44127
> +
> +        Replicates existing functionality, use existing tests.
> +
> +        * platform/graphics/chromium/LayerRendererChromium.cpp:
> +        (WebCore::LayerRendererChromium::getFramebufferPixels):
> +        * platform/graphics/chromium/LayerRendererChromium.h:
> +
>  2010-08-17  Darin Fisher  <darin at chromium.org>
>  
>          Reviewed by Darin Adler.
> diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
> index 2f70efad02606b6a37a1218f93b6dcb73e1de796..04b69e11dc31dbf6786dc0569b2f3a5e9ade6106 100644
> --- a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
> +++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
> @@ -506,6 +506,33 @@ void LayerRendererChromium::drawLayers(const IntRect& updateRect, const IntRect&
>      m_needsDisplay = false;
>  }
>  
> +void LayerRendererChromium::getFramebufferPixels(void *pixels, const int width, const int height, const int rowBytes)
> +{
> +    if (!pixels)
> +        return;
> +
> +    makeContextCurrent();
> +
> +    checkGLError();
> +
> +    glReadPixels(0, 0, width, height,
> +                 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
> +
> +    checkGLError();
> +
> +    // Flip pixels vertically.
> +    OwnPtr<unsigned char> lineTemp(new unsigned char[rowBytes]);
> +    for (int row1 = 0, row2 = height - 1; row1 < height / 2; ++row1, --row2) {
> +
> +        unsigned char* ptr1 = static_cast<unsigned char*>(pixels) + row1 * rowBytes;
> +        unsigned char* ptr2 = static_cast<unsigned char*>(pixels) + row2 * rowBytes;
> +
> +        memcpy(lineTemp.get(), ptr1, rowBytes);
> +        memcpy(ptr1, ptr2, rowBytes);
> +        memcpy(ptr2, lineTemp.get(), rowBytes);
> +    }
> +}
> +
>  // Returns the id of the texture currently associated with the layer or
>  // -1 if the id hasn't been registered yet.
>  int LayerRendererChromium::getTextureId(LayerChromium* layer)
> diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
> index e4474b5a0251d53a073d4b7590a057d9f91b6639..ae9f55cb3e634211d62c30f0103b300278b8782b 100644
> --- a/WebCore/platform/graphics/chromium/LayerRendererChromium.h
> +++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
> @@ -87,6 +87,8 @@ public:
>  
>      GraphicsContext* rootLayerGraphicsContext() const { return m_rootLayerGraphicsContext.get(); }
>  
> +    void getFramebufferPixels(void *pixels, const int width, const int height, const int rowBytes);
> +
>  private:
>      enum ShaderProgramType { DebugBorderProgram, ScrollLayerProgram, ContentLayerProgram, CanvasLayerProgram, NumShaderProgramTypes };
>  
> diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
> index c5b2a5d467a378d74a06bd2021c0b2f4c9c74173..6c10f07439458543c6d5d4ba7bff181d5997cdc7 100644
> --- a/WebKit/chromium/ChangeLog
> +++ b/WebKit/chromium/ChangeLog
> @@ -1,3 +1,17 @@
> +2010-08-19  W. James MacLean  <wjmaclean at google.com>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        [chromium] Thumbnails not generated for GPU Rendered Pages
> +        https://bugs.webkit.org/show_bug.cgi?id=44127
> +
> +        Modified WebViewImpl::paint() to detect non-null canvas pointers when
> +        accelerated compositing is active, and instead fills the pixel buffer
> +        from the GPU framebuffer.
> +
> +        * src/WebViewImpl.cpp:
> +        (WebKit::WebViewImpl::paint):
> +
>  2010-08-17  Sheriff Bot  <webkit.review.bot at gmail.com>
>  
>          Unreviewed, rolling out r65516.
> diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
> index 62b20d5fb59477df2448b03ba95e883051a19b1d..5d862472afbb86e92aff3b33aa92284de4ba31c0 100644
> --- a/WebKit/chromium/src/WebViewImpl.cpp
> +++ b/WebKit/chromium/src/WebViewImpl.cpp
> @@ -114,6 +114,10 @@
>  #include "WebViewClient.h"
>  #include "wtf/OwnPtr.h"
>  
> +#if WEBKIT_USING_CG
> +#include <CoreGraphics/CGContext.h>
> +#endif
> +
>  #if OS(WINDOWS)
>  #include "RenderThemeChromiumWin.h"
>  #else
> @@ -954,6 +958,35 @@ void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
>              webframe->paint(canvas, rect);
>  #if USE(ACCELERATED_COMPOSITING)
>      } else {
> +        // If canvas is non-NULL, we just read the pixels from
> +        // the GPU framebuffer.
> +        if (canvas) {
> +#if WEBKIT_USING_SKIA
> +            const SkBitmap bitmap = canvas->getDevice()->accessBitmap(false);
> +
> +            int width = bitmap.width();
> +            int height = bitmap.height();
> +            int rowBytes = bitmap.rowBytes();
> +
> +            SkAutoLockPixels bitmapLock(bitmap);
> +            void* pixels = bitmap.getPixels();
> +#elif WEBKIT_USING_CG
> +            CGContextRef bitmap = reinterpret_cast<CGContextRef>(canvas);
> +
> +            int width = CGBitmapContextGetWidth(bitmap);
> +            int height = CGBitmapContextGetHeight(bitmap);
> +            int rowBytes = CGBitmapContextGetBytesPerRow(bitmap);
> +
> +            void* pixels = CGBitmapContextGetData(bitmap);
> +            ASSERT(pixels);
> +#else
> +#error Must port to your platform.
> +#endif
> +
> +            m_layerRenderer->getFramebufferPixels(pixels, width, height, rowBytes);
> +            return;
> +        }
> +
>          // Draw the contents of the root layer.
>          updateRootLayerContents(rect);
>  

WebKit/chromium/src/WebViewImpl.cpp:981
 +              ASSERT(pixels);
This ASSERT could move outside the #if clause so that it runs for both Skia and CG

WebKit/chromium/src/WebViewImpl.cpp:963
 +          if (canvas) {
This code will probably need to move after the call to m_layerRenderer->drawLayers() so that we get fresh results. I guess the problem is that drawLayers calls swap buffers so it will be too late. A possible solution would be to split the call to swap buffers out to a different function (say: LayerRendererChromium::present()) and call that from WebViewImpl, after drawLayers and readFramebufferPixels.

WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:518
 +      glReadPixels(0, 0, width, height,
Are there any guarantees that the width and height passed in match those of the framebuffer? You should probably at a minimum put an assert there and/or clamp to the size of the framebuffer.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list