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

Side by Side Diff: Source/core/inspector/InspectorLayerTreeAgent.cpp

Issue 559103002: Reduce memory peaks when generating data urls for images. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: toDataURL(): Fewer temporary coppies of image data Created 6 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
« no previous file with comments | « no previous file | Source/platform/graphics/ImageBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "core/rendering/compositing/CompositedLayerMapping.h" 46 #include "core/rendering/compositing/CompositedLayerMapping.h"
47 #include "core/rendering/compositing/RenderLayerCompositor.h" 47 #include "core/rendering/compositing/RenderLayerCompositor.h"
48 #include "platform/geometry/IntRect.h" 48 #include "platform/geometry/IntRect.h"
49 #include "platform/graphics/CompositingReasons.h" 49 #include "platform/graphics/CompositingReasons.h"
50 #include "platform/graphics/GraphicsContextRecorder.h" 50 #include "platform/graphics/GraphicsContextRecorder.h"
51 #include "platform/image-encoders/skia/PNGImageEncoder.h" 51 #include "platform/image-encoders/skia/PNGImageEncoder.h"
52 #include "platform/transforms/TransformationMatrix.h" 52 #include "platform/transforms/TransformationMatrix.h"
53 #include "public/platform/WebFloatPoint.h" 53 #include "public/platform/WebFloatPoint.h"
54 #include "public/platform/WebLayer.h" 54 #include "public/platform/WebLayer.h"
55 #include "wtf/text/Base64.h" 55 #include "wtf/text/Base64.h"
56 #include "wtf/text/StringBuilder.h"
56 57
57 namespace blink { 58 namespace blink {
58 59
59 unsigned InspectorLayerTreeAgent::s_lastSnapshotId; 60 unsigned InspectorLayerTreeAgent::s_lastSnapshotId;
60 61
61 inline String idForLayer(const GraphicsLayer* graphicsLayer) 62 inline String idForLayer(const GraphicsLayer* graphicsLayer)
62 { 63 {
63 return String::number(graphicsLayer->platformLayer()->id()); 64 return String::number(graphicsLayer->platformLayer()->id());
64 } 65 }
65 66
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void InspectorLayerTreeAgent::replaySnapshot(ErrorString* errorString, const Str ing& snapshotId, const int* fromStep, const int* toStep, const double* scale, St ring* dataURL) 377 void InspectorLayerTreeAgent::replaySnapshot(ErrorString* errorString, const Str ing& snapshotId, const int* fromStep, const int* toStep, const double* scale, St ring* dataURL)
377 { 378 {
378 const GraphicsContextSnapshot* snapshot = snapshotById(errorString, snapshot Id); 379 const GraphicsContextSnapshot* snapshot = snapshotById(errorString, snapshot Id);
379 if (!snapshot) 380 if (!snapshot)
380 return; 381 return;
381 OwnPtr<Vector<char> > base64Data = snapshot->replay(fromStep ? *fromStep : 0 , toStep ? *toStep : 0, scale ? *scale : 1.0); 382 OwnPtr<Vector<char> > base64Data = snapshot->replay(fromStep ? *fromStep : 0 , toStep ? *toStep : 0, scale ? *scale : 1.0);
382 if (!base64Data) { 383 if (!base64Data) {
383 *errorString = "Image encoding failed"; 384 *errorString = "Image encoding failed";
384 return; 385 return;
385 } 386 }
386 *dataURL = "data:image/png;base64," + *base64Data; 387 StringBuilder url;
388 url.appendLiteral("data:image/png;base64,");
389 url.reserveCapacity(url.length() + base64Data->size());
390 url.append(base64Data->begin(), base64Data->size());
391 *dataURL = url.toString();
387 } 392 }
388 393
389 void InspectorLayerTreeAgent::profileSnapshot(ErrorString* errorString, const St ring& snapshotId, const int* minRepeatCount, const double* minDuration, RefPtr<T ypeBuilder::Array<TypeBuilder::Array<double> > >& outTimings) 394 void InspectorLayerTreeAgent::profileSnapshot(ErrorString* errorString, const St ring& snapshotId, const int* minRepeatCount, const double* minDuration, RefPtr<T ypeBuilder::Array<TypeBuilder::Array<double> > >& outTimings)
390 { 395 {
391 const GraphicsContextSnapshot* snapshot = snapshotById(errorString, snapshot Id); 396 const GraphicsContextSnapshot* snapshot = snapshotById(errorString, snapshot Id);
392 if (!snapshot) 397 if (!snapshot)
393 return; 398 return;
394 OwnPtr<GraphicsContextSnapshot::Timings> timings = snapshot->profile(minRepe atCount ? *minRepeatCount : 1, minDuration ? *minDuration : 0); 399 OwnPtr<GraphicsContextSnapshot::Timings> timings = snapshot->profile(minRepe atCount ? *minRepeatCount : 1, minDuration ? *minDuration : 0);
395 outTimings = TypeBuilder::Array<TypeBuilder::Array<double> >::create(); 400 outTimings = TypeBuilder::Array<TypeBuilder::Array<double> >::create();
396 for (size_t i = 0; i < timings->size(); ++i) { 401 for (size_t i = 0; i < timings->size(); ++i) {
(...skipping 21 matching lines...) Expand all
418 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) 423 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer)
419 { 424 {
420 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); 425 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id());
421 if (index == WTF::kNotFound) 426 if (index == WTF::kNotFound)
422 return; 427 return;
423 m_pageOverlayLayerIds.remove(index); 428 m_pageOverlayLayerIds.remove(index);
424 } 429 }
425 430
426 431
427 } // namespace blink 432 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/ImageBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698