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

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

Issue 2212163002: Add some plumbing for the color management of canvases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 4 years, 3 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 "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/workers/WorkerGlobalScope.h" 10 #include "core/workers/WorkerGlobalScope.h"
11 #include "core/workers/WorkerSettings.h" 11 #include "core/workers/WorkerSettings.h"
12 #include "platform/graphics/ImageBuffer.h" 12 #include "platform/graphics/ImageBuffer.h"
13 #include "platform/graphics/StaticBitmapImage.h" 13 #include "platform/graphics/StaticBitmapImage.h"
14 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 14 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
15 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" 15 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
16 #include "wtf/Assertions.h" 16 #include "wtf/Assertions.h"
17 17
18 #define UNIMPLEMENTED ASSERT_NOT_REACHED 18 #define UNIMPLEMENTED ASSERT_NOT_REACHED
19 19
20 namespace blink { 20 namespace blink {
21 21
22 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() 22 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D()
23 { 23 {
24 } 24 }
25 25
26 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D(ScriptState * scriptState, OffscreenCanvas* canvas, const CanvasContextCreationAttributes& a ttrs) 26 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D(ScriptState * scriptState, OffscreenCanvas* canvas, const CanvasContextCreationAttributes& a ttrs)
27 : CanvasRenderingContext(nullptr, canvas) 27 : CanvasRenderingContext(nullptr, canvas, attrs)
28 , m_hasAlpha(attrs.alpha())
29 { 28 {
30 ExecutionContext* executionContext = scriptState->getExecutionContext(); 29 ExecutionContext* executionContext = scriptState->getExecutionContext();
31 if (executionContext->isDocument()) { 30 if (executionContext->isDocument()) {
32 if (toDocument(executionContext)->settings()->disableReadingFromCanvas() ) 31 if (toDocument(executionContext)->settings()->disableReadingFromCanvas() )
33 canvas->setDisableReadingFromCanvasTrue(); 32 canvas->setDisableReadingFromCanvasTrue();
34 return; 33 return;
35 } 34 }
36 35
37 WorkerSettings* workerSettings = toWorkerGlobalScope(executionContext)->work erSettings(); 36 WorkerSettings* workerSettings = toWorkerGlobalScope(executionContext)->work erSettings();
38 if (workerSettings && workerSettings->disableReadingFromCanvas()) 37 if (workerSettings && workerSettings->disableReadingFromCanvas())
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 { 85 {
87 if (!isMainThread()) 86 if (!isMainThread())
88 return false; // Add support on Workers crbug.com/ 87 return false; // Add support on Workers crbug.com/
89 return RuntimeEnabledFeatures::accelerated2dCanvasEnabled(); 88 return RuntimeEnabledFeatures::accelerated2dCanvasEnabled();
90 } 89 }
91 90
92 ImageBuffer* OffscreenCanvasRenderingContext2D::imageBuffer() const 91 ImageBuffer* OffscreenCanvasRenderingContext2D::imageBuffer() const
93 { 92 {
94 if (!m_imageBuffer) { 93 if (!m_imageBuffer) {
95 IntSize surfaceSize(width(), height()); 94 IntSize surfaceSize(width(), height());
96 OpacityMode opacityMode = m_hasAlpha ? NonOpaque : Opaque; 95 OpacityMode opacityMode = hasAlpha() ? NonOpaque : Opaque;
97 std::unique_ptr<ImageBufferSurface> surface; 96 std::unique_ptr<ImageBufferSurface> surface;
98 if (shouldAccelerate(surfaceSize)) { 97 if (shouldAccelerate(surfaceSize)) {
99 surface.reset(new AcceleratedImageBufferSurface(surfaceSize, opacity Mode)); 98 surface.reset(new AcceleratedImageBufferSurface(surfaceSize, opacity Mode));
100 } 99 }
101 100
102 if (!surface || !surface->isValid()) { 101 if (!surface || !surface->isValid()) {
103 surface.reset(new UnacceleratedImageBufferSurface(surfaceSize, opaci tyMode, InitializeImagePixels)); 102 surface.reset(new UnacceleratedImageBufferSurface(surfaceSize, opaci tyMode, InitializeImagePixels));
104 } 103 }
105 104
106 OffscreenCanvasRenderingContext2D* nonConstThis = const_cast<OffscreenCa nvasRenderingContext2D*>(this); 105 OffscreenCanvasRenderingContext2D* nonConstThis = const_cast<OffscreenCa nvasRenderingContext2D*>(this);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 bool OffscreenCanvasRenderingContext2D::isContextLost() const 192 bool OffscreenCanvasRenderingContext2D::isContextLost() const
194 { 193 {
195 return false; 194 return false;
196 } 195 }
197 196
198 bool OffscreenCanvasRenderingContext2D::isPaintable() const 197 bool OffscreenCanvasRenderingContext2D::isPaintable() const
199 { 198 {
200 return this->imageBuffer(); 199 return this->imageBuffer();
201 } 200 }
202 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698