Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp

Issue 2508943003: Make OffscreenCanvas resizeable (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
index e183a7ebaa16e4212c2a94e538ff12822c5e405c..14c524d91f9be4f433d01d6610217d1043d0a07c 100644
--- a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
@@ -108,6 +108,37 @@ void BaseRenderingContext2D::restoreMatrixClipStack(SkCanvas* c) const {
validateStateStack();
}
+void BaseRenderingContext2D::unwindStateStack() {
Justin Novosad 2016/11/16 22:58:18 code moved from CanvasRenderingContext2D.cpp
+ if (size_t stackSize = m_stateStack.size()) {
+ if (SkCanvas* skCanvas = existingDrawingCanvas()) {
+ while (--stackSize)
+ skCanvas->restore();
+ }
+ }
+}
+
+void BaseRenderingContext2D::reset() {
+ validateStateStack();
+ unwindStateStack();
+ m_stateStack.resize(1);
+ m_stateStack.first() = CanvasRenderingContext2DState::create();
+ m_path.clear();
+ if (SkCanvas* c = existingDrawingCanvas()) {
+ // The canvas should always have an initial/unbalanced save frame, which
+ // we use to reset the top level matrix and clip here.
+ DCHECK_EQ(c->getSaveCount(), 2);
+ c->restore();
+ c->save();
+ DCHECK(c->getTotalMatrix().isIdentity());
+#if DCHECK_IS_ON()
+ SkIRect clipBounds;
+ DCHECK(c->getClipDeviceBounds(&clipBounds));
+ DCHECK(clipBounds == c->imageInfo().bounds());
+#endif
+ }
+ validateStateStack();
+}
+
static inline void convertCanvasStyleToUnionType(
CanvasStyle* style,
StringOrCanvasGradientOrCanvasPattern& returnValue) {

Powered by Google App Engine
This is Rietveld 408576698