Source/WebCore/ChangeLog

 12011-08-15 Stephen White <senorblanco@chromium.org>
 2
 3 Canvas resizing can be slow
 4 https://bugs.webkit.org/show_bug.cgi?id=66251
 5
 6 Canvas resizing was slow due to re-allocation of the ImageBuffer on
 7 each size change (width or height). This was introduced inadvertently
 8 by calls to isAccelerated() during canvas reset(). Since we won't
 9 know if we have successfully accelerated until ImageBuffer creation,
 10 move the compositor invalidation to createImageBuffer() as well.
 11 This patch also attempts to unify the Skia and CG accelerated canvas
 12 paths. The DrawingBuffer used by the Skia path is now owned by
 13 ImageBuffer[Skia], similar to how the IOSurface is owned by
 14 ImageBuffer[CG]. Some of the logic for when to accelerate was moved
 15 into HTMLCanvasElement and unified with the CG path. Acceleration is
 16 also now enabled by the same "Accelerated" ImageBuffer create flag
 17 used by the CG path. DrawingBuffer is now re-created even for a
 18 same-size change (same as the memory buffer), but we speed it up
 19 by calling GraphicsContext3D::texImage2D() with a NULL pixels ptr
 20 instead of GraphicsContext3D::teximage2DResourceSafe() (no need to
 21 clear it, since it's done with a glClear anyway).
 22
 23 Reviewed by NOBODY (OOPS!).
 24
 25 Covered by existing tests in fast/canvas and canvas/philip.
 26
 27 * html/HTMLCanvasElement.cpp:
 28 (WebCore::HTMLCanvasElement::reset):
 29 Don't call isAccelerated() from reset(), since we don't want to
 30 inadvertently create the ImageBuffer. Also, since we won't know if
 31 we have successfully accelerated until createImageBuffer() is
 32 called, defer the compositor invalidation to createImageBuffer() as
 33 well.
 34 (WebCore::HTMLCanvasElement::shouldAccelerate):
 35 Unify the CG and Skia ports' logic for when to accelerate (Skia
 36 logic moved in from CanvasRenderingContext2D).
 37 (WebCore::HTMLCanvasElement::createImageBuffer):
 38 Use the unified shouldAccelerate() logic, and pass it as a flag
 39 to ImageBuffer. Do compositor invalidation as well.
 40 * html/HTMLCanvasElement.h:
 41 (WebCore::HTMLCanvasElement::hasCreatedImageBuffer):
 42 Expose hasCreatedImageBuffer() publically, so
 43 CanvasRenderingContext2D::isAccelerated() doesn't inadvertently create
 44 it.
 45 * html/canvas/CanvasRenderingContext2D.cpp:
 46 (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
 47 (WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D):
 48 Remove all acceleration setting and resetting, since it's now done
 49 during ImageBuffer creation.
 50 (WebCore::CanvasRenderingContext2D::isAccelerated):
 51 Check if the image buffer was created, so we don't inadvertently
 52 create it here.
 53 (WebCore::CanvasRenderingContext2D::paintsIntoCanvasBuffer):
 54 Don't call GraphicsContext3D::paintsIntoCanvasBuffer(), since its
 55 WebViewImpl may be null. Ask the render tree instead.
 56 (WebCore::CanvasRenderingContext2D::reset):
 57 Don't reset acceleration here, since we don't own it anymore.
 58 (WebCore::CanvasRenderingContext2D::platformLayer):
 59 Call into the ImageBuffer to get our PlatformLayer.
 60 * html/canvas/CanvasRenderingContext2D.h:
 61 Remove m_drawingBuffer, and all acceleration-related calls.
 62 * platform/graphics/GraphicsContext.cpp:
 63 * platform/graphics/GraphicsContext.h:
 64 Remove setGraphicsContext3D(), and paintsIntoImageBuffer().
 65 * platform/graphics/ImageBuffer.cpp:
 66 (WebCore::ImageBuffer::platformLayer):
 67 Implement a dummy platformLayer() call for non-skia ports.
 68 * platform/graphics/ImageBuffer.h:
 69 Declare a platformLayer() call (USE(ACCELERATED_COMPOSITING) only).
 70 * platform/graphics/chromium/ImageBufferDataSkia.h:
 71 Add a DrawingBuffer data member.
 72 * platform/graphics/gpu/DrawingBuffer.cpp:
 73 (WebCore::DrawingBuffer::reset):
 74 Use texImage2D() with a NULL ptr, not texImage2DResourceSafe().
 75 Since we immediately clear the framebuffer via glClear(), this whole
 76 resource safe business is overkill.
 77 * platform/graphics/skia/GraphicsContextSkia.cpp:
 78 Remove setGraphicsContext3D() and paintsIntoImageBuffer(). This
 79 functionality is handled by ImageBuffer now.
 80 * platform/graphics/skia/ImageBufferSkia.cpp:
 81 (WebCore::ImageBuffer::ImageBuffer):
 82 Give the ImageBufferData ownership of the DrawingBuffer.
 83 (WebCore::ImageBuffer::platformLayer):
 84 Implement an accessor for the DrawingBuffer's PlatformLayer.
 85 * platform/graphics/skia/PlatformContextSkia.cpp:
 86 (WebCore::PlatformContextSkia::setGraphicsContext3D):
 87 * platform/graphics/skia/PlatformContextSkia.h:
 88 Remove isPathSkiaSafe() extern (unused).
 89 Remove paintsIntoImageBuffer() (now unused). Remove IntSize param
 90 from setGraphicsContext3D() (unused).
 91
1922011-08-15 Mark Hahnenberg <mhahnenberg@apple.com>
293
394 Refactor JS objects to allocate in static create methods rather than constructors
93062

Source/WebCore/html/HTMLCanvasElement.cpp

@@void HTMLCanvasElement::reset()
247247
248248 if (m_context && m_context->is2d()) {
249249 CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get());
250  bool wasAccelerated = context2D->isAccelerated();
251250 context2D->reset();
252 #if USE(IOSURFACE_CANVAS_BACKING_STORE) || (ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING))
253  // Recalculate compositing requirements if acceleration state changed.
254  if (context2D->isAccelerated() != wasAccelerated)
255  setNeedsStyleRecalc(SyntheticStyleChange);
256 #else
257  UNUSED_PARAM(wasAccelerated);
258 #endif
259251 }
260252
261253 if (RenderObject* renderer = this->renderer()) {

@@CSSStyleSelector* HTMLCanvasElement::sty
424416 return document()->styleSelector();
425417}
426418
 419bool HTMLCanvasElement::shouldAccelerate(const IntSize& size) const
 420{
 421#if USE(IOSURFACE_CANVAS_BACKING_STORE)
 422 UNUSED_PARAM(size);
 423 return document()->settings()->canvasUsesAcceleratedDrawing();
 424#elif ENABLE(ACCELERATED_2D_CANVAS)
 425 if (m_context && !m_context->is2d())
 426 return false;
 427
 428 Settings* settings = document()->settings();
 429 if (!settings->accelerated2dCanvasEnabled())
 430 return false;
 431
 432 // Do not use acceleration for small canvas.
 433 if (size.width() * size.height() < settings->minimumAccelerated2dCanvasSize())
 434 return false;
 435
 436 return true;
 437#else
 438 UNUSED_PARAM(size);
 439 return false;
 440#endif
 441}
 442
