[skia] Improve performance of GraphicsContext::createCompatibleBuffer by using SkDevi...
authorjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2012 21:40:26 +0000 (21:40 +0000)
committerjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2012 21:40:26 +0000 (21:40 +0000)
commit13c77196d34253b6d6325cefa8d93f9fc4180cff
treed62eb265ba95fabb4489efe428ef4967a484a15a
parent5e75264ce0599a06506e6f080beb3735be7d3f48
[skia] Improve performance of GraphicsContext::createCompatibleBuffer by using SkDevice:createCompatibleDevice
https://bugs.webkit.org/show_bug.cgi?id=103896

Reviewed by Stephen White.

Source/WebCore:

Refactored GraphicsContext::createCompatibleBuffer (platform common
code) to use platform-specific implementations provided by ImageBuffer.
There is no change in behavior for non-skia ports. The skia
implementation uses skia'a own createCompatibleDevice implementation,
which offers several performance benefits:
1. For accelerated contexts, the backing store may be allocated from
the scratch texture pool, which minimizes texture allocation and
deallocation overhead.
2. The backing store will not be initially cleared if it is known
in advance that fully opaque contents will be drawn into the buffer.
3. For non-accelerated contexts, if the backing store is flagged as
opaque, faster blitter loop implementations will be used for drawing
the buffer contents into other buffers. (e.g. generated opaque gradient
fills)

No new tests: covered by existing layout tests

* platform/graphics/Generator.h:
(Generator):
Added hasAlpha method so that it can be used by GeneratorGeneratedImage
* platform/graphics/GeneratorGeneratedImage.cpp:
(WebCore::GeneratorGeneratedImage::drawPattern):
Passing m_generator->hasAlpha() to createCompatibleBuffer in order to
take advantage of optimizations that apply to opaque buffers.
* platform/graphics/Gradient.h:
(Gradient):
Made hasAlpha virtual so that it now overrides Generator::hasAlpha
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::createCompatibleBuffer):
Refactored to use platform-specific implementation
* platform/graphics/GraphicsContext.h:
* platform/graphics/ImageBuffer.cpp:
(WebCore::createCompatibleBuffer):
Non-skia implementation. Mimics old
GraphicsContext::createCompatibleBuffer
* platform/graphics/ImageBuffer.h:
(ImageBuffer):
New skia-specific constructor
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::ImageBuffer::createCompatibleBuffer):
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::createCompatibleDevice):
(WebCore):
* platform/graphics/skia/PlatformContextSkia.h:
(PlatformContextSkia):

LayoutTests:

Added image failure expectation for test needing new baselines

* platform/chromium/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136755 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Generator.h
Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp
Source/WebCore/platform/graphics/Gradient.h
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/ImageBuffer.cpp
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
Source/WebCore/platform/graphics/skia/PlatformContextSkia.h