WebCore/ChangeLog

112010-08-06 James Robinson <jamesr@chromium.org>
22
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [chromium] Add a PrepareTextureCallback to the chromium canvas layer compositor to upload mixed-mode results before compositing
 6 https://bugs.webkit.org/show_bug.cgi?id=43656
 7
 8 When compositing an accelerated canvas that is using both hardware and software drawing,
 9 we need a callback before compositing the layer to make sure that we upload any software
 10 drawn results to the texture. This will go away as soon as implement all draw calls
 11 in hardware.
 12
 13 To test, run any canvas demo that runs in mixed mode and verifies that the software results
 14 always show up.
 15
 16 * platform/graphics/chromium/CanvasLayerChromium.cpp:
 17 (WebCore::CanvasLayerChromium::updateTextureContents):
 18 * platform/graphics/chromium/CanvasLayerChromium.h:
 19 (WebCore::CanvasLayerChromium::setPrepareTextureCallback):
 20 * platform/graphics/skia/PlatformContextSkia.cpp:
 21 (WebCore::PrepareTextureCallbackImpl::create):
 22 (WebCore::PrepareTextureCallbackImpl::willPrepareTexture):
 23 (WebCore::PrepareTextureCallbackImpl::PrepareTextureCallbackImpl):
 24 (WebCore::PlatformContextSkia::setGraphicsContext3D):
 25
 262010-08-06 James Robinson <jamesr@chromium.org>
 27
328 Reviewed by Simon Fraser.
429
530 Accelerated 2d canvases should get compositing layers

WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp

@@void CanvasLayerChromium::updateTextureContents(unsigned textureId)
7575 }
7676 // Update the contents of the texture used by the compositor.
7777 if (m_contentsDirty) {
 78 if (m_prepareTextureCallback)
 79 m_prepareTextureCallback->willPrepareTexture();
7880 m_context->prepareTexture();
7981 m_contentsDirty = false;
8082 }

WebCore/platform/graphics/chromium/CanvasLayerChromium.h

@@public:
5454
5555 static void setShaderProgramId(unsigned shaderProgramId) { m_shaderProgramId = shaderProgramId; }
5656
 57 class PrepareTextureCallback : public Noncopyable {
 58 public:
 59 virtual void willPrepareTexture() = 0;
 60 };
 61 void setPrepareTextureCallback(PassOwnPtr<PrepareTextureCallback> callback) { m_prepareTextureCallback = callback; }
 62
5763private:
5864 explicit CanvasLayerChromium(GraphicsLayerChromium* owner);
5965 GraphicsContext3D* m_context;
6066 unsigned m_textureId;
6167 bool m_textureChanged;
 68 OwnPtr<PrepareTextureCallback> m_prepareTextureCallback;
6269
6370 static unsigned m_shaderProgramId;
6471};

WebCore/platform/graphics/skia/PlatformContextSkia.cpp

3333#include "PlatformContextSkia.h"
3434
3535#include "AffineTransform.h"
 36#include "CanvasLayerChromium.h"
3637#include "GraphicsContext.h"
3738#include "ImageBuffer.h"
3839#include "NativeImageSkia.h"

@@PlatformContextSkia::PlatformContextSkia(skia::PlatformCanvas* canvas)
220221
221222PlatformContextSkia::~PlatformContextSkia()
222223{
 224#if USE(GLES2_RENDERING)
 225 if (m_gpuCanvas) {
 226 CanvasLayerChromium* layer = static_cast<CanvasLayerChromium*>(m_gpuCanvas->context()->platformLayer());
 227 layer->setPrepareTextureCallback(0);
 228 }
 229#endif
223230}
224231
225232void PlatformContextSkia::setCanvas(skia::PlatformCanvas* canvas)

@@void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
678685
679686#if USE(GLES2_RENDERING)
680687
 688class PrepareTextureCallbackImpl : public CanvasLayerChromium::PrepareTextureCallback {
 689public:
 690 static PassOwnPtr<PrepareTextureCallbackImpl> create(PlatformContextSkia* pcs)
 691 {
 692 return new PrepareTextureCallbackImpl(pcs);
 693 }
 694
 695 virtual void willPrepareTexture()
 696 {
 697 m_pcs->prepareForHardwareDraw();
 698 }
 699private:
 700 explicit PrepareTextureCallbackImpl(PlatformContextSkia* pcs) : m_pcs(pcs) {}
 701 PlatformContextSkia* m_pcs;
 702};
 703
681704void PlatformContextSkia::setGraphicsContext3D(GraphicsContext3D* context, const WebCore::IntSize& size)
682705{
683706 m_useGPU = true;
684707 m_gpuCanvas = new GLES2Canvas(context, size);
 708 CanvasLayerChromium* layer = static_cast<CanvasLayerChromium*>(context->platformLayer());
 709 layer->setPrepareTextureCallback(PrepareTextureCallbackImpl::create(this));
685710}
686711
687712void PlatformContextSkia::prepareForSoftwareDraw() const