Source/WebCore/ChangeLog

 12011-10-27 David Reveman <reveman@chromium.org>
 2
 3 [Chromium] Paint directly to shared memory.
 4 https://bugs.webkit.org/show_bug.cgi?id=71023
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Plumbing to allow allocation of compositor resources before painting
 9 of layer contents. Add mapTexSubImage2D interface to ManagedTexture
 10 class and new LayerTextureUpdaterShm class that render directly
 11 to mapped memory.
 12
 13 No new tests. Covered by existing tests.
 14
 15 * platform/graphics/chromium/ContentLayerChromium.cpp:
 16 (WebCore::ContentLayerChromium::prepareToPaintContents):
 17 (WebCore::ContentLayerChromium::paintContentsIfDirty):
 18 (WebCore::ContentLayerChromium::createTextureUpdater):
 19 * platform/graphics/chromium/ContentLayerChromium.h:
 20 * platform/graphics/chromium/ImageLayerChromium.cpp:
 21 (WebCore::ImageLayerTextureUpdater::prepareToUpdate):
 22 (WebCore::ImageLayerTextureUpdater::prepareToUpdateRect):
 23 (WebCore::ImageLayerTextureUpdater::paintContents):
 24 (WebCore::ImageLayerTextureUpdater::paintTextureRect):
 25 (WebCore::ImageLayerChromium::prepareToPaintContents):
 26 (WebCore::ImageLayerChromium::paintContentsIfDirty):
 27 * platform/graphics/chromium/ImageLayerChromium.h:
 28 * platform/graphics/chromium/LayerChromium.h:
 29 (WebCore::LayerChromium::prepareToPaintContents):
 30 (WebCore::LayerChromium::prepareCompositorResources):
 31 * platform/graphics/chromium/LayerTextureUpdater.h:
 32 * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
 33 (WebCore::LayerTextureUpdaterCanvas::paint):
 34 (WebCore::LayerTextureUpdaterBitmap::prepareToUpdate):
 35 (WebCore::LayerTextureUpdaterBitmap::paintContents):
 36 (WebCore::LayerTextureUpdaterBitmap::updateTextureRect):
 37 (WebCore::LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture):
 38 (WebCore::LayerTextureUpdaterSkPicture::paintContents):
 39 (WebCore::LayerTextureUpdaterSkPicture::drawPicture):
 40 (WebCore::LayerTextureUpdaterSharedMemory::create):
 41 (WebCore::LayerTextureUpdaterSharedMemory::LayerTextureUpdaterSharedMemory):
 42 (WebCore::LayerTextureUpdaterSharedMemory::sampledTexelFormat):
 43 (WebCore::LayerTextureUpdaterSharedMemory::prepareToUpdateRect):
 44 (WebCore::LayerTextureUpdaterSharedMemory::paintTextureRect):
 45 (WebCore::LayerTextureUpdaterSharedMemory::updateTextureRect):
 46 (WebCore::LayerTextureUpdaterFramebuffer::create):
 47 (WebCore::LayerTextureUpdaterFramebuffer::LayerTextureUpdaterFramebuffer):
 48 (WebCore::LayerTextureUpdaterFramebuffer::~LayerTextureUpdaterFramebuffer):
 49 (WebCore::LayerTextureUpdaterFramebuffer::sampledTexelFormat):
 50 (WebCore::LayerTextureUpdaterFramebuffer::updateTextureRect):
 51 * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
 52 (WebCore::LayerTextureUpdaterBitmap::prepareToUpdateRect):
 53 (WebCore::LayerTextureUpdaterBitmap::paintTextureRect):
 54 (WebCore::LayerTextureUpdaterSharedMemory::orientation):
 55 (WebCore::LayerTextureUpdaterSharedMemory::prepareToUpdate):
 56 (WebCore::LayerTextureUpdaterFramebuffer::prepareToUpdate):
 57 (WebCore::LayerTextureUpdaterFramebuffer::prepareToUpdateRect):
 58 (WebCore::LayerTextureUpdaterFramebuffer::paintTextureRect):
 59 * platform/graphics/chromium/ManagedTexture.cpp:
 60 (WebCore::ManagedTexture::ManagedTexture):
 61 (WebCore::ManagedTexture::~ManagedTexture):
 62 (WebCore::ManagedTexture::mapTexSubImage2D):
 63 (WebCore::ManagedTexture::unmapTexSubImage2D):
 64 * platform/graphics/chromium/ManagedTexture.h:
 65 (WebCore::ManagedTexture::mappedBuffer):
 66 * platform/graphics/chromium/TiledLayerChromium.cpp:
 67 (WebCore::TiledLayerChromium::prepareCompositorResources):
 68 (WebCore::TiledLayerChromium::updateCompositorResources):
 69 (WebCore::TiledLayerChromium::prepareToUpdate):
 70 (WebCore::TiledLayerChromium::paintContents):
 71 * platform/graphics/chromium/TiledLayerChromium.h:
 72 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
 73 (WebCore::CCLayerTreeHost::prepareToUpdateLayers):
 74 (WebCore::CCLayerTreeHost::updateLayers):
 75 (WebCore::prepareToPaintContents):
 76 (WebCore::CCLayerTreeHost::prepareToPaintMaskAndReplicaForRenderSurface):
 77 (WebCore::CCLayerTreeHost::prepareToPaintLayerContents):
 78 (WebCore::paintContentsIfDirty):
 79 (WebCore::CCLayerTreeHost::paintMaskAndReplicaForRenderSurface):
 80 (WebCore::CCLayerTreeHost::paintLayerContents):
 81 (WebCore::CCLayerTreeHost::prepareCompositorResources):
 82 (WebCore::CCLayerTreeHost::updateCompositorResources):
 83 * platform/graphics/chromium/cc/CCLayerTreeHost.h:
 84 (WebCore::CCSettings::CCSettings):
 85 * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
 86 (WebCore::CCSingleThreadProxy::commitIfNeeded):
 87 * platform/graphics/chromium/cc/CCThreadProxy.cpp:
 88 (WebCore::CCThreadProxy::beginFrameAndCommit):
 89 (WebCore::CCThreadProxy::allocateOnImplThread):
 90 * platform/graphics/chromium/cc/CCThreadProxy.h:
 91