427443void HTMLCanvasElement::createImageBuffer() const
428444{
429445 ASSERT(!m_imageBuffer);

@@void HTMLCanvasElement::createImageBuffe
435451 if (!size.width() || !size.height())
436452 return;
437453
438 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
439  if (document()->settings()->canvasUsesAcceleratedDrawing())
440  m_imageBuffer = ImageBuffer::create(size, ColorSpaceDeviceRGB, Accelerated);
441  else
442  m_imageBuffer = ImageBuffer::create(size, ColorSpaceDeviceRGB, Unaccelerated);
443 #else
444  m_imageBuffer = ImageBuffer::create(size);
445 #endif
 454 RenderingMode renderingMode = shouldAccelerate(size) ? Accelerated : Unaccelerated;
 455 m_imageBuffer = ImageBuffer::create(size, ColorSpaceDeviceRGB, renderingMode);
446456 // The convertLogicalToDevice MaxCanvasArea check should prevent common cases
447457 // where ImageBuffer::create() returns 0, however we could still be low on memory.
448458 if (!m_imageBuffer)

@@void HTMLCanvasElement::createImageBuffe
455465 JSC::JSLock lock(JSC::SilenceAssertionsOnly);
456466 scriptExecutionContext()->globalData()->heap.reportExtraMemoryCost(m_imageBuffer->dataSize());
457467#endif
 468
 469#if USE(IOSURFACE_CANVAS_BACKING_STORE) || (ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING))
 470 if (m_context && m_context->is2d())
 471 // Recalculate compositing requirements if acceleration state changed.
 472 const_cast<HTMLCanvasElement*>(this)->setNeedsStyleRecalc(SyntheticStyleChange);
 473#endif
458474}
459475
460476GraphicsContext* HTMLCanvasElement::drawingContext() const
93062

