Source/Platform/ChangeLog

 12012-08-01 James Robinson <jamesr@chromium.org>
 2
 3 [chromium] Wrap shared context getters in WebKit API and avoid WebCore::GraphicsContext3D use in compositor internals
 4 https://bugs.webkit.org/show_bug.cgi?id=92917
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This adds Platform API for creating and accessing shared GraphicsContext3D and Ganesh contexts from the main or
 9 compositor threads. These can be used for evaluating filters or doing accelerated painting. These contexts are
 10 generally leaked until lost or process exit, the details are documented in WebSharedGraphicsContext3D.h
 11
 12 * Platform.gypi:
 13 * chromium/public/WebSharedGraphicsContext3D.h: Added.
 14 (WebKit):
 15 (WebSharedGraphicsContext3D):
 16
1172012-08-01 Tommy Widenflycht <tommyw@google.com>
218
319 MediaStream API: Add ExtraData capability to MediaStreamSource

Source/WebCore/ChangeLog

112012-08-01 James Robinson <jamesr@chromium.org>
22
 3 [chromium] Wrap shared context getters in WebKit API and avoid WebCore::GraphicsContext3D use in compositor internals
 4 https://bugs.webkit.org/show_bug.cgi?id=92917
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This uses Platform API wrappers to access the shared WebGraphicsContext3D / Ganesh contexts from the compositor
 9 to evaluate accelerated filters or do accelerated painting.
 10
 11 Filters changes covered by css3/filters/*-hw.html layout tests.
 12
 13 * WebCore.gypi:
 14 * platform/chromium/support/WebSharedGraphicsContext3D.cpp:
 15 (WebKit):
 16 (WebKit::WebSharedGraphicsContext3D::mainThreadContext):
 17 (WebKit::WebSharedGraphicsContext3D::mainThreadGrContext):
 18 (WebKit::WebSharedGraphicsContext3D::compositorThreadContext):
 19 (WebKit::WebSharedGraphicsContext3D::compositorThreadGrContext):
 20 (WebKit::WebSharedGraphicsContext3D::haveCompositorThreadContext):
 21 (WebKit::WebSharedGraphicsContext3D::createCompositorThreadContext):
 22 * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
 23 (WebCore::createAcceleratedCanvas):
 24 (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect):
 25 (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
 26 * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h:
 27 (WebKit):
 28 (FrameBufferSkPictureCanvasLayerTextureUpdater):
 29 * platform/graphics/chromium/LayerRendererChromium.cpp:
 30 (WebCore::applyFilters):
 31 * platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp:
 32 (WebCore::CCRenderSurfaceFilters::apply):
 33 * platform/graphics/chromium/cc/CCRenderSurfaceFilters.h:
 34 (WebKit):
 35 (CCRenderSurfaceFilters):
 36
 372012-08-01 James Robinson <jamesr@chromium.org>
 38
339 [chromium] Move compositor HUD font atlas generation out of compositor core
440 https://bugs.webkit.org/show_bug.cgi?id=92901
541

Source/Platform/Platform.gypi

114114 'chromium/public/WebScrollbarThemeGeometry.h',
115115 'chromium/public/WebScrollbarThemePainter.h',
116116 'chromium/public/WebSessionDescriptionDescriptor.h',
 117 'chromium/public/WebSharedGraphicsContext3D.h',
117118 'chromium/public/WebSize.h',
118119 'chromium/public/WebSocketStreamError.h',
119120 'chromium/public/WebSocketStreamHandle.h',

Source/Platform/chromium/public/WebSharedGraphicsContext3D.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebSharedGraphicsContext3D_h
 27#define WebSharedGraphicsContext3D_h
 28
 29#include "WebCommon.h"
 30
 31class GrContext;
 32
 33namespace WebKit {
 34
 35class WebGraphicsContext3D;
 36
 37class WebSharedGraphicsContext3D {
 38public:
 39 // Returns a context usable from the main thread. If the context is lost or has never been created, this will attempt to create a new context.
 40 // The returned pointer is only valid until the next call to mainThreadContext().
 41 WEBKIT_EXPORT static WebGraphicsContext3D* mainThreadContext();
 42
 43 // Returns a ganesh context associated with the main thread shared context. The ganesh context has the same lifetime as the main thread shared
 44 // WebGraphicsContext3D.
 45 WEBKIT_EXPORT static GrContext* mainThreadGrContext();
 46
 47 // Attempts to create a context usable from the compositor thread. Must be called from the main (WebKit) thread. Returns false
 48 // if a context could not be created.
 49 WEBKIT_EXPORT static bool createCompositorThreadContext();
 50
 51 // Can be called from any thread.
 52 WEBKIT_EXPORT static bool haveCompositorThreadContext();
 53
 54 // Returns a context usable from the compositor thread, if there is one. The context must be used only from the compositor thread.
 55 // The returned context is valid until the next call to createCompositorThreadContext().
 56 // If this context becomes lost or unusable, the caller should call createCompositorThreadContext() on the main thread and
 57 // then use the newly created context from the compositor thread.
 58 WEBKIT_EXPORT static WebGraphicsContext3D* compositorThreadContext();
 59
 60 // Returns a ganesh context associated with the compositor thread shared context. The ganesh context has the same lifetime as the compositor thread
 61 // shared WebGraphicsContext3D.
 62 WEBKIT_EXPORT static GrContext* compositorThreadGrContext();
 63};
 64
 65}
 66
 67#endif // WebSharedGraphicsContext3D_h

Source/WebCore/WebCore.gypi

82278227 'platform/chromium/support/WebMediaStreamSource.cpp',
82288228 'platform/chromium/support/WebMediaStreamSourcesRequest.cpp',
82298229 'platform/chromium/support/WebPrerender.cpp',
 8230 'platform/chromium/support/WebSharedGraphicsContext3D.cpp',
82308231 'platform/chromium/support/WebThreadSafeData.cpp',
82318232 'platform/chromium/support/WebTransformationMatrix.cpp',
82328233 'platform/chromium/support/WebTransformOperations.cpp',

Source/WebCore/platform/chromium/support/WebSharedGraphicsContext3D.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27
 28#include <public/WebSharedGraphicsContext3D.h>
 29
 30#include "GraphicsContext3DPrivate.h"
 31#include "SharedGraphicsContext3D.h"
 32
 33using WebCore::GraphicsContext3DPrivate;
 34using WebCore::SharedGraphicsContext3D;
 35
 36namespace WebKit {
 37
 38WebGraphicsContext3D* WebSharedGraphicsContext3D::mainThreadContext()
 39{
 40 return GraphicsContext3DPrivate::extractWebGraphicsContext3D(SharedGraphicsContext3D::get().get());
 41}
 42
 43GrContext* WebSharedGraphicsContext3D::mainThreadGrContext()
 44{
 45 return SharedGraphicsContext3D::get() ? SharedGraphicsContext3D::get()->grContext() : 0;
 46}
 47
 48
 49WebGraphicsContext3D* WebSharedGraphicsContext3D::compositorThreadContext()
 50{
 51 return GraphicsContext3DPrivate::extractWebGraphicsContext3D(SharedGraphicsContext3D::getForImplThread().get());
 52}
 53
 54GrContext* WebSharedGraphicsContext3D::compositorThreadGrContext()
 55{
 56 return SharedGraphicsContext3D::getForImplThread() ? SharedGraphicsContext3D::getForImplThread()->grContext() : 0;
 57}
 58
 59bool WebSharedGraphicsContext3D::haveCompositorThreadContext()
 60{
 61 return SharedGraphicsContext3D::haveForImplThread();
 62}
 63
 64bool WebSharedGraphicsContext3D::createCompositorThreadContext()
 65{
 66 return SharedGraphicsContext3D::createForImplThread();
 67}
 68
 69}
 70

Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp

3131#include "FrameBufferSkPictureCanvasLayerTextureUpdater.h"
3232
3333#include "LayerPainterChromium.h"
34 #include "SharedGraphicsContext3D.h"
3534#include "SkCanvas.h"
3635#include "SkGpuDevice.h"
3736#include "cc/CCProxy.h"
 37#include <public/WebGraphicsContext3D.h>
 38#include <public/WebSharedGraphicsContext3D.h>
 39
 40using WebKit::WebGraphicsContext3D;
 41using WebKit::WebSharedGraphicsContext3D;
3842
3943namespace WebCore {
4044
41 static PassOwnPtr<SkCanvas> createAcceleratedCanvas(GraphicsContext3D* context,
 45static PassOwnPtr<SkCanvas> createAcceleratedCanvas(GrContext* grContext,
4246 IntSize canvasSize,
4347 unsigned textureId)
4448{
45  GrContext* grContext = context->grContext();
4649 GrPlatformTextureDesc textureDesc;
4750 textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag;
4851 textureDesc.fWidth = canvasSize.width();

@@FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture()
6669
6770void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCResourceProvider* resourceProvider, const IntRect& sourceRect, const IntRect& destRect)
6871{
69  RefPtr<GraphicsContext3D> sharedContext = CCProxy::hasImplThread() ? SharedGraphicsContext3D::getForImplThread() : SharedGraphicsContext3D::get();
70  if (!sharedContext)
 72 WebGraphicsContext3D* sharedContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadContext() : WebSharedGraphicsContext3D::mainThreadContext();
 73 GrContext* sharedGrContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadGrContext() : WebSharedGraphicsContext3D::mainThreadGrContext();
 74 if (!sharedContext || !sharedGrContext)
7175 return;
72  textureUpdater()->updateTextureRect(sharedContext.release(), resourceProvider, texture(), sourceRect, destRect);
 76 textureUpdater()->updateTextureRect(sharedContext, sharedGrContext, resourceProvider, texture(), sourceRect, destRect);
7377}
7478
7579PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> FrameBufferSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter)

@@LayerTextureUpdater::SampledTexelFormat FrameBufferSkPictureCanvasLayerTextureUp
97101 return LayerTextureUpdater::SampledTexelFormatRGBA;
98102}
99103
100 void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(PassRefPtr<GraphicsContext3D> prpContext, CCResourceProvider* resourceProvider, CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
 104void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(WebGraphicsContext3D* context, GrContext* grContext, CCResourceProvider* resourceProvider, CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
101105{
102  RefPtr<GraphicsContext3D> context(prpContext);
103 
104106 // Make sure ganesh uses the correct GL context.
105107 context->makeContextCurrent();
106108
107109 texture->acquireBackingTexture(resourceProvider);
108110 CCScopedLockResourceForWrite lock(resourceProvider, texture->resourceId());
109111 // Create an accelerated canvas to draw on.
110  OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context.get(), texture->size(), lock.textureId());
 112 OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(grContext, texture->size(), lock.textureId());
111113
112114 // The compositor expects the textures to be upside-down so it can flip
113115 // the final composited image. Ganesh renders the image upright so we

@@void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(PassRefPtr
123125 drawPicture(canvas.get());
124126
125127 // Flush ganesh context so that all the rendered stuff appears on the texture.
126  context->grContext()->flush();
 128 grContext->flush();
127129
128130 // Flush the GL context so rendering results from this context are visible in the compositor's context.
129131 context->flush();

Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h

3131
3232#include "SkPictureCanvasLayerTextureUpdater.h"
3333
 34namespace WebKit {
 35class WebGraphicsContext3D;
 36class WebSharedGraphicsContext3D;
 37}
 38
3439namespace WebCore {
3540
3641// This class records the contentRect into an SkPicture, then uses accelerated

@@public:
5661
5762 virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(CCPrioritizedTextureManager*) OVERRIDE;
5863 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) OVERRIDE;
59  void updateTextureRect(PassRefPtr<GraphicsContext3D>, CCResourceProvider*, CCPrioritizedTexture*, const IntRect& sourceRect, const IntRect& destRect);
 64 void updateTextureRect(WebKit::WebGraphicsContext3D*, GrContext*, CCResourceProvider*, CCPrioritizedTexture*, const IntRect& sourceRect, const IntRect& destRect);
6065
6166private:
6267 explicit FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);

Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

4040#include "GrTexture.h"
4141#include "NotImplemented.h"
4242#include "PlatformColor.h"
43 #include "SharedGraphicsContext3D.h"
4443#include "SkBitmap.h"
4544#include "SkColor.h"
4645#include "ThrottledTextureUploader.h"

5655#include "cc/CCSingleThreadProxy.h"
5756#include "cc/CCVideoLayerImpl.h"
5857#include <public/WebGraphicsContext3D.h>
 58#include <public/WebSharedGraphicsContext3D.h>
5959#include <public/WebVideoFrame.h>
6060#include <wtf/CurrentTime.h>
6161#include <wtf/MainThread.h>

6464using namespace std;
6565using WebKit::WebGraphicsContext3D;
6666using WebKit::WebGraphicsMemoryAllocation;
 67using WebKit::WebSharedGraphicsContext3D;
6768using WebKit::WebTransformationMatrix;
6869
6970namespace WebCore {

@@static inline SkBitmap applyFilters(LayerRendererChromium* layerRenderer, const
535536 if (filters.isEmpty())
536537 return SkBitmap();
537538
538  RefPtr<GraphicsContext3D> filterContext = CCProxy::hasImplThread() ? SharedGraphicsContext3D::getForImplThread() : SharedGraphicsContext3D::get();
539  if (!filterContext)
 539 WebGraphicsContext3D* filterContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadContext() : WebSharedGraphicsContext3D::mainThreadContext();
 540 GrContext* filterGrContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadGrContext() : WebSharedGraphicsContext3D::mainThreadGrContext();
 541
 542 if (!filterContext || !filterGrContext)
540543 return SkBitmap();
541544
542545 layerRenderer->context()->flush();
543546
544547 CCScopedLockResourceForWrite lock(layerRenderer->resourceProvider(), sourceTexture->id());
545  SkBitmap source = CCRenderSurfaceFilters::apply(filters, lock.textureId(), sourceTexture->size(), filterContext.get());
 548 SkBitmap source = CCRenderSurfaceFilters::apply(filters, lock.textureId(), sourceTexture->size(), filterContext, filterGrContext);
546549 return source;
547550}
548551

Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp

3030#include "cc/CCRenderSurfaceFilters.h"
3131
3232#include "FloatSize.h"
33 #include "GraphicsContext3D.h"
3433#include "SkBlurImageFilter.h"
3534#include "SkCanvas.h"
3635#include "SkColorMatrixFilter.h"

3837#include "SkGrTexturePixelRef.h"
3938#include <public/WebFilterOperation.h>
4039#include <public/WebFilterOperations.h>
 40#include <public/WebGraphicsContext3D.h>
4141#include <wtf/MathExtras.h>
4242
4343namespace {

@@bool applyColorMatrix(FilterBufferState* state, SkScalar matrix[20])
335335
336336namespace WebCore {
337337
338 SkBitmap CCRenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize& size, GraphicsContext3D* context3D)
 338SkBitmap CCRenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize& size, WebKit::WebGraphicsContext3D* context3D, GrContext* grContext)
339339{
340  if (!context3D)
 340 if (!context3D || !grContext)
341341 return SkBitmap();
342342
343  GrContext* grContext = context3D->grContext();
344  if (!grContext)
345  return SkBitmap();
346343 FilterBufferState state(grContext, size, textureId);
347344
348345 SkScalar accumulatedColorMatrix[20];

Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.h

2929
3030#if USE(ACCELERATED_COMPOSITING)
3131
 32class GrContext;
3233class SkBitmap;
3334
3435namespace WebKit {
3536class WebFilterOperations;
 37class WebGraphicsContext3D;
3638}
3739
3840namespace WebCore {
3941class FloatSize;
40 class GraphicsContext3D;
4142
4243class CCRenderSurfaceFilters {
4344public:
44  static SkBitmap apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize&, GraphicsContext3D*);
 45 static SkBitmap apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize&, WebKit::WebGraphicsContext3D*, GrContext*);
 46
4547private:
4648 CCRenderSurfaceFilters();
4749};