1922011-10-27 Daniel Cheng <dcheng@chromium.org>
293
394 Clean up MicroDataItemValue to use const String& instead of String

Source/WebKit/chromium/ChangeLog

 12011-10-27 David Reveman <reveman@chromium.org>
 2
 3 [Chromium] Paint directly to shared memory.
 4 https://bugs.webkit.org/show_bug.cgi?id=71023
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add sharedMemoryPainting setting.
 9
 10 * public/WebLayerTreeView.h:
 11 (WebKit::WebLayerTreeView::Settings::Settings):
 12 * public/WebSettings.h:
 13 * src/WebLayerTreeView.cpp:
 14 (WebKit::WebLayerTreeView::Settings::operator CCSettings):
 15 * src/WebSettingsImpl.cpp:
 16 (WebKit::WebSettingsImpl::WebSettingsImpl):
 17 (WebKit::WebSettingsImpl::setSharedMemoryPainting):
 18 * src/WebSettingsImpl.h:
 19 (WebKit::WebSettingsImpl::sharedMemoryPainting):
 20 * src/WebViewImpl.cpp:
 21 (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
 22
1232011-10-27 Dave Michael <dmichael@chromium.org>
224
325 Chromium ui_tests WorkerTest.WorkerMessagePort[GC] were broken by https://bugs.webkit.org/attachment.cgi?id=112342

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

@@void ContentLayerChromium::cleanupResources()
9292 TiledLayerChromium::cleanupResources();
9393}
9494
95 void ContentLayerChromium::paintContentsIfDirty()
 95void ContentLayerChromium::prepareToPaintContents()
9696{
9797 ASSERT(drawsContent());
9898

@@void ContentLayerChromium::paintContentsIfDirty()
113113 resetNeedsDisplay();
114114}
115115
 116void ContentLayerChromium::paintContentsIfDirty()
 117{
 118 if (!drawsContent())
 119 return;
 120
 121 if (visibleLayerRect().isEmpty())
 122 return;
 123
 124 paintContents();
 125}
 126
116127bool ContentLayerChromium::drawsContent() const
117128{
118129 return m_delegate && m_delegate->drawsContent() && TiledLayerChromium::drawsContent();

@@void ContentLayerChromium::createTextureUpdater(const CCLayerTreeHost* host)
122133{
123134#if USE(SKIA)
124135 if (host->settings().acceleratePainting) {
125  m_textureUpdater = LayerTextureUpdaterSkPicture::create(ContentLayerPainter::create(m_delegate));
 136 m_textureUpdater = LayerTextureUpdaterFramebuffer::create(ContentLayerPainter::create(m_delegate));
 137 return;
 138 }
 139 if (host->settings().sharedMemoryPainting && host->layerRendererCapabilities().usingMapSub) {
 140 m_textureUpdater = LayerTextureUpdaterSharedMemory::create(ContentLayerPainter::create(m_delegate));
126141 return;
127142 }
128143#endif // USE(SKIA)

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

@@public:
4949
5050 virtual ~ContentLayerChromium();
5151
 52 virtual void prepareToPaintContents();
5253 virtual void paintContentsIfDirty();
5354
5455protected:

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

@@public:
6161 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA;
6262 }
6363
64  virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int /* borderTexels */)
 64 virtual void prepareToUpdate(GraphicsContext3D* context, const IntRect& contentRect, const IntSize& tileSize)
6565 {
6666 m_texSubImage.setSubImageSize(tileSize);
6767 }
6868
 69 virtual void prepareToUpdateRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& destRect) { }
 70
 71 virtual void paintContents(const IntRect& contentRect, int borderTexels) { }
 72
 73 virtual void paintTextureRect(ManagedTexture* texture, const IntRect& sourceRect) { }
 74
6975 virtual void updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
7076 {
7177 texture->bindTexture(context, allocator);

@@void ImageLayerChromium::setContents(Image* contents)
144150 setOpaque(!m_contents->currentFrameHasAlpha());
145151}
146152
147 void ImageLayerChromium::paintContentsIfDirty()
 153void ImageLayerChromium::prepareToPaintContents()
148154{
149155 if (!m_dirtyRect.isEmpty()) {
150156 m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame());

@@void ImageLayerChromium::paintContentsIfDirty()
162168 prepareToUpdate(visibleLayerRect());
163169}
164170
 171void ImageLayerChromium::paintContentsIfDirty()
 172{
 173 if (!m_dirtyRect.isEmpty())
 174 m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame());
 175}
 176
165177LayerTextureUpdater* ImageLayerChromium::textureUpdater() const
166178{
167179 return m_textureUpdater.get();

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

@@public:
5353 virtual ~ImageLayerChromium();
5454
5555 virtual bool drawsContent() const;
 56 virtual void prepareToPaintContents();
5657 virtual void paintContentsIfDirty();
5758
5859 void setContents(Image* image);

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

@@public:
159159
160160 // These methods typically need to be overwritten by derived classes.
161161 virtual bool drawsContent() const { return false; }
 162 virtual void prepareToPaintContents() { }
162163 virtual void paintContentsIfDirty() { }
 164 virtual void prepareCompositorResources(GraphicsContext3D*, CCTextureUpdater&) { }
163165 virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) { }
164166 virtual void setIsMask(bool) { }
165167 virtual void unreserveContentsTexture() { }

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

