OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 DCHECK(canCreateImageBuffer(size)); | 133 DCHECK(canCreateImageBuffer(size)); |
134 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size
.height()); | 134 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size
.height()); |
135 return StaticBitmapImage::create(fromSkSp(surface->makeImageSnapshot())); | 135 return StaticBitmapImage::create(fromSkSp(surface->makeImageSnapshot())); |
136 } | 136 } |
137 | 137 |
138 } // namespace | 138 } // namespace |
139 | 139 |
140 inline HTMLCanvasElement::HTMLCanvasElement(Document& document) | 140 inline HTMLCanvasElement::HTMLCanvasElement(Document& document) |
141 : HTMLElement(canvasTag, document) | 141 : HTMLElement(canvasTag, document) |
142 , ContextLifecycleObserver(&document) | 142 , ContextLifecycleObserver(&document) |
143 , PageLifecycleObserver(document.page()) | 143 , PageVisibilityObserver(document.page()) |
144 , m_size(DefaultWidth, DefaultHeight) | 144 , m_size(DefaultWidth, DefaultHeight) |
145 , m_ignoreReset(false) | 145 , m_ignoreReset(false) |
146 , m_externallyAllocatedMemory(0) | 146 , m_externallyAllocatedMemory(0) |
147 , m_originClean(true) | 147 , m_originClean(true) |
148 , m_didFailToCreateImageBuffer(false) | 148 , m_didFailToCreateImageBuffer(false) |
149 , m_imageBufferIsClear(false) | 149 , m_imageBufferIsClear(false) |
150 { | 150 { |
151 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::CanvasCreated); | 151 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::CanvasCreated); |
152 } | 152 } |
153 | 153 |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 { | 893 { |
894 if (m_context && m_context->is2d()) | 894 if (m_context && m_context->is2d()) |
895 m_context->loseContext(CanvasRenderingContext::RealLostContext); | 895 m_context->loseContext(CanvasRenderingContext::RealLostContext); |
896 } | 896 } |
897 | 897 |
898 DEFINE_TRACE(HTMLCanvasElement) | 898 DEFINE_TRACE(HTMLCanvasElement) |
899 { | 899 { |
900 visitor->trace(m_listeners); | 900 visitor->trace(m_listeners); |
901 visitor->trace(m_context); | 901 visitor->trace(m_context); |
902 ContextLifecycleObserver::trace(visitor); | 902 ContextLifecycleObserver::trace(visitor); |
903 PageLifecycleObserver::trace(visitor); | 903 PageVisibilityObserver::trace(visitor); |
904 HTMLElement::trace(visitor); | 904 HTMLElement::trace(visitor); |
905 } | 905 } |
906 | 906 |
907 DEFINE_TRACE_WRAPPERS(HTMLCanvasElement) | 907 DEFINE_TRACE_WRAPPERS(HTMLCanvasElement) |
908 { | 908 { |
909 visitor->traceWrappers(m_context); | 909 visitor->traceWrappers(m_context); |
910 HTMLElement::traceWrappers(visitor); | 910 HTMLElement::traceWrappers(visitor); |
911 } | 911 } |
912 | 912 |
913 void HTMLCanvasElement::updateExternallyAllocatedMemory() const | 913 void HTMLCanvasElement::updateExternallyAllocatedMemory() const |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 | 1048 |
1049 void HTMLCanvasElement::styleDidChange(const ComputedStyle* oldStyle, const Comp
utedStyle& newStyle) | 1049 void HTMLCanvasElement::styleDidChange(const ComputedStyle* oldStyle, const Comp
utedStyle& newStyle) |
1050 { | 1050 { |
1051 if (m_context) | 1051 if (m_context) |
1052 m_context->styleDidChange(oldStyle, newStyle); | 1052 m_context->styleDidChange(oldStyle, newStyle); |
1053 } | 1053 } |
1054 | 1054 |
1055 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument) | 1055 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument) |
1056 { | 1056 { |
1057 ContextLifecycleObserver::setContext(&document()); | 1057 ContextLifecycleObserver::setContext(&document()); |
1058 PageLifecycleObserver::setContext(document().page()); | 1058 PageVisibilityObserver::setContext(document().page()); |
1059 HTMLElement::didMoveToNewDocument(oldDocument); | 1059 HTMLElement::didMoveToNewDocument(oldDocument); |
1060 } | 1060 } |
1061 | 1061 |
1062 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(SourceImageStatus*
status, AccelerationHint hint, SnapshotReason reason, const FloatSize&) const | 1062 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(SourceImageStatus*
status, AccelerationHint hint, SnapshotReason reason, const FloatSize&) const |
1063 { | 1063 { |
1064 if (!width() || !height()) { | 1064 if (!width() || !height()) { |
1065 *status = ZeroSizeCanvasSourceImageStatus; | 1065 *status = ZeroSizeCanvasSourceImageStatus; |
1066 return nullptr; | 1066 return nullptr; |
1067 } | 1067 } |
1068 | 1068 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1194 |
1195 bool HTMLCanvasElement::createSurfaceLayer() | 1195 bool HTMLCanvasElement::createSurfaceLayer() |
1196 { | 1196 { |
1197 DCHECK(!m_surfaceLayerBridge); | 1197 DCHECK(!m_surfaceLayerBridge); |
1198 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); | 1198 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); |
1199 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); | 1199 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); |
1200 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); | 1200 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); |
1201 } | 1201 } |
1202 | 1202 |
1203 } // namespace blink | 1203 } // namespace blink |
OLD | NEW |