Source/WebCore/html/HTMLCanvasElement.h

@@public:
128128#endif
129129
130130 void makeRenderingResultsAvailable();
 131 bool hasCreatedImageBuffer() const { return m_hasCreatedImageBuffer; }
131132
132133private:
133134 HTMLCanvasElement(const QualifiedName&, Document*);

@@private:
137138
138139 void reset();
139140
 141 bool shouldAccelerate(const IntSize&) const;
140142 void createImageBuffer() const;
141143
142144 void setSurfaceSize(const IntSize&);
143  bool hasCreatedImageBuffer() const { return m_hasCreatedImageBuffer; }
144145
145146 HashSet<CanvasObserver*> m_observers;
146147
93062

Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

6161#include "TextMetrics.h"
6262#include "TextRun.h"
6363
64 #if ENABLE(ACCELERATED_2D_CANVAS)
65 #include "Chrome.h"
66 #include "ChromeClient.h"
67 #include "DrawingBuffer.h"
68 #include "FrameView.h"
69 #include "SharedGraphicsContext3D.h"
7064#if USE(ACCELERATED_COMPOSITING)
7165#include "RenderLayer.h"
7266#endif
73 #endif
7467
7568#include <wtf/ByteArray.h>
7669#include <wtf/MathExtras.h>

@@static bool isOriginClean(CachedImage* c
9891 return !securityOrigin->taintsCanvas(cachedImage->response().url());
9992}
10093
101 #if ENABLE(ACCELERATED_2D_CANVAS)
102 static bool shouldAccelerateCanvas(const HTMLCanvasElement* canvas)
103 {
104  const Page* page = canvas->document()->page();
105  if (!page)
106  return false;
107 
108  const Settings* settings = page->settings();
109  if (!settings->accelerated2dCanvasEnabled())
110  return false;
111 
112  // Do not use acceleration for small canvas.
113  if (canvas->width() * canvas->height() < settings->minimumAccelerated2dCanvasSize())
114  return false;
115 
116  return true;
117 }
118 #endif
119 
12094class CanvasStrokeStyleApplier : public StrokeStyleApplier {
12195public:
12296 CanvasStrokeStyleApplier(CanvasRenderingContext2D* canvasContext)

@@CanvasRenderingContext2D::CanvasRenderin
151125 // Make sure that even if the drawingContext() has a different default
152126 // thickness, it is in sync with the canvas thickness.
153127 setLineWidth(lineWidth());
154 
155 #if ENABLE(ACCELERATED_2D_CANVAS)
156  resetAcceleration();
157 #endif
158128}
159129
160130CanvasRenderingContext2D::~CanvasRenderingContext2D()

@@CanvasRenderingContext2D::~CanvasRenderi
170140 }
171141 }
172142#endif
173 
174 #if ENABLE(ACCELERATED_2D_CANVAS)
175  if (GraphicsContext* context = drawingContext())
176  context->setGraphicsContext3D(0, 0, IntSize());
177 #endif
178143}
179144
180145bool CanvasRenderingContext2D::isAccelerated() const

@@bool CanvasRenderingContext2D::isAcceler
183148 ImageBuffer* buffer = canvas()->buffer();
184149 return buffer ? buffer->isAccelerated() : false;
185150#elif ENABLE(ACCELERATED_2D_CANVAS)
186  return drawingContext() && drawingContext()->isAcceleratedContext();
 151 return canvas()->hasCreatedImageBuffer() && drawingContext() && drawingContext()->isAcceleratedContext();
187152#else
188153 return false;
189154#endif

@@bool CanvasRenderingContext2D::isAcceler
191156
192157bool CanvasRenderingContext2D::paintsIntoCanvasBuffer() const
193158{
194 #if ENABLE(ACCELERATED_2D_CANVAS)
195  if (drawingContext())
196  return drawingContext()->paintsIntoImageBuffer();
 159#if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
 160 if (!isAccelerated())
 161 return true;
 162
 163 RenderBox* renderBox = canvas()->renderBox();
 164 if (renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing())
 165 return false;
197166#endif
198167 return true;
199168}