@@public:
6161 // This format specifies the component order in the sampled texel.
6262 // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red.
6363 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
64  virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
 64 virtual void prepareToUpdate(GraphicsContext3D*, const IntRect& contentRect, const IntSize& tileSize) = 0;
 65 virtual void prepareToUpdateRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& destRect) = 0;
 66 virtual void paintContents(const IntRect& contentRect, int borderTexels) = 0;
 67 virtual void paintTextureRect(ManagedTexture*, const IntRect& sourceRect) = 0;
6568 virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
6669};
6770

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

4242#include "PlatformContextSkia.h"
4343#include "SkCanvas.h"
4444#include "SkGpuDevice.h"
 45#include "skia/ext/platform_canvas.h"
4546#endif // USE(SKIA)
4647
4748namespace WebCore {

@@LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChro
111112{
112113}
113114
114 void LayerTextureUpdaterCanvas::paintContents(GraphicsContext& context, const IntRect& contentRect)
 115void LayerTextureUpdaterCanvas::paint(GraphicsContext& context, const IntRect& contentRect)
115116{
116117 context.translate(-contentRect.x(), -contentRect.y());
117118 {

@@LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterBitmap::sampledTexelF
139140 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA;
140141}
141142
142 void LayerTextureUpdaterBitmap::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels)
 143void LayerTextureUpdaterBitmap::prepareToUpdate(GraphicsContext3D* context, const IntRect& contentRect, const IntSize& tileSize)
143144{
144145 m_texSubImage.setSubImageSize(tileSize);
145146
146147 m_canvas.resize(contentRect.size());
 148}
 149
 150void LayerTextureUpdaterBitmap::paintContents(const IntRect& contentRect, int borderTexels)
 151{
147152 // Assumption: if a tiler is using border texels, then it is because the
148153 // layer is likely to be filtered or transformed. Because of it might be
149154 // transformed, draw the text in grayscale instead of subpixel antialiasing.
150155 PlatformCanvas::Painter::TextOption textOption =
151156 borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText;
152157 PlatformCanvas::Painter canvasPainter(&m_canvas, textOption);
153  paintContents(*canvasPainter.context(), contentRect);
 158 paint(*canvasPainter.context(), contentRect);
154159}
155160
156161void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)

@@void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, Te
162167}
163168
164169#if USE(SKIA)
165 PassRefPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter)
 170LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter)
 171 : LayerTextureUpdaterCanvas(painter)
166172{
167  return adoptRef(new LayerTextureUpdaterSkPicture(painter));
168173}
169174
170 LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter)
171  : LayerTextureUpdaterCanvas(painter)
 175void LayerTextureUpdaterSkPicture::paintContents(const IntRect& contentRect, int borderTexels)
172176{
 177 SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height());
 178 PlatformContextSkia platformContext(canvas);
 179 GraphicsContext graphicsContext(&platformContext);
 180 paint(graphicsContext, contentRect);
 181 m_picture.endRecording();
173182}
174183
175 LayerTextureUpdaterSkPicture::~LayerTextureUpdaterSkPicture()
 184void LayerTextureUpdaterSkPicture::drawPicture(SkCanvas* canvas)
176185{
 186 TRACE_EVENT("LayerTextureUpdaterSkPicture::drawPicture", this, 0);
 187 canvas->drawPicture(m_picture);
177188}
178189
179 LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterSkPicture::sampledTexelFormat(GC3Denum textureFormat)
 190PassRefPtr<LayerTextureUpdaterSharedMemory> LayerTextureUpdaterSharedMemory::create(PassOwnPtr<LayerPainterChromium> painter)
180191{
181  // Here we directly render to the texture, so the component order is always correct.
182  return LayerTextureUpdater::SampledTexelFormatRGBA;
 192 return adoptRef(new LayerTextureUpdaterSharedMemory(painter));
183193}
184194
185 void LayerTextureUpdaterSkPicture::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels)
 195LayerTextureUpdaterSharedMemory::LayerTextureUpdaterSharedMemory(PassOwnPtr<LayerPainterChromium> painter) : LayerTextureUpdaterSkPicture(painter)
186196{
187  SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height());
188  PlatformContextSkia platformContext(canvas);
189  GraphicsContext graphicsContext(&platformContext);
190  paintContents(graphicsContext, contentRect);
191  m_picture.endRecording();
192197}
193198
194 void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
 199LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterSharedMemory::sampledTexelFormat(GC3Denum textureFormat)
 200{
 201 // The component order may be bgra if we uploaded bgra pixels to rgba textures.
 202 return PlatformColor::sameComponentOrder(textureFormat) ?
 203 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA;
 204}
 205
 206void LayerTextureUpdaterSharedMemory::prepareToUpdateRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& destRect)
 207{
 208 texture->bindTexture(context, allocator);
 209 texture->mapTexSubImage2D(context, allocator, destRect);
 210}
 211
 212void LayerTextureUpdaterSharedMemory::paintTextureRect(ManagedTexture* texture, const IntRect& sourceRect)
 213{
 214 OwnPtr<SkCanvas> canvas = adoptPtr(new skia::PlatformCanvas(sourceRect.width(), sourceRect.height(), false, texture->mappedBuffer()));
 215
 216 // Translate the origin of contentRect to that of sourceRect.
 217 canvas->translate(contentRect().x() - sourceRect.x(),
 218 contentRect().y() - sourceRect.y());
 219 drawPicture(canvas.get());
 220}
 221
 222void LayerTextureUpdaterSharedMemory::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
 223{
 224 texture->bindTexture(context, allocator);
 225 texture->unmapTexSubImage2D(context);
 226}
 227
 228PassRefPtr<LayerTextureUpdaterFramebuffer> LayerTextureUpdaterFramebuffer::create(PassOwnPtr<LayerPainterChromium> painter)
 229{
 230 return adoptRef(new LayerTextureUpdaterFramebuffer(painter));
 231}
 232
 233LayerTextureUpdaterFramebuffer::LayerTextureUpdaterFramebuffer(PassOwnPtr<LayerPainterChromium> painter)
 234 : LayerTextureUpdaterSkPicture(painter)
 235{
 236}
 237
 238LayerTextureUpdaterFramebuffer::~LayerTextureUpdaterFramebuffer()
 239{
 240}
 241
 242LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterFramebuffer::sampledTexelFormat(GC3Denum textureFormat)
 243{
 244 // Here we directly render to the texture, so the component order is always correct.
 245 return LayerTextureUpdater::SampledTexelFormatRGBA;
 246}
 247
 248void LayerTextureUpdaterFramebuffer::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
