| OLD | NEW |
| 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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 return false; | 997 return false; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 void BaseRenderingContext2D::drawImage(ExecutionContext* executionContext, Canva
sImageSource* imageSource, | 1000 void BaseRenderingContext2D::drawImage(ExecutionContext* executionContext, Canva
sImageSource* imageSource, |
| 1001 double sx, double sy, double sw, double sh, | 1001 double sx, double sy, double sw, double sh, |
| 1002 double dx, double dy, double dw, double dh, ExceptionState& exceptionState) | 1002 double dx, double dy, double dw, double dh, ExceptionState& exceptionState) |
| 1003 { | 1003 { |
| 1004 if (!drawingCanvas()) | 1004 if (!drawingCanvas()) |
| 1005 return; | 1005 return; |
| 1006 | 1006 |
| 1007 RefPtr<Image> image; |
| 1008 FloatSize defaultObjectSize(width(), height()); |
| 1009 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; |
| 1010 if (!imageSource->isVideoElement()) { |
| 1011 AccelerationHint hint = imageBuffer()->isAccelerated() ? PreferAccelerat
ion : PreferNoAcceleration; |
| 1012 image = imageSource->getSourceImageForCanvas(&sourceImageStatus, hint, S
napshotReasonDrawImage, defaultObjectSize); |
| 1013 if (sourceImageStatus == UndecodableSourceImageStatus) |
| 1014 exceptionState.throwDOMException(InvalidStateError, "The HTMLImageEl
ement provided is in the 'broken' state."); |
| 1015 if (!image || !image->width() || !image->height()) |
| 1016 return; |
| 1017 } else { |
| 1018 if (!static_cast<HTMLVideoElement*>(imageSource)->hasAvailableVideoFrame
()) |
| 1019 return; |
| 1020 } |
| 1021 |
| 1022 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dw) || !std::
isfinite(dh) |
| 1023 || !std::isfinite(sx) || !std::isfinite(sy) || !std::isfinite(sw) || !st
d::isfinite(sh) |
| 1024 || !dw || !dh || !sw || !sh) |
| 1025 return; |
| 1026 |
| 1027 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh)); |
| 1028 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh)); |
| 1029 FloatSize imageSize = imageSource->elementSize(defaultObjectSize); |
| 1030 |
| 1031 clipRectsToImageRect(FloatRect(FloatPoint(), imageSize), &srcRect, &dstRect)
; |
| 1032 |
| 1033 imageSource->adjustDrawRects(&srcRect, &dstRect); |
| 1034 |
| 1035 if (srcRect.isEmpty()) |
| 1036 return; |
| 1037 |
| 1038 DisableDeferralReason reason = DisableDeferralReasonUnknown; |
| 1039 if (shouldDisableDeferral(imageSource, &reason) || image->isTextureBacked()) |
| 1040 disableDeferral(reason); |
| 1041 |
| 1042 validateStateStack(); |
| 1043 |
| 1007 // TODO(xidachen): After collecting some data, come back and prune off | 1044 // TODO(xidachen): After collecting some data, come back and prune off |
| 1008 // the ones that is not needed. | 1045 // the ones that is not needed. |
| 1009 Optional<ScopedUsHistogramTimer> timer; | 1046 Optional<ScopedUsHistogramTimer> timer; |
| 1010 if (imageBuffer() && imageBuffer()->isAccelerated()) { | 1047 if (imageBuffer() && imageBuffer()->isAccelerated()) { |
| 1011 if (imageSource->isVideoElement()) { | 1048 if (imageSource->isVideoElement()) { |
| 1012 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rVideoGPU, new CustomCountHistogram("Blink.Canvas.DrawImage.Video.GPU", 0, 10000
000, 50)); | 1049 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rVideoGPU, new CustomCountHistogram("Blink.Canvas.DrawImage.Video.GPU", 0, 10000
000, 50)); |
| 1013 timer.emplace(scopedUsCounterVideoGPU); | 1050 timer.emplace(scopedUsCounterVideoGPU); |
| 1014 } else if (imageSource->isCanvasElement()) { | 1051 } else if (imageSource->isCanvasElement()) { |
| 1015 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rCanvasGPU, new CustomCountHistogram("Blink.Canvas.DrawImage.Canvas.GPU", 0, 100
00000, 50)); | 1052 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rCanvasGPU, new CustomCountHistogram("Blink.Canvas.DrawImage.Canvas.GPU", 0, 100
00000, 50)); |
| 1016 timer.emplace(scopedUsCounterCanvasGPU); | 1053 timer.emplace(scopedUsCounterCanvasGPU); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 timer.emplace(scopedUsCounterSVGCPU); | 1090 timer.emplace(scopedUsCounterSVGCPU); |
| 1054 } else if (imageSource->isImageBitmap()) { | 1091 } else if (imageSource->isImageBitmap()) { |
| 1055 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rImageBitmapCPU, new CustomCountHistogram("Blink.Canvas.DrawImage.ImageBitmap.CP
U", 0, 10000000, 50)); | 1092 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rImageBitmapCPU, new CustomCountHistogram("Blink.Canvas.DrawImage.ImageBitmap.CP
U", 0, 10000000, 50)); |
| 1056 timer.emplace(scopedUsCounterImageBitmapCPU); | 1093 timer.emplace(scopedUsCounterImageBitmapCPU); |
| 1057 } else { | 1094 } else { |
| 1058 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rOthersCPU, new CustomCountHistogram("Blink.Canvas.DrawImage.Others.CPU", 0, 100
00000, 50)); | 1095 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounte
rOthersCPU, new CustomCountHistogram("Blink.Canvas.DrawImage.Others.CPU", 0, 100
00000, 50)); |
| 1059 timer.emplace(scopedUsCounterOthersCPU); | 1096 timer.emplace(scopedUsCounterOthersCPU); |
| 1060 } | 1097 } |
| 1061 } | 1098 } |
| 1062 | 1099 |
| 1063 RefPtr<Image> image; | |
| 1064 FloatSize defaultObjectSize(width(), height()); | |
| 1065 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; | |
| 1066 if (!imageSource->isVideoElement()) { | |
| 1067 AccelerationHint hint = imageBuffer()->isAccelerated() ? PreferAccelerat
ion : PreferNoAcceleration; | |
| 1068 image = imageSource->getSourceImageForCanvas(&sourceImageStatus, hint, S
napshotReasonDrawImage, defaultObjectSize); | |
| 1069 if (sourceImageStatus == UndecodableSourceImageStatus) | |
| 1070 exceptionState.throwDOMException(InvalidStateError, "The HTMLImageEl
ement provided is in the 'broken' state."); | |
| 1071 if (!image || !image->width() || !image->height()) | |
| 1072 return; | |
| 1073 } else { | |
| 1074 if (!static_cast<HTMLVideoElement*>(imageSource)->hasAvailableVideoFrame
()) | |
| 1075 return; | |
| 1076 } | |
| 1077 | |
| 1078 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dw) || !std::
isfinite(dh) | |
| 1079 || !std::isfinite(sx) || !std::isfinite(sy) || !std::isfinite(sw) || !st
d::isfinite(sh) | |
| 1080 || !dw || !dh || !sw || !sh) | |
| 1081 return; | |
| 1082 | |
| 1083 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh)); | |
| 1084 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh)); | |
| 1085 FloatSize imageSize = imageSource->elementSize(defaultObjectSize); | |
| 1086 | |
| 1087 clipRectsToImageRect(FloatRect(FloatPoint(), imageSize), &srcRect, &dstRect)
; | |
| 1088 | |
| 1089 imageSource->adjustDrawRects(&srcRect, &dstRect); | |
| 1090 | |
| 1091 if (srcRect.isEmpty()) | |
| 1092 return; | |
| 1093 | |
| 1094 DisableDeferralReason reason = DisableDeferralReasonUnknown; | |
| 1095 if (shouldDisableDeferral(imageSource, &reason) || image->isTextureBacked()) | |
| 1096 disableDeferral(reason); | |
| 1097 | |
| 1098 validateStateStack(); | |
| 1099 | |
| 1100 draw( | 1100 draw( |
| 1101 [this, &imageSource, &image, &srcRect, dstRect](SkCanvas* c, const SkPai
nt* paint) // draw lambda | 1101 [this, &imageSource, &image, &srcRect, dstRect](SkCanvas* c, const SkPai
nt* paint) // draw lambda |
| 1102 { | 1102 { |
| 1103 drawImageInternal(c, imageSource, image.get(), srcRect, dstRect, pai
nt); | 1103 drawImageInternal(c, imageSource, image.get(), srcRect, dstRect, pai
nt); |
| 1104 }, | 1104 }, |
| 1105 [this, &dstRect](const SkIRect& clipBounds) // overdraw test lambda | 1105 [this, &dstRect](const SkIRect& clipBounds) // overdraw test lambda |
| 1106 { | 1106 { |
| 1107 return rectContainsTransformedRect(dstRect, clipBounds); | 1107 return rectContainsTransformedRect(dstRect, clipBounds); |
| 1108 }, dstRect, CanvasRenderingContext2DState::ImagePaintType, | 1108 }, dstRect, CanvasRenderingContext2DState::ImagePaintType, |
| 1109 imageSource->isOpaque() ? CanvasRenderingContext2DState::OpaqueImage : C
anvasRenderingContext2DState::NonOpaqueImage); | 1109 imageSource->isOpaque() ? CanvasRenderingContext2DState::OpaqueImage : C
anvasRenderingContext2DState::NonOpaqueImage); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 size.setHeight(1); | 1255 size.setHeight(1); |
| 1256 | 1256 |
| 1257 ImageData* result = ImageData::create(size); | 1257 ImageData* result = ImageData::create(size); |
| 1258 if (!result) | 1258 if (!result) |
| 1259 exceptionState.throwRangeError("Out of memory at ImageData creation"); | 1259 exceptionState.throwRangeError("Out of memory at ImageData creation"); |
| 1260 return result; | 1260 return result; |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 ImageData* BaseRenderingContext2D::getImageData(double sx, double sy, double sw,
double sh, ExceptionState& exceptionState) const | 1263 ImageData* BaseRenderingContext2D::getImageData(double sx, double sy, double sw,
double sh, ExceptionState& exceptionState) const |
| 1264 { | 1264 { |
| 1265 Optional<ScopedUsHistogramTimer> timer; | |
| 1266 if (imageBuffer() && imageBuffer()->isAccelerated()) { | |
| 1267 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU
, new CustomCountHistogram("Blink.Canvas.GetImageData.GPU", 0, 10000000, 50)); | |
| 1268 timer.emplace(scopedUsCounterGPU); | |
| 1269 } else if (imageBuffer() && imageBuffer()->isRecording()) { | |
| 1270 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDis
playList, new CustomCountHistogram("Blink.Canvas.GetImageData.DisplayList", 0, 1
0000000, 50)); | |
| 1271 timer.emplace(scopedUsCounterDisplayList); | |
| 1272 } else { | |
| 1273 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCPU
, new CustomCountHistogram("Blink.Canvas.GetImageData.CPU", 0, 10000000, 50)); | |
| 1274 timer.emplace(scopedUsCounterCPU); | |
| 1275 } | |
| 1276 | |
| 1277 if (!originClean()) | 1265 if (!originClean()) |
| 1278 exceptionState.throwSecurityError("The canvas has been tainted by cross-
origin data."); | 1266 exceptionState.throwSecurityError("The canvas has been tainted by cross-
origin data."); |
| 1279 else if (!sw || !sh) | 1267 else if (!sw || !sh) |
| 1280 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s is 0.", sw ? "height" : "width")); | 1268 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s is 0.", sw ? "height" : "width")); |
| 1281 | 1269 |
| 1282 if (exceptionState.hadException()) | 1270 if (exceptionState.hadException()) |
| 1283 return nullptr; | 1271 return nullptr; |
| 1284 | 1272 |
| 1285 if (sw < 0) { | 1273 if (sw < 0) { |
| 1286 sx += sw; | 1274 sx += sw; |
| 1287 sw = -sw; | 1275 sw = -sw; |
| 1288 } | 1276 } |
| 1289 if (sh < 0) { | 1277 if (sh < 0) { |
| 1290 sy += sh; | 1278 sy += sh; |
| 1291 sh = -sh; | 1279 sh = -sh; |
| 1292 } | 1280 } |
| 1293 | 1281 |
| 1294 FloatRect logicalRect(sx, sy, sw, sh); | 1282 FloatRect logicalRect(sx, sy, sw, sh); |
| 1295 if (logicalRect.width() < 1) | 1283 if (logicalRect.width() < 1) |
| 1296 logicalRect.setWidth(1); | 1284 logicalRect.setWidth(1); |
| 1297 if (logicalRect.height() < 1) | 1285 if (logicalRect.height() < 1) |
| 1298 logicalRect.setHeight(1); | 1286 logicalRect.setHeight(1); |
| 1299 if (!logicalRect.isExpressibleAsIntRect()) | 1287 if (!logicalRect.isExpressibleAsIntRect()) |
| 1300 return nullptr; | 1288 return nullptr; |
| 1301 | 1289 |
| 1290 Optional<ScopedUsHistogramTimer> timer; |
| 1291 if (imageBuffer() && imageBuffer()->isAccelerated()) { |
| 1292 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU
, new CustomCountHistogram("Blink.Canvas.GetImageData.GPU", 0, 10000000, 50)); |
| 1293 timer.emplace(scopedUsCounterGPU); |
| 1294 } else if (imageBuffer() && imageBuffer()->isRecording()) { |
| 1295 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDis
playList, new CustomCountHistogram("Blink.Canvas.GetImageData.DisplayList", 0, 1
0000000, 50)); |
| 1296 timer.emplace(scopedUsCounterDisplayList); |
| 1297 } else { |
| 1298 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCPU
, new CustomCountHistogram("Blink.Canvas.GetImageData.CPU", 0, 10000000, 50)); |
| 1299 timer.emplace(scopedUsCounterCPU); |
| 1300 } |
| 1301 |
| 1302 IntRect imageDataRect = enclosingIntRect(logicalRect); | 1302 IntRect imageDataRect = enclosingIntRect(logicalRect); |
| 1303 ImageBuffer* buffer = imageBuffer(); | 1303 ImageBuffer* buffer = imageBuffer(); |
| 1304 if (!buffer || isContextLost()) { | 1304 if (!buffer || isContextLost()) { |
| 1305 ImageData* result = ImageData::create(imageDataRect.size()); | 1305 ImageData* result = ImageData::create(imageDataRect.size()); |
| 1306 if (!result) | 1306 if (!result) |
| 1307 exceptionState.throwRangeError("Out of memory at ImageData creation"
); | 1307 exceptionState.throwRangeError("Out of memory at ImageData creation"
); |
| 1308 return result; | 1308 return result; |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 WTF::ArrayBufferContents contents; | 1311 WTF::ArrayBufferContents contents; |
| 1312 if (!buffer->getImageData(Unmultiplied, imageDataRect, contents)) { | 1312 if (!buffer->getImageData(Unmultiplied, imageDataRect, contents)) { |
| 1313 exceptionState.throwRangeError("Out of memory at ImageData creation"); | 1313 exceptionState.throwRangeError("Out of memory at ImageData creation"); |
| 1314 return nullptr; | 1314 return nullptr; |
| 1315 } | 1315 } |
| 1316 | 1316 |
| 1317 DOMArrayBuffer* arrayBuffer = DOMArrayBuffer::create(contents); | 1317 DOMArrayBuffer* arrayBuffer = DOMArrayBuffer::create(contents); |
| 1318 return ImageData::create( | 1318 return ImageData::create( |
| 1319 imageDataRect.size(), | 1319 imageDataRect.size(), |
| 1320 DOMUint8ClampedArray::create(arrayBuffer, 0, arrayBuffer->byteLength()))
; | 1320 DOMUint8ClampedArray::create(arrayBuffer, 0, arrayBuffer->byteLength()))
; |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 void BaseRenderingContext2D::putImageData(ImageData* data, double dx, double dy,
ExceptionState& exceptionState) | 1323 void BaseRenderingContext2D::putImageData(ImageData* data, double dx, double dy,
ExceptionState& exceptionState) |
| 1324 { | 1324 { |
| 1325 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), exceptionSta
te); | 1325 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), exceptionSta
te); |
| 1326 } | 1326 } |
| 1327 | 1327 |
| 1328 void BaseRenderingContext2D::putImageData(ImageData* data, double dx, double dy,
double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight, ExceptionS
tate& exceptionState) | 1328 void BaseRenderingContext2D::putImageData(ImageData* data, double dx, double dy,
double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight, ExceptionS
tate& exceptionState) |
| 1329 { | 1329 { |
| 1330 Optional<ScopedUsHistogramTimer> timer; | |
| 1331 if (imageBuffer() && imageBuffer()->isAccelerated()) { | |
| 1332 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU
, new CustomCountHistogram("Blink.Canvas.PutImageData.GPU", 0, 10000000, 50)); | |
| 1333 timer.emplace(scopedUsCounterGPU); | |
| 1334 } else if (imageBuffer() && imageBuffer()->isRecording()) { | |
| 1335 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDis
playList, new CustomCountHistogram("Blink.Canvas.PutImageData.DisplayList", 0, 1
0000000, 50)); | |
| 1336 timer.emplace(scopedUsCounterDisplayList); | |
| 1337 } else { | |
| 1338 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCPU
, new CustomCountHistogram("Blink.Canvas.PutImageData.CPU", 0, 10000000, 50)); | |
| 1339 timer.emplace(scopedUsCounterCPU); | |
| 1340 } | |
| 1341 | |
| 1342 if (data->data()->bufferBase()->isNeutered()) { | 1330 if (data->data()->bufferBase()->isNeutered()) { |
| 1343 exceptionState.throwDOMException(InvalidStateError, "The source data has
been neutered."); | 1331 exceptionState.throwDOMException(InvalidStateError, "The source data has
been neutered."); |
| 1344 return; | 1332 return; |
| 1345 } | 1333 } |
| 1346 ImageBuffer* buffer = imageBuffer(); | 1334 ImageBuffer* buffer = imageBuffer(); |
| 1347 if (!buffer) | 1335 if (!buffer) |
| 1348 return; | 1336 return; |
| 1349 | 1337 |
| 1350 if (dirtyWidth < 0) { | 1338 if (dirtyWidth < 0) { |
| 1351 dirtyX += dirtyWidth; | 1339 dirtyX += dirtyWidth; |
| 1352 dirtyWidth = -dirtyWidth; | 1340 dirtyWidth = -dirtyWidth; |
| 1353 } | 1341 } |
| 1354 | 1342 |
| 1355 if (dirtyHeight < 0) { | 1343 if (dirtyHeight < 0) { |
| 1356 dirtyY += dirtyHeight; | 1344 dirtyY += dirtyHeight; |
| 1357 dirtyHeight = -dirtyHeight; | 1345 dirtyHeight = -dirtyHeight; |
| 1358 } | 1346 } |
| 1359 | 1347 |
| 1360 FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight); | 1348 FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight); |
| 1361 clipRect.intersect(IntRect(0, 0, data->width(), data->height())); | 1349 clipRect.intersect(IntRect(0, 0, data->width(), data->height())); |
| 1362 IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy)); | 1350 IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy)); |
| 1363 IntRect destRect = enclosingIntRect(clipRect); | 1351 IntRect destRect = enclosingIntRect(clipRect); |
| 1364 destRect.move(destOffset); | 1352 destRect.move(destOffset); |
| 1365 destRect.intersect(IntRect(IntPoint(), buffer->size())); | 1353 destRect.intersect(IntRect(IntPoint(), buffer->size())); |
| 1366 if (destRect.isEmpty()) | 1354 if (destRect.isEmpty()) |
| 1367 return; | 1355 return; |
| 1356 |
| 1357 Optional<ScopedUsHistogramTimer> timer; |
| 1358 if (imageBuffer() && imageBuffer()->isAccelerated()) { |
| 1359 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU
, new CustomCountHistogram("Blink.Canvas.PutImageData.GPU", 0, 10000000, 50)); |
| 1360 timer.emplace(scopedUsCounterGPU); |
| 1361 } else if (imageBuffer() && imageBuffer()->isRecording()) { |
| 1362 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDis
playList, new CustomCountHistogram("Blink.Canvas.PutImageData.DisplayList", 0, 1
0000000, 50)); |
| 1363 timer.emplace(scopedUsCounterDisplayList); |
| 1364 } else { |
| 1365 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCPU
, new CustomCountHistogram("Blink.Canvas.PutImageData.CPU", 0, 10000000, 50)); |
| 1366 timer.emplace(scopedUsCounterCPU); |
| 1367 } |
| 1368 |
| 1368 IntRect sourceRect(destRect); | 1369 IntRect sourceRect(destRect); |
| 1369 sourceRect.move(-destOffset); | 1370 sourceRect.move(-destOffset); |
| 1370 | 1371 |
| 1371 checkOverdraw(destRect, 0, CanvasRenderingContext2DState::NoImage, Untransfo
rmedUnclippedFill); | 1372 checkOverdraw(destRect, 0, CanvasRenderingContext2DState::NoImage, Untransfo
rmedUnclippedFill); |
| 1372 | 1373 |
| 1373 buffer->putByteArray(Unmultiplied, data->data()->data(), IntSize(data->width
(), data->height()), sourceRect, IntPoint(destOffset)); | 1374 buffer->putByteArray(Unmultiplied, data->data()->data(), IntSize(data->width
(), data->height()), sourceRect, IntPoint(destOffset)); |
| 1374 | 1375 |
| 1375 didDraw(destRect); | 1376 didDraw(destRect); |
| 1376 } | 1377 } |
| 1377 | 1378 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 | 1483 |
| 1483 imageBuffer()->willOverwriteCanvas(); | 1484 imageBuffer()->willOverwriteCanvas(); |
| 1484 } | 1485 } |
| 1485 | 1486 |
| 1486 DEFINE_TRACE(BaseRenderingContext2D) | 1487 DEFINE_TRACE(BaseRenderingContext2D) |
| 1487 { | 1488 { |
| 1488 visitor->trace(m_stateStack); | 1489 visitor->trace(m_stateStack); |
| 1489 } | 1490 } |
| 1490 | 1491 |
| 1491 } // namespace blink | 1492 } // namespace blink |
| OLD | NEW |