Chromium Code Reviews| Index: Source/platform/graphics/Canvas2DImageBufferSurface.h |
| diff --git a/Source/core/testing/LayerRect.h b/Source/platform/graphics/Canvas2DImageBufferSurface.h |
| similarity index 55% |
| copy from Source/core/testing/LayerRect.h |
| copy to Source/platform/graphics/Canvas2DImageBufferSurface.h |
| index 4827feee4f2476d200f0a986a73c81ca9cb4d020..e7921cfdf80f107eb48f65f3f52ec5057090fe5b 100644 |
| --- a/Source/core/testing/LayerRect.h |
| +++ b/Source/platform/graphics/Canvas2DImageBufferSurface.h |
| @@ -28,44 +28,42 @@ |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| -#ifndef LayerRect_h |
| -#define LayerRect_h |
| +#ifndef Canvas2DImageBufferSurface_h |
| +#define Canvas2DImageBufferSurface_h |
| -#include "core/dom/ClientRect.h" |
| - |
| -#include "wtf/PassRefPtr.h" |
| -#include "wtf/RefCounted.h" |
| -#include "wtf/RefPtr.h" |
| -#include "wtf/text/WTFString.h" |
| +#include "platform/graphics/Canvas2DLayerBridge.h" |
| +#include "platform/graphics/ImageBufferSurface.h" |
| namespace WebCore { |
| -class Node; |
| - |
| -class LayerRect : public RefCounted<LayerRect> { |
| +// This shim necessary because ImageBufferSurfaces are not allowed to be RefCounted |
| +class Canvas2DImageBufferSurface : public ImageBufferSurface { |
| public: |
| - static PassRefPtr<LayerRect> create(PassRefPtr<Node> node, const String& layerType, PassRefPtr<ClientRect> rect) |
| + Canvas2DImageBufferSurface(const IntSize& size, OpacityMode opacityMode = NonOpaque, int msaaSampleCount = 1) |
| + : ImageBufferSurface(size, opacityMode) |
| + , m_layerBridge(Canvas2DLayerBridge::create(size, opacityMode, msaaSampleCount)) |
| { |
| - return adoptRef(new LayerRect(node, layerType, rect)); |
| + clear(); |
| } |
| - Node* layerRootNode() const { return m_layerRootNode.get(); } |
| - String layerType() const { return m_layerType; } |
| - ClientRect* layerRelativeRect() const { return m_rect.get(); } |
| - |
| -private: |
| - LayerRect(PassRefPtr<Node> node, const String& layerName, PassRefPtr<ClientRect> rect) |
| - : m_layerRootNode(node) |
| - , m_layerType(layerName) |
| - , m_rect(rect) |
| + virtual ~Canvas2DImageBufferSurface() |
| { |
| + if (m_layerBridge) |
| + m_layerBridge->destroy(); |
|
Stephen White
2013/12/09 15:33:08
Not new to this patch, but since this doesn't actu
|
| } |
| - RefPtr<Node> m_layerRootNode; |
| - String m_layerType; |
| - RefPtr<ClientRect> m_rect; |
| + // ImageBufferSurface implementation |
| + virtual void aboutToUse() OVERRIDE { m_layerBridge->aboutToUse(); } |
|
Stephen White
2013/12/09 15:33:08
Things like this are usually "willUse()" in Blink.
Justin Novosad
2013/12/09 16:37:31
Ah yes, 'aboutTo' is a skia-ism. Thanks.
|
| + virtual SkCanvas* canvas() const OVERRIDE { return m_layerBridge->canvas(); } |
| + virtual bool isValid() const OVERRIDE { return m_layerBridge && m_layerBridge->isValid(); } |
| + virtual blink::WebLayer* layer() const OVERRIDE { return m_layerBridge->layer(); } |
| + virtual Platform3DObject getBackingTexture() const OVERRIDE { return m_layerBridge->getBackingTexture(); } |
| + virtual bool isAccelerated() const { return m_layerBridge->isAccelerated(); } |
| + |
| +private: |
| + RefPtr<Canvas2DLayerBridge> m_layerBridge; |
| }; |
| -} // namespace WebCore |
| +} |
| #endif |