195249{
196250 // Make sure SKIA uses the correct GL context.
197251 context->makeContextCurrent();

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

@@class LayerTextureUpdaterCanvas : public LayerTextureUpdater {
5454protected:
5555 explicit LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChromium>);
5656
57  void paintContents(GraphicsContext&, const IntRect& contentRect);
 57 void paint(GraphicsContext&, const IntRect& contentRect);
5858 const IntRect& contentRect() const { return m_contentRect; }
5959
6060private:

@@public:
7070
7171 virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
7272 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
73  virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
 73 virtual void prepareToUpdate(GraphicsContext3D*, const IntRect& contentRect, const IntSize& tileSize);
 74 virtual void prepareToUpdateRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& destRect) { }
 75 virtual void paintContents(const IntRect& contentRect, int borderTexels);
 76 virtual void paintTextureRect(ManagedTexture* texture, const IntRect& sourceRect) { }
7477 virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
7578
7679private:

@@private:
8285#if USE(SKIA)
8386class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas {
8487public:
85  static PassRefPtr<LayerTextureUpdaterSkPicture> create(PassOwnPtr<LayerPainterChromium>);
86  virtual ~LayerTextureUpdaterSkPicture();
 88 explicit LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium>);
 89
 90 virtual void paintContents(const IntRect& contentRect, int borderTexels);
 91 void drawPicture(SkCanvas*);
 92
 93protected:
 94 SkPicture m_picture; // Recording canvas.
 95};
 96
 97class LayerTextureUpdaterSharedMemory : public LayerTextureUpdaterSkPicture {
 98public:
 99 static PassRefPtr<LayerTextureUpdaterSharedMemory> create(PassOwnPtr<LayerPainterChromium>);
 100
 101 virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
 102 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
 103 virtual void prepareToUpdate(GraphicsContext3D*, const IntRect& contentRect, const IntSize& tileSize) { }
 104 virtual void prepareToUpdateRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& destRect);
 105 virtual void paintTextureRect(ManagedTexture*, const IntRect& sourceRect);
 106 virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
 107
 108private:
 109 LayerTextureUpdaterSharedMemory(PassOwnPtr<LayerPainterChromium>);
 110};
 111
 112class LayerTextureUpdaterFramebuffer : public LayerTextureUpdaterSkPicture {
 113public:
 114 static PassRefPtr<LayerTextureUpdaterFramebuffer> create(PassOwnPtr<LayerPainterChromium>);
 115 virtual ~LayerTextureUpdaterFramebuffer();
87116
88117 virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; }
89118 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
90  virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
 119 virtual void prepareToUpdate(GraphicsContext3D*, const IntRect& contentRect, const IntSize& tileSize) { }
 120 virtual void prepareToUpdateRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& destRect) { }
 121 virtual void paintTextureRect(ManagedTexture* texture, const IntRect& sourceRect) { }
91122 virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
92123
93124private:
94  explicit LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium>);
95 
96  SkPicture m_picture; // Recording canvas.
 125 explicit LayerTextureUpdaterFramebuffer(PassOwnPtr<LayerPainterChromium>);
97126};
98127#endif // USE(SKIA)
99128

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

2828
2929#include "ManagedTexture.h"
3030
 31#include "Extensions3DChromium.h"
3132#include "GraphicsContext3D.h"
3233#include "TextureManager.h"
3334

@@ManagedTexture::ManagedTexture(TextureManager* manager)
3839 , m_token(0)
3940 , m_format(0)
4041 , m_textureId(0)
 42 , m_mappedBuffer(0)
4143{
4244}
4345
4446ManagedTexture::~ManagedTexture()
4547{
 48 ASSERT(!m_mappedBuffer);
4649 if (m_token)
4750 m_textureManager->releaseToken(m_token);
4851}

@@void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context, TextureAll
9699 context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0);
97100}
98101
 102void ManagedTexture::mapTexSubImage2D(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& destRect)
 103{
 104 ASSERT(!m_mappedBuffer);
 105 if (!m_textureId)
 106 m_textureId = m_textureManager->allocateTexture(allocator, m_token);
 107 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
 108 m_mappedBuffer = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), m_format, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
 109}
 110
 111void ManagedTexture::unmapTexSubImage2D(GraphicsContext3D* context)
 112{
 113 ASSERT(m_mappedBuffer);
 114 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
 115 extensions->unmapTexSubImage2DCHROMIUM(m_mappedBuffer);
 116 m_mappedBuffer = 0;
 117}
 118
99119}
100120
101121#endif // USE(ACCELERATED_COMPOSITING)

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

@@public:
5757
5858 void bindTexture(GraphicsContext3D*, TextureAllocator*);
5959 void framebufferTexture2D(GraphicsContext3D*, TextureAllocator*);
 60 void mapTexSubImage2D(GraphicsContext3D*, TextureAllocator*, const IntRect&);
 61 void unmapTexSubImage2D(GraphicsContext3D*);
6062
6163 IntSize size() const { return m_size; }
6264 unsigned format() const { return m_format; }
6365 unsigned textureId() const { return m_textureId; }
 66 uint8_t* mappedBuffer() const { return m_mappedBuffer; }
6467
6568private:
6669 explicit ManagedTexture(TextureManager*);

