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

Side by Side Diff: third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp

Issue 1995733005: Fix 2D canvas state persistency after OffscreenCanvas.transferToImageBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 6 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" 5 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h"
6 6
7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC ontextOrWebGL2RenderingContext.h" 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC ontextOrWebGL2RenderingContext.h"
8 #include "core/frame/ImageBitmap.h" 8 #include "core/frame/ImageBitmap.h"
9 #include "platform/graphics/ImageBuffer.h" 9 #include "platform/graphics/ImageBuffer.h"
10 #include "platform/graphics/StaticBitmapImage.h" 10 #include "platform/graphics/StaticBitmapImage.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 { 66 {
67 return !!m_imageBuffer; 67 return !!m_imageBuffer;
68 } 68 }
69 69
70 ImageBuffer* OffscreenCanvasRenderingContext2D::imageBuffer() const 70 ImageBuffer* OffscreenCanvasRenderingContext2D::imageBuffer() const
71 { 71 {
72 if (!m_imageBuffer) { 72 if (!m_imageBuffer) {
73 // TODO: crbug.com/593514 Add support for GPU rendering 73 // TODO: crbug.com/593514 Add support for GPU rendering
74 OffscreenCanvasRenderingContext2D* nonConstThis = const_cast<OffscreenCa nvasRenderingContext2D*>(this); 74 OffscreenCanvasRenderingContext2D* nonConstThis = const_cast<OffscreenCa nvasRenderingContext2D*>(this);
75 nonConstThis->m_imageBuffer = ImageBuffer::create(IntSize(width(), heigh t()), m_hasAlpha ? NonOpaque : Opaque, InitializeImagePixels); 75 nonConstThis->m_imageBuffer = ImageBuffer::create(IntSize(width(), heigh t()), m_hasAlpha ? NonOpaque : Opaque, InitializeImagePixels);
76 // TODO: crbug.com/593349 Restore matrix and clip state on the new Image Buffer. 76
77 if (m_needsMatrixClipRestore) {
78 restoreMatrixClipStack(m_imageBuffer->canvas());
79 nonConstThis->m_needsMatrixClipRestore = false;
80 }
77 } 81 }
78 82
79 return m_imageBuffer.get(); 83 return m_imageBuffer.get();
80 } 84 }
81 85
82 ImageBitmap* OffscreenCanvasRenderingContext2D::transferToImageBitmap(ExceptionS tate& exceptionState) 86 ImageBitmap* OffscreenCanvasRenderingContext2D::transferToImageBitmap(ExceptionS tate& exceptionState)
83 { 87 {
84 if (!imageBuffer()) 88 if (!imageBuffer())
85 return nullptr; 89 return nullptr;
86 // TODO: crbug.com/593514 Add support for GPU rendering 90 // TODO: crbug.com/593514 Add support for GPU rendering
87 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera tion, SnapshotReasonUnknown); 91 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera tion, SnapshotReasonUnknown);
88 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( )); 92 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( ));
89 image->setOriginClean(this->originClean()); 93 image->setOriginClean(this->originClean());
90 m_imageBuffer.reset(); // "Transfer" means no retained buffer 94 m_imageBuffer.reset(); // "Transfer" means no retained buffer
95 m_needsMatrixClipRestore = true;
91 return ImageBitmap::create(image.release()); 96 return ImageBitmap::create(image.release());
92 } 97 }
93 98
94 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result) 99 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result)
95 { 100 {
96 result.setOffscreenCanvasRenderingContext2D(this); 101 result.setOffscreenCanvasRenderingContext2D(this);
97 } 102 }
98 103
99 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const 104 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const
100 { 105 {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 157 }
153 #endif 158 #endif
154 } 159 }
155 160
156 bool OffscreenCanvasRenderingContext2D::isContextLost() const 161 bool OffscreenCanvasRenderingContext2D::isContextLost() const
157 { 162 {
158 return false; 163 return false;
159 } 164 }
160 165
161 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698