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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 1992253002: Adding performance tracking for canvas API calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 597
598 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToDataURL ); 598 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToDataURL );
599 599
600 ImageData* imageData = toImageData(sourceBuffer, SnapshotReasonToDataURL); 600 ImageData* imageData = toImageData(sourceBuffer, SnapshotReasonToDataURL);
601 601
602 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU RL(encodingMimeType, quality); 602 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU RL(encodingMimeType, quality);
603 } 603 }
604 604
605 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q ualityArgument, ExceptionState& exceptionState) const 605 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q ualityArgument, ExceptionState& exceptionState) const
606 { 606 {
607 Optional<ScopedUsHistogramTimer> timer;
608 if (m_imageBuffer && m_imageBuffer->isAccelerated()) {
609 DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU, ("Blink.Ca nvas.ToDataURL.GPU", 0, 10000000, 50));
Justin Novosad 2016/05/19 15:28:40 You are missing entries in histograms.xml
610 timer.emplace(scopedUsCounterGPU);
611 } else if (m_imageBuffer && m_imageBuffer->isRecording()) {
612 DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDL, ("Blink.Can vas.ToDataURL.DL", 0, 10000000, 50));
Justin Novosad 2016/05/19 15:28:39 DL -> DisplayList
xidachen 2016/05/20 12:36:54 Changed in all places.
613 timer.emplace(scopedUsCounterDL);
614 } else {
615 DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSW, ("Blink.Can vas.ToDataURL.SW", 0, 10000000, 50));
Justin Novosad 2016/05/19 15:28:40 SW -> CPU
xidachen 2016/05/20 12:36:54 Changed in all places.
616 timer.emplace(scopedUsCounterSW);
617 }
618
607 if (!originClean()) { 619 if (!originClean()) {
608 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); 620 exceptionState.throwSecurityError("Tainted canvases may not be exported. ");
Justin Novosad 2016/05/19 15:36:55 We should start the measurement after this early e
xidachen 2016/05/20 12:36:54 Done.
609 return String(); 621 return String();
610 } 622 }
611 double quality = UndefinedQualityValue; 623 double quality = UndefinedQualityValue;
612 if (!qualityArgument.isEmpty()) { 624 if (!qualityArgument.isEmpty()) {
613 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); 625 v8::Local<v8::Value> v8Value = qualityArgument.v8Value();
614 if (v8Value->IsNumber()) { 626 if (v8Value->IsNumber()) {
615 quality = v8Value.As<v8::Number>()->Value(); 627 quality = v8Value.As<v8::Number>()->Value();
616 } 628 }
617 } 629 }
618 return toDataURLInternal(mimeType, quality, BackBuffer); 630 return toDataURLInternal(mimeType, quality, BackBuffer);
Justin Novosad 2016/05/19 15:36:55 Specifically for toDataURL, it would make more sen
xidachen 2016/05/20 12:36:54 Done.
619 } 631 }
620 632
621 void HTMLCanvasElement::toBlob(BlobCallback* callback, const String& mimeType, c onst ScriptValue& qualityArgument, ExceptionState& exceptionState) 633 void HTMLCanvasElement::toBlob(BlobCallback* callback, const String& mimeType, c onst ScriptValue& qualityArgument, ExceptionState& exceptionState)
622 { 634 {
623 if (!originClean()) { 635 if (!originClean()) {
624 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); 636 exceptionState.throwSecurityError("Tainted canvases may not be exported. ");
625 return; 637 return;
626 } 638 }
627 639
628 if (!isPaintable()) { 640 if (!isPaintable()) {
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 } 1138 }
1127 1139
1128 String HTMLCanvasElement::getIdFromControl(const Element* element) 1140 String HTMLCanvasElement::getIdFromControl(const Element* element)
1129 { 1141 {
1130 if (m_context) 1142 if (m_context)
1131 return m_context->getIdFromControl(element); 1143 return m_context->getIdFromControl(element);
1132 return String(); 1144 return String();
1133 } 1145 }
1134 1146
1135 } // namespace blink 1147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698