@@private:
7073 IntSize m_size;
7174 unsigned m_format;
7275 unsigned m_textureId;
 76 uint8_t* m_mappedBuffer;
7377};
7478
7579}

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

@@public:
6060
6161 // Layer-space dirty rectangle that needs to be repainted.
6262 IntRect m_dirtyLayerRect;
 63 // Tile-space rectangle that needs to be updated.
 64 IntRect m_updateRect;
6365private:
6466 OwnPtr<ManagedTexture> m_tex;
6567};

@@void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
151153 isNonCompositedContent() ? CCLayerTilingData::NoBorderTexels : CCLayerTilingData::HasBorderTexels);
152154}
153155
154 void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
 156void TiledLayerChromium::prepareCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
155157{
156  // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
 158 if (m_paintRect.isEmpty())
 159 return;
 160
 161 textureUpdater()->prepareToUpdate(context, m_paintRect, m_tiler->tileSize());
 162
157163 if (m_skipsDraw || m_requestedUpdateRect.isEmpty() || !m_tiler->numTiles())
158164 return;
159165

@@void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, C
162168 for (int j = top; j <= bottom; ++j) {
163169 for (int i = left; i <= right; ++i) {
164170 UpdatableTile* tile = tileAt(i, j);
165  if (!tile)
166  tile = createTile(i, j);
167  else if (!tile->dirty())
 171 if (!tile || !tile->dirty())
168172 continue;
169173
170  // Calculate page-space rectangle to copy from.
 174 // Calculate page-space rectangle to update.
171175 IntRect sourceRect = m_tiler->tileContentRect(tile);
172176 const IntPoint anchor = sourceRect.location();
173177 sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect));

@@void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, C
177181 if (sourceRect.isEmpty())
178182 continue;
179183
180  ASSERT(tile->texture()->isReserved());
181 
182  // Calculate tile-space rectangle to upload into.
 184 // Calculate tile-space rectangle to update.
183185 IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size());
184186 if (destRect.x() < 0)
185187 CRASH();
186188 if (destRect.y() < 0)
187189 CRASH();
188190
 191 tile->m_updateRect = destRect;
 192
 193 textureUpdater()->prepareToUpdateRect(context, updater.allocator(), tile->texture(), destRect);
 194 }
 195 }
 196}
 197
 198void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
 199{
 200 // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
 201 if (m_skipsDraw || m_requestedUpdateRect.isEmpty() || !m_tiler->numTiles())
 202 return;
 203
 204 int left, top, right, bottom;
 205 m_tiler->contentRectToTileIndices(m_requestedUpdateRect, left, top, right, bottom);
 206 for (int j = top; j <= bottom; ++j) {
 207 for (int i = left; i <= right; ++i) {
 208 UpdatableTile* tile = tileAt(i, j);
 209 if (!tile || !tile->dirty())
 210 continue;
 211
 212 IntPoint tileOffset = m_tiler->tileContentRect(tile).location();
 213
 214 // Calculate page-space rectangle to copy from.
 215 IntRect sourceRect(IntPoint(tile->m_updateRect.x() + tileOffset.x(), tile->m_updateRect.y() + tileOffset.y()), tile->m_updateRect.size());
 216 if (sourceRect.isEmpty())
 217 continue;
 218
 219 ASSERT(tile->texture()->isReserved());
 220
189221 // Offset from paint rectangle to this tile's dirty rectangle.
190222 IntPoint paintOffset(sourceRect.x() - m_paintRect.x(), sourceRect.y() - m_paintRect.y());
191223 if (paintOffset.x() < 0)
192224 CRASH();
193225 if (paintOffset.y() < 0)
194226 CRASH();
195  if (paintOffset.x() + destRect.width() > m_paintRect.width())
 227 if (paintOffset.x() + tile->m_updateRect.width() > m_paintRect.width())
196228 CRASH();
197  if (paintOffset.y() + destRect.height() > m_paintRect.height())
 229 if (paintOffset.y() + tile->m_updateRect.height() > m_paintRect.height())
198230 CRASH();
199231
200232 tile->texture()->bindTexture(context, updater.allocator());

@@void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, C
202234 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
203235 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
204236
205  updater.append(tile->texture(), textureUpdater(), sourceRect, destRect);
 237 updater.append(tile->texture(), textureUpdater(), sourceRect, tile->m_updateRect);
206238 tile->clearDirty();
207239 }
208240 }

@@void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect)
365397 m_requestedUpdateRect = contentRect;
366398
367399 m_paintRect = m_tiler->layerRectToContentRect(dirtyLayerRect);
368  if (dirtyLayerRect.isEmpty())
 400}
 401
 402void TiledLayerChromium::paintContents()
 403{
 404 ASSERT(m_tiler);
 405
 406 if (m_requestedUpdateRect.isEmpty())
 407 return;
 408
 409 if (!m_tiler->numTiles())
 410 return;
 411
 412 if (m_skipsDraw)
 413 return;
 414
 415 if (m_paintRect.isEmpty())
369416 return;
370417
371  // Calling prepareToUpdate() calls into WebKit to paint, which may have the side
 418 // Calling paintContents() calls into WebKit to paint, which may have the side
372419 // effect of disabling compositing, which causes our reference to the texture updater to be deleted.
373420 // However, we can't free the memory backing the GraphicsContext until the paint finishes,
374421 // so we grab a local reference here to hold the updater alive until the paint completes.
375422 RefPtr<LayerTextureUpdater> protector(textureUpdater());
376  textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels());
 423 textureUpdater()->paintContents(m_paintRect, m_tiler->hasBorderTexels());
 424
 425 int left, top, right, bottom;
 426 m_tiler->contentRectToTileIndices(m_requestedUpdateRect, left, top, right, bottom);
 427 for (int j = top; j <= bottom; ++j) {
 428 for (int i = left; i <= right; ++i) {
 429 UpdatableTile* tile = tileAt(i, j);
 430 if (!tile || !tile->dirty())
 431 continue;
 432
 433 IntPoint tileOffset = m_tiler->tileContentRect(tile).location();
 434
 435 // Calculate page-space rectangle to paint.
 436 IntRect sourceRect(IntPoint(tile->m_updateRect.x() + tileOffset.x(), tile->m_updateRect.y() + tileOffset.y()), tile->m_updateRect.size());
 437 if (sourceRect.isEmpty())
 438 continue;
 439
 440 textureUpdater()->paintTextureRect(tile->texture(), sourceRect);
 441 }
 442 }
