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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp

Issue 1919363002: Add createGradient and createPattern to OffscreenCanvas2D in worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ScriptState Created 4 years, 7 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/canvas2d/BaseRenderingContext2D.h" 5 #include "modules/canvas2d/BaseRenderingContext2D.h"
6 6
7 #include "bindings/core/v8/ExceptionMessages.h" 7 #include "bindings/core/v8/ExceptionMessages.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 9 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
10 #include "core/css/parser/CSSParser.h" 10 #include "core/css/parser/CSSParser.h"
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 1045
1046 if (imageSize.width() * imageSize.height() > width() * height() * ExpensiveC anvasHeuristicParameters::ExpensiveImageSizeRatio) 1046 if (imageSize.width() * imageSize.height() > width() * height() * ExpensiveC anvasHeuristicParameters::ExpensiveImageSizeRatio)
1047 isExpensive = true; 1047 isExpensive = true;
1048 1048
1049 if (isExpensive) { 1049 if (isExpensive) {
1050 ImageBuffer* buffer = imageBuffer(); 1050 ImageBuffer* buffer = imageBuffer();
1051 if (buffer) 1051 if (buffer)
1052 buffer->setHasExpensiveOp(); 1052 buffer->setHasExpensiveOp();
1053 } 1053 }
1054 1054
1055 if (originClean() && wouldTaintOrigin(imageSource)) 1055 if (originClean() && wouldTaintOrigin(imageSource, nullptr))
Justin Novosad 2016/04/27 19:32:25 why no scriptState here? I realize you have not ye
xlai (Olivia) 2016/04/27 19:47:49 The call here does not invoke OCRC2D::wouldTaintOr
1056 setOriginTainted(); 1056 setOriginTainted();
1057 } 1057 }
1058 1058
1059 void BaseRenderingContext2D::clearCanvas() 1059 void BaseRenderingContext2D::clearCanvas()
1060 { 1060 {
1061 FloatRect canvasRect(0, 0, width(), height()); 1061 FloatRect canvasRect(0, 0, width(), height());
1062 checkOverdraw(canvasRect, 0, CanvasRenderingContext2DState::NoImage, ClipFil l); 1062 checkOverdraw(canvasRect, 0, CanvasRenderingContext2DState::NoImage, ClipFil l);
1063 SkCanvas* c = drawingCanvas(); 1063 SkCanvas* c = drawingCanvas();
1064 if (c) 1064 if (c)
1065 c->clear(hasAlpha() ? SK_ColorTRANSPARENT : SK_ColorBLACK); 1065 c->clear(hasAlpha() ? SK_ColorTRANSPARENT : SK_ColorBLACK);
(...skipping 16 matching lines...) Expand all
1082 { 1082 {
1083 if (r0 < 0 || r1 < 0) { 1083 if (r0 < 0 || r1 < 0) {
1084 exceptionState.throwDOMException(IndexSizeError, String::format("The %s provided is less than 0.", r0 < 0 ? "r0" : "r1")); 1084 exceptionState.throwDOMException(IndexSizeError, String::format("The %s provided is less than 0.", r0 < 0 ? "r0" : "r1"));
1085 return nullptr; 1085 return nullptr;
1086 } 1086 }
1087 1087
1088 CanvasGradient* gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, Fl oatPoint(x1, y1), r1); 1088 CanvasGradient* gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, Fl oatPoint(x1, y1), r1);
1089 return gradient; 1089 return gradient;
1090 } 1090 }
1091 1091
1092 CanvasPattern* BaseRenderingContext2D::createPattern(const CanvasImageSourceUnio n& imageSource, const String& repetitionType, ExceptionState& exceptionState) 1092 CanvasPattern* BaseRenderingContext2D::createPattern(ScriptState* scriptState, c onst CanvasImageSourceUnion& imageSource, const String& repetitionType, Exceptio nState& exceptionState)
1093 { 1093 {
1094 Pattern::RepeatMode repeatMode = CanvasPattern::parseRepetitionType(repetiti onType, exceptionState); 1094 Pattern::RepeatMode repeatMode = CanvasPattern::parseRepetitionType(repetiti onType, exceptionState);
1095 if (exceptionState.hadException()) 1095 if (exceptionState.hadException())
1096 return nullptr; 1096 return nullptr;
1097 1097
1098 SourceImageStatus status; 1098 SourceImageStatus status;
1099 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource, exceptionState); 1099 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource, exceptionState);
1100 if (!imageSourceInternal) 1100 if (!imageSourceInternal)
1101 return nullptr; 1101 return nullptr;
1102 FloatSize defaultObjectSize(width(), height()); 1102 FloatSize defaultObjectSize(width(), height());
(...skipping 12 matching lines...) Expand all
1115 imageForRendering = Image::nullImage(); 1115 imageForRendering = Image::nullImage();
1116 break; 1116 break;
1117 case IncompleteSourceImageStatus: 1117 case IncompleteSourceImageStatus:
1118 return nullptr; 1118 return nullptr;
1119 default: 1119 default:
1120 ASSERT_NOT_REACHED(); 1120 ASSERT_NOT_REACHED();
1121 return nullptr; 1121 return nullptr;
1122 } 1122 }
1123 ASSERT(imageForRendering); 1123 ASSERT(imageForRendering);
1124 1124
1125 bool originClean = !wouldTaintOrigin(imageSourceInternal); 1125 bool originClean = !wouldTaintOrigin(imageSourceInternal, scriptState);
1126 1126
1127 return CanvasPattern::create(imageForRendering.release(), repeatMode, origin Clean); 1127 return CanvasPattern::create(imageForRendering.release(), repeatMode, origin Clean);
1128 } 1128 }
1129 1129
1130 bool BaseRenderingContext2D::computeDirtyRect(const FloatRect& localRect, SkIRec t* dirtyRect) 1130 bool BaseRenderingContext2D::computeDirtyRect(const FloatRect& localRect, SkIRec t* dirtyRect)
1131 { 1131 {
1132 SkIRect clipBounds; 1132 SkIRect clipBounds;
1133 if (!drawingCanvas()->getClipDeviceBounds(&clipBounds)) 1133 if (!drawingCanvas()->getClipDeviceBounds(&clipBounds))
1134 return false; 1134 return false;
1135 return computeDirtyRect(localRect, clipBounds, dirtyRect); 1135 return computeDirtyRect(localRect, clipBounds, dirtyRect);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1386
1387 imageBuffer()->willOverwriteCanvas(); 1387 imageBuffer()->willOverwriteCanvas();
1388 } 1388 }
1389 1389
1390 DEFINE_TRACE(BaseRenderingContext2D) 1390 DEFINE_TRACE(BaseRenderingContext2D)
1391 { 1391 {
1392 visitor->trace(m_stateStack); 1392 visitor->trace(m_stateStack);
1393 } 1393 }
1394 1394
1395 } // namespace blink 1395 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698