@@void CanvasRenderingContext2D::reset()
204173 m_stateStack.resize(1);
205174 m_stateStack.first() = State();
206175 m_path.clear();
207 #if ENABLE(ACCELERATED_2D_CANVAS)
208  resetAcceleration();
209176#if USE(ACCELERATED_COMPOSITING)
210177 RenderBox* renderBox = canvas()->renderBox();
211178 if (renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing())
212179 renderBox->layer()->contentChanged(RenderLayer::CanvasChanged);
213180#endif
214 #endif
215181}
216182
217183CanvasRenderingContext2D::State::State()

@@const Font& CanvasRenderingContext2D::ac
20151981 return state().m_font;
20161982}
20171983
2018 #if ENABLE(ACCELERATED_2D_CANVAS)
2019 #if USE(ACCELERATED_COMPOSITING)
 1984#if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
20201985PlatformLayer* CanvasRenderingContext2D::platformLayer() const
20211986{
2022  return m_drawingBuffer ? m_drawingBuffer->platformLayer() : 0;
2023 }
2024 #endif
2025 
2026 void CanvasRenderingContext2D::clearAcceleration()
2027 {
2028  if (GraphicsContext* ctx = drawingContext())
2029  ctx->setGraphicsContext3D(0, 0, IntSize());
2030 
2031  m_drawingBuffer.clear();
2032 }
2033 
2034 void CanvasRenderingContext2D::resetAcceleration()
2035 {
2036  if (!shouldAccelerateCanvas(canvas())) {
2037  clearAcceleration();
2038  return;
2039  }
2040 
2041  // Try to accelerate.
2042  GraphicsContext* ctx = drawingContext();
2043  if (!ctx) {
2044  clearAcceleration();
2045  return;
2046  }
2047 
2048  Page* page = canvas()->document()->page();
2049  GraphicsContext3D* context3D = SharedGraphicsContext3D::create(page->chrome());
2050  if (!context3D) {
2051  clearAcceleration();
2052  return;
2053  }
2054 
2055  if (m_drawingBuffer) {
2056  if (!m_drawingBuffer->reset(canvas()->size())) {
2057  clearAcceleration();
2058  return;
2059  }
2060  } else {
2061  m_drawingBuffer = context3D->createDrawingBuffer(canvas()->size());
2062  if (!m_drawingBuffer) {
2063  clearAcceleration();
2064  return;
2065  }
2066  }
2067 
2068  ctx->setGraphicsContext3D(context3D, m_drawingBuffer.get(), canvas()->size());
 1987 return canvas()->buffer() ? canvas()->buffer()->platformLayer() : 0;
20691988}
20701989#endif
20711990
93062

Source/WebCore/html/canvas/CanvasRenderingContext2D.h

@@class HTMLVideoElement;
5353class ImageData;
5454class TextMetrics;
5555
56 #if ENABLE(ACCELERATED_2D_CANVAS)
57 class DrawingBuffer;
58 class SharedGraphicsContext3D;
59 #endif
60 
6156typedef int ExceptionCode;
6257
6358class CanvasRenderingContext2D : public CanvasRenderingContext {

@@private:
294289
295290 void prepareGradientForDashboard(CanvasGradient* gradient) const;
296291
297 #if ENABLE(ACCELERATED_2D_CANVAS)
298  void clearAcceleration();
299  void resetAcceleration();
300 #endif
301 
302292 Vector<State, 1> m_stateStack;
303293 bool m_usesCSSCompatibilityParseMode;
304294#if ENABLE(DASHBOARD_SUPPORT)
305295 bool m_usesDashboardCompatibilityMode;
306296#endif
307 
308 #if ENABLE(ACCELERATED_2D_CANVAS)
309  RefPtr<DrawingBuffer> m_drawingBuffer;
310 #endif
311297};
312298
313299} // namespace WebCore
93062

Source/WebCore/platform/graphics/GraphicsContext.cpp