377443}
378444
379445}

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

@@public:
4343
4444 virtual ~TiledLayerChromium();
4545
 46 virtual void prepareCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
4647 virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
4748 virtual void setIsMask(bool);
4849

@@protected:
6566
6667 // Set invalidations to be potentially repainted during update().
6768 void invalidateRect(const IntRect& contentRect);
68  // Prepare data needed to update textures that intersect with contentRect.
 69 // Prepare to update textures that intersect with contentRect.
6970 void prepareToUpdate(const IntRect& contentRect);
 71 // Paint contents needed to update textures.
 72 void paintContents();
 73 // Update invalid textures that intersect with contentRect provided in prepareToUpdate().
 74 void updateRect(GraphicsContext3D*, LayerTextureUpdater*);
7075
7176 virtual void protectVisibleTileTextures();
7277

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

@@void CCLayerTreeHost::composite()
252252 static_cast<CCSingleThreadProxy*>(m_proxy.get())->compositeImmediately();
253253}
254254
 255void CCLayerTreeHost::prepareToUpdateLayers()
 256{
 257 if (!rootLayer())
 258 return;
 259
 260 if (viewportSize().isEmpty())
 261 return;
 262
 263 prepareToUpdateLayers(rootLayer());
 264}
 265
255266void CCLayerTreeHost::updateLayers()
256267{
257268 if (!rootLayer())

@@void CCLayerTreeHost::updateLayers()
263274 updateLayers(rootLayer());
264275}
265276
266 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer)
 277void CCLayerTreeHost::prepareToUpdateLayers(LayerChromium* rootLayer)
267278{
268  TRACE_EVENT("CCLayerTreeHost::updateLayers", this, 0);
 279 TRACE_EVENT("CCLayerTreeHost::prepareToUpdateLayers", this, 0);
269280
270281 if (!rootLayer->renderSurface())
271282 rootLayer->createRenderSurface();

@@void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer)
275286 rootLayer->setScissorRect(rootScissorRect);
276287
277288 // This assert fires if updateCompositorResources wasn't called after
278  // updateLayers. Only one update can be pending at any given time.
 289 // prepareToUpdateLayers. Only one update can be pending at any given time.
279290 ASSERT(!m_updateList.size());
280291 m_updateList.append(rootLayer);
281292

@@void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer)
287298 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, m_zoomAnimatorTransform, m_zoomAnimatorTransform, m_updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize);
288299 }
289300
 301 prepareToPaintLayerContents(m_updateList);
 302}
 303
 304void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer)
 305{
 306 TRACE_EVENT("CCLayerTreeHost::updateLayers", this, 0);
 307
290308 paintLayerContents(m_updateList);
291309}
292310
293 static void paintContentsIfDirty(LayerChromium* layer, const IntRect& visibleLayerRect)
 311static void prepareToPaintContents(LayerChromium* layer, const IntRect& visibleLayerRect)
294312{
295313 if (layer->drawsContent()) {
296314 layer->setVisibleLayerRect(visibleLayerRect);
297  layer->paintContentsIfDirty();
 315 layer->prepareToPaintContents();
298316 }
299317}
300318
301 void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderSurfaceLayer)
 319void CCLayerTreeHost::prepareToPaintMaskAndReplicaForRenderSurface(LayerChromium* renderSurfaceLayer)
302320{
303321 // Note: Masks and replicas only exist for layers that own render surfaces. If we reach this point
304322 // in code, we already know that at least something will be drawn into this render surface, so the

@@void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderS
306324
307325 if (renderSurfaceLayer->maskLayer()) {
308326 renderSurfaceLayer->maskLayer()->setLayerTreeHost(this);
309  paintContentsIfDirty(renderSurfaceLayer->maskLayer(), IntRect(IntPoint(), renderSurfaceLayer->contentBounds()));
 327 prepareToPaintContents(renderSurfaceLayer->maskLayer(), IntRect(IntPoint(), renderSurfaceLayer->contentBounds()));
310328 }
311329
312330 LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer();

@@void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderS
315333 IntRect visibleLayerRect = CCLayerTreeHostCommon::calculateVisibleLayerRect<LayerChromium>(renderSurfaceLayer);
316334
317335 replicaLayer->setLayerTreeHost(this);
318  paintContentsIfDirty(replicaLayer, visibleLayerRect);
 336 prepareToPaintContents(replicaLayer, visibleLayerRect);
319337
320338 if (replicaLayer->maskLayer()) {
321339 replicaLayer->maskLayer()->setLayerTreeHost(this);
322  paintContentsIfDirty(replicaLayer->maskLayer(), IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds()));
 340 prepareToPaintContents(replicaLayer->maskLayer(), IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds()));
323341 }
324342 }
325343}
326344
327 void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList)
 345void CCLayerTreeHost::prepareToPaintLayerContents(const LayerList& renderSurfaceLayerList)
328346{
329347 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
330348 LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();

@@void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
340358 continue;
341359
342360 renderSurfaceLayer->setLayerTreeHost(this);
343  paintMaskAndReplicaForRenderSurface(renderSurfaceLayer);
 361 prepareToPaintMaskAndReplicaForRenderSurface(renderSurfaceLayer);
344362
345363 const LayerList& layerList = renderSurface->layerList();
346364 ASSERT(layerList.size());

@@void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
359377
360378 IntRect visibleLayerRect = CCLayerTreeHostCommon::calculateVisibleLayerRect<LayerChromium>(layer);
361379
362  paintContentsIfDirty(layer, visibleLayerRect);
 380 prepareToPaintContents(layer, visibleLayerRect);
363381 }
364382 }
365383}
366384
 385static void paintContentsIfDirty(LayerChromium* layer)
 386{
 387 if (layer->drawsContent())
 388 layer->paintContentsIfDirty();
 389}
 390
 391void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderSurfaceLayer)
 392{
 393 if (renderSurfaceLayer->maskLayer())
 394 paintContentsIfDirty(renderSurfaceLayer->maskLayer());
 395
 396 LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer();
 397 if (replicaLayer) {
 398 paintContentsIfDirty(replicaLayer);
 399
 400 if (replicaLayer->maskLayer())
 401 paintContentsIfDirty(replicaLayer->maskLayer());
 402 }
 403}
 404
 405void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList)
 406{
 407 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
 408 LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
 409 RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
 410 ASSERT(renderSurface);
 411
 412 if (!renderSurface->layerList().size() || !renderSurface->drawOpacity())
 413 continue;
 414
 415 paintMaskAndReplicaForRenderSurface(renderSurfaceLayer);
 416
 417 const LayerList& layerList = renderSurface->layerList();
 418 ASSERT(layerList.size());
 419 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
 420 LayerChromium* layer = layerList[layerIndex].get();
 421
 422 if (layer->renderSurface() && layer->renderSurface() != renderSurface)
 423 continue;
 424
 425 paintContentsIfDirty(layer);
 426 }
 427 }
 428}
 429
 430void CCLayerTreeHost::prepareCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
 431{
 432 for (int surfaceIndex = m_updateList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
 433 LayerChromium* renderSurfaceLayer = m_updateList[surfaceIndex].get();
 434 RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
 435 ASSERT(renderSurface);
 436
 437 if (!renderSurface->layerList().size() || !renderSurface->drawOpacity())
 438 continue;
 439
 440 if (renderSurfaceLayer->maskLayer())
 441 prepareCompositorResources(renderSurfaceLayer->maskLayer(), context, updater);
 442
 443 if (renderSurfaceLayer->replicaLayer()) {
 444 prepareCompositorResources(renderSurfaceLayer->replicaLayer(), context, updater);
 445
 446 if (renderSurfaceLayer->replicaLayer()->maskLayer())
 447 prepareCompositorResources(renderSurfaceLayer->replicaLayer()->maskLayer(), context, updater);
 448 }
 449
 450 const LayerList& layerList = renderSurface->layerList();
 451 ASSERT(layerList.size());
 452 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
 453 LayerChromium* layer = layerList[layerIndex].get();
 454 if (layer->renderSurface() && layer->renderSurface() != renderSurface)
 455 continue;
 456
 457 prepareCompositorResources(layer, context, updater);
 458 }
 459 }
 460}
 461
 462void CCLayerTreeHost::prepareCompositorResources(LayerChromium* layer, GraphicsContext3D* context, CCTextureUpdater& updater)
 463{
 464 // For normal layers, these conditions should have already been checked while creating the render surface layer lists.
 465 // For masks and replicas however, we may still need to check them here.
 466 if (layer->bounds().isEmpty() || !layer->opacity() || !layer->drawsContent())
 467 return;
 468
 469 layer->prepareCompositorResources(context, updater);
 470}
 471