@@void GraphicsContext::setPlatformShouldS
684684}
685685#endif
686686
687 #if !USE(SKIA)
688 void GraphicsContext::setGraphicsContext3D(GraphicsContext3D*, DrawingBuffer*, const IntSize&)
689 {
690 }
691 #endif
692 
693687#if !USE(SKIA) && !USE(CG)
694688bool GraphicsContext::isAcceleratedContext() const
695689{

@@bool GraphicsContext::isAcceleratedConte
697691}
698692#endif
699693
700 #if !USE(SKIA)
701 bool GraphicsContext::paintsIntoImageBuffer() const
702 {
703  return true;
704 }
705 #endif
706 
707694void GraphicsContext::adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle penStyle)
708695{
709696 // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
93062

Source/WebCore/platform/graphics/GraphicsContext.h

@@namespace WebCore {
275275 void setIsAcceleratedContext(bool);
276276#endif
277277 bool isAcceleratedContext() const;
278  bool paintsIntoImageBuffer() const;
279278
280279 void save();
281280 void restore();

@@namespace WebCore {
509508 pattern getHaikuStrokeStyle();
510509#endif
511510
512  void setGraphicsContext3D(GraphicsContext3D*, DrawingBuffer*, const IntSize&);
513 
514511 static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
515512
516513 private:
93062

Source/WebCore/platform/graphics/ImageBuffer.cpp

@@void ImageBuffer::convertToLuminanceMask
9595 genericConvertToLuminanceMask();
9696}
9797
 98#if USE(ACCELERATED_COMPOSITING) && !USE(SKIA)
 99PlatformLayer* ImageBuffer::platformLayer() const
 100{
 101 return 0;
 102}
 103#endif
 104
98105}
93062

Source/WebCore/platform/graphics/ImageBuffer.h

3131#include "AffineTransform.h"
3232#include "ColorSpace.h"
3333#include "FloatRect.h"
 34#if USE(ACCELERATED_COMPOSITING)
 35#include "GraphicsLayer.h"
 36#endif
3437#include "GraphicsTypes.h"
3538#include "IntSize.h"
3639#include "ImageBufferData.h"

@@namespace WebCore {
106109#else
107110 AffineTransform baseTransform() const { return AffineTransform(1, 0, 0, -1, 0, m_size.height()); }
108111#endif
 112#if USE(ACCELERATED_COMPOSITING)
 113 PlatformLayer* platformLayer() const;
 114#endif
109115
110116 private:
111117#if USE(CG)
93062

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

2828 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929 */
3030
 31#include "DrawingBuffer.h"
3132#include "PlatformContextSkia.h"
3233
3334#include "skia/ext/platform_canvas.h"

@@public:
4041
4142 OwnPtr<SkCanvas> m_canvas;
4243 PlatformContextSkia m_platformContext;
 44 RefPtr<DrawingBuffer> m_drawingBuffer;
4345};
4446
4547} // namespace WebCore
93062

Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp

@@bool DrawingBuffer::reset(const IntSize&
270270
271271 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
272272
273  m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE);
 273 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE, 0);
274274
275275 m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
276276 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
93062

Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

@@void GraphicsContext::translate(float w,
12031203 WebCoreFloatToSkScalar(h));
12041204}
12051205
1206 void GraphicsContext::setGraphicsContext3D(GraphicsContext3D* context, DrawingBuffer* drawingBuffer, const IntSize& size)
1207 {
1208  platformContext()->setGraphicsContext3D(context, drawingBuffer, size);
1209 }
1210 
12111206bool GraphicsContext::isAcceleratedContext() const
12121207{
12131208 return platformContext()->isAccelerated();
12141209}
12151210
1216 bool GraphicsContext::paintsIntoImageBuffer() const
1217 {
1218  return platformContext()->paintsIntoImageBuffer();
1219 }
1220 
12211211#if PLATFORM(CHROMIUM) && OS(DARWIN)
12221212CGColorSpaceRef deviceRGBColorSpaceRef()
12231213{
93062

Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

4343#include "MIMETypeRegistry.h"
4444#include "PNGImageEncoder.h"
4545#include "PlatformContextSkia.h"
 46#include "SharedGraphicsContext3D.h"
4647#include "SkColorPriv.h"
4748#include "SkiaUtils.h"
4849

@@ImageBufferData::ImageBufferData(const I
6162{
6263}
6364
64 ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode, bool& success)
 65ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode renderingMode, bool& success)
6566 : m_data(size)
6667 , m_size(size)
6768{

@@ImageBuffer::ImageBuffer(const IntSize&
8081 // required, but the canvas is currently filled with the magic transparency
8182 // color. Can we have another way to manage this?
8283 m_data.m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
 84 if (renderingMode == Accelerated) {
 85 GraphicsContext3D* context3D = SharedGraphicsContext3D::create(0);
 86 if (context3D) {
 87 m_data.m_drawingBuffer = context3D->createDrawingBuffer(size);
 88 m_data.m_platformContext.setGraphicsContext3D(context3D, m_data.m_drawingBuffer.get());
 89 }
 90 }
 91
8392 success = true;
8493}
8594

@@String ImageBuffer::toDataURL(const Stri
366375 return ImageToDataURL(device->accessBitmap(false), mimeType, quality);
367376}
368377
 378PlatformLayer* ImageBuffer::platformLayer() const
 379{
 380 return m_data.m_drawingBuffer->platformLayer();
 381}
 382
369383String ImageDataToDataURL(const ImageData& source, const String& mimeType, const double* quality)
370384{
371385 return ImageToDataURL(source, mimeType, quality);
93062

Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

5959
6060namespace WebCore {
6161
62 extern bool isPathSkiaSafe(const SkMatrix& transform, const SkPath& path);
63 
6462// State -----------------------------------------------------------------------
6563
6664// Encapsulates the additional painting state information we store for each

@@void PlatformContextSkia::applyAntiAlias
652650 m_canvas->restore();
653651}
654652
655 void PlatformContextSkia::setGraphicsContext3D(GraphicsContext3D* context, DrawingBuffer* drawingBuffer, const WebCore::IntSize& size)
 653void PlatformContextSkia::setGraphicsContext3D(GraphicsContext3D* context, DrawingBuffer* drawingBuffer)
656654{
657655 m_gpuContext = context;
658656#if ENABLE(ACCELERATED_2D_CANVAS)

@@void PlatformContextSkia::makeGrContextC
682680 m_gpuContext->makeContextCurrent();
683681}
684682
685 bool PlatformContextSkia::paintsIntoImageBuffer() const
686 {
687  return m_gpuContext ? m_gpuContext->paintsIntoCanvasBuffer() : true;
688 }
689 
690683} // namespace WebCore
93062

Source/WebCore/platform/graphics/skia/PlatformContextSkia.h

@@public:
178178 bool hasImageResamplingHint() const;
179179
180180 bool isAccelerated() const { return m_gpuContext; }
181  void setGraphicsContext3D(GraphicsContext3D*, DrawingBuffer*, const IntSize&);
182  bool paintsIntoImageBuffer() const;
 181 void setGraphicsContext3D(GraphicsContext3D*, DrawingBuffer*);
183182 void makeGrContextCurrent();
184183
185184private:
93062

Source/WebKit/chromium/ChangeLog

 12011-08-15 Stephen White <senorblanco@chromium.org>
 2
 3 Canvas resizing can be slow
 4 https://bugs.webkit.org/show_bug.cgi?id=66251
 5
 6 Allow the hostWindow param (and m_webViewImpl) to be NULL. This
 7 makes it much easier to enable GPU acceleration at a lower level
 8 in WebKit's platform/graphics layer, without needing access to the
 9 Page* or HostWindow*.
 10
 11 Reviewed by NOBODY (OOPS!).
 12
 13 * src/GraphicsContext3DChromium.cpp:
 14 (WebCore::GraphicsContext3DInternal::initialize):
 15 (WebCore::GraphicsContext3DInternal::platformTexture):
 16 (WebCore::GraphicsContext3DInternal::paintsIntoCanvasBuffer):
 17
1182011-08-15 Mikhail Naganov <mnaganov@chromium.org>
219
320 Chromium: expose MemoryCache::prune and FontCache::purgeInactiveFontData.
93062

Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp

@@bool GraphicsContext3DInternal::initiali
122122 return false;
123123
124124 Chrome* chrome = static_cast<Chrome*>(hostWindow);
125  m_webViewImpl = static_cast<WebKit::WebViewImpl*>(chrome->client()->webView());
 125 m_webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0;
126126
127  if (!m_webViewImpl)
128  return false;
129127 if (!webContext->initialize(webAttributes, m_webViewImpl, renderDirectlyToHostWindow))
130128 return false;
131129 m_impl = webContext.release();

@@PlatformGraphicsContext3D GraphicsContex
150148
151149Platform3DObject GraphicsContext3DInternal::platformTexture() const
152150{
 151 ASSERT(m_webViewImpl);
153152 m_impl->setParentContext(m_webViewImpl->graphicsContext3D());
154153 return m_impl->getPlatformTextureId();
155154}

@@PassRefPtr<ImageData> GraphicsContext3DI
303302bool GraphicsContext3DInternal::paintsIntoCanvasBuffer() const
304303{
305304 // If the gpu compositor is on then skip the readback and software rendering path.
 305 ASSERT(m_webViewImpl);
306306 return !m_webViewImpl->isAcceleratedCompositingActive();
307307}
308308
93062