367472void CCLayerTreeHost::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
368473{
369474 for (int surfaceIndex = m_updateList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {

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

@@struct CCSettings {
7070 : acceleratePainting(false)
7171 , compositeOffscreen(false)
7272 , enableCompositorThread(false)
 73 , sharedMemoryPainting(false)
7374 , showFPSCounter(false)
7475 , showPlatformLayerTree(false) { }
7576
7677 bool acceleratePainting;
7778 bool compositeOffscreen;
7879 bool enableCompositorThread;
 80 bool sharedMemoryPainting;
7981 bool showFPSCounter;
8082 bool showPlatformLayerTree;
8183};

@@public:
158160
159161 void setVisible(bool);
160162
 163 void prepareToUpdateLayers();
161164 void updateLayers();
162165
 166 void prepareCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
163167 void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
164168 void applyScrollDeltas(const CCScrollUpdateSet&);
165169 void startRateLimiter(GraphicsContext3D*);

@@protected:
171175private:
172176 typedef Vector<RefPtr<LayerChromium> > LayerList;
173177
 178 void prepareToPaintLayerContents(const LayerList&);
 179 void prepareToPaintMaskAndReplicaForRenderSurface(LayerChromium*);
174180 void paintLayerContents(const LayerList&);
175181 void paintMaskAndReplicaForRenderSurface(LayerChromium*);
176182
 183 void prepareToUpdateLayers(LayerChromium*);
177184 void updateLayers(LayerChromium*);
 185
 186 void prepareCompositorResources(LayerChromium*, GraphicsContext3D*, CCTextureUpdater&);
178187 void updateCompositorResources(LayerChromium*, GraphicsContext3D*, CCTextureUpdater&);
 188
179189 void clearPendingUpdate();
180190
181191 int m_compositorIdentifier;

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

@@void CCSingleThreadProxy::commitIfNeeded()
266266{
267267 ASSERT(CCProxy::isMainThread());
268268
 269 // Prepare update
 270 m_layerTreeHost->prepareToUpdateLayers();
 271
 272 // Allocate
 273 {
 274 DebugScopedSetImplThread impl;
 275
 276 CCTextureUpdater updater(m_layerTreeHostImpl->contentsTextureAllocator());
 277 m_layerTreeHost->prepareCompositorResources(m_layerTreeHostImpl->context(), updater);
 278 }
 279
 280 // Update
269281 m_layerTreeHost->updateLayers();
270282
271283 doCommit();

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

@@void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim
391391 // updateLayers.
392392 m_commitRequested = false;
393393
 394 m_layerTreeHost->prepareToUpdateLayers();
 395
 396 {
 397 // Blocking call to CCThreadProxy::allocateOnImplThread
 398 TRACE_EVENT("allocate", this, 0);
 399 CCCompletionEvent completion;
 400 s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::allocateOnImplThread, AllowCrossThreadAccess(&completion)));
 401 completion.wait();
 402 }
 403
394404 m_layerTreeHost->updateLayers();
395405
396406 {

@@void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim
410420 ASSERT(m_lastExecutedBeginFrameAndCommitSequenceNumber == sequenceNumber);
411421}
412422
 423void CCThreadProxy::allocateOnImplThread(CCCompletionEvent* completion)
 424{
 425 TRACE_EVENT("CCThreadProxy::allocateOnImplThread", this, 0);
 426 ASSERT(isImplThread());
 427 if (!m_layerTreeHostImpl) {
 428 completion->signal();
 429 return;
 430 }
 431
 432 CCTextureUpdater updater(m_layerTreeHostImpl->contentsTextureAllocator());
 433 m_layerTreeHost->prepareCompositorResources(m_layerTreeHostImpl->context(), updater);
 434
 435 completion->signal();
 436}
 437
413438void CCThreadProxy::commitOnImplThread(CCCompletionEvent* completion)
414439{
415440 TRACE_EVENT("CCThreadProxy::beginFrameAndCommitOnImplThread", this, 0);

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

@@private:
8080 void postBeginFrameAndCommitOnImplThread();
8181 PassOwnPtr<CCMainThread::Task> createBeginFrameAndCommitTaskOnImplThread();
8282 void obtainBeginFrameAndCommitTaskFromCCThread(CCCompletionEvent*, CCMainThread::Task**);
 83 void allocateOnImplThread(CCCompletionEvent*);
8384 void commitOnImplThread(CCCompletionEvent*);
8485 void drawLayersAndSwapOnImplThread();
8586 void drawLayersOnImplThread();

Source/WebKit/chromium/public/WebLayerTreeView.h

@@public:
4545 Settings()
4646 : acceleratePainting(false)
4747 , compositeOffscreen(false)
48  , enableCompositorThread(false) { }
 48 , enableCompositorThread(false)
 49 , sharedMemoryPainting(false) { }
4950
5051 bool acceleratePainting;
5152 bool compositeOffscreen;
5253 bool enableCompositorThread;
 54 bool sharedMemoryPainting;
5355#if WEBKIT_IMPLEMENTATION
5456 operator WebCore::CCSettings() const;
5557#endif

Source/WebKit/chromium/public/WebSettings.h

@@public:
131131 virtual void setShouldPrintBackgrounds(bool) = 0;
132132 virtual void setEnableScrollAnimator(bool) = 0;
133133 virtual void setHixie76WebSocketProtocolEnabled(bool) = 0;
 134 virtual void setSharedMemoryPainting(bool) = 0;
 135 virtual bool sharedMemoryPainting() const = 0;
134136
135137protected:
136138 ~WebSettings() { }

Source/WebKit/chromium/src/WebLayerTreeView.cpp

@@WebLayerTreeView::Settings::operator CCSettings() const
3939 settings.acceleratePainting = acceleratePainting;
4040 settings.compositeOffscreen = compositeOffscreen;
4141 settings.enableCompositorThread = enableCompositorThread;
 42 settings.sharedMemoryPainting = sharedMemoryPainting;
4243
4344 // FIXME: showFPSCounter / showPlatformLayerTree aren't supported currently.
4445 settings.showFPSCounter = false;

Source/WebKit/chromium/src/WebSettingsImpl.cpp

@@namespace WebKit {
4848WebSettingsImpl::WebSettingsImpl(Settings* settings)
4949 : m_settings(settings)
5050 , m_compositeToTextureEnabled(false)
 51 , m_sharedMemoryPainting(false)
5152 , m_showFPSCounter(false)
5253 , m_showPlatformLayerTree(false)
5354 , m_useThreadedCompositor(false)

@@void WebSettingsImpl::setHixie76WebSocketProtocolEnabled(bool enabled)
460461#endif
461462}
462463
 464void WebSettingsImpl::setSharedMemoryPainting(bool enabled)
 465{
 466 m_sharedMemoryPainting = enabled;
 467}
 468
463469} // namespace WebKit

Source/WebKit/chromium/src/WebSettingsImpl.h

@@public:
123123 virtual void setShouldPrintBackgrounds(bool);
124124 virtual void setEnableScrollAnimator(bool);
125125 virtual void setHixie76WebSocketProtocolEnabled(bool);
 126 virtual void setSharedMemoryPainting(bool);
 127 virtual bool sharedMemoryPainting() const { return m_sharedMemoryPainting; }
126128
127129private:
128130 WebCore::Settings* m_settings;
129131 bool m_compositeToTextureEnabled;
 132 bool m_sharedMemoryPainting;
130133 bool m_showFPSCounter;
131134 bool m_showPlatformLayerTree;
132135 bool m_useThreadedCompositor;

Source/WebKit/chromium/src/WebViewImpl.cpp

@@void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
26792679 ccSettings.acceleratePainting = page()->settings()->acceleratedDrawingEnabled();
26802680 ccSettings.compositeOffscreen = settings()->compositeToTextureEnabled();
26812681 ccSettings.enableCompositorThread = settings()->useThreadedCompositor();
 2682 ccSettings.sharedMemoryPainting = settings()->sharedMemoryPainting();
26822683 ccSettings.showFPSCounter = settings()->showFPSCounter();
26832684 ccSettings.showPlatformLayerTree = settings()->showPlatformLayerTree();
26842685