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

Side by Side Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 1382883002: Fixing performance issue of creating imagebitmap from ImageData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change enum type name and remove temps Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "config.h" 5 #include "config.h"
6 #include "core/frame/ImageBitmap.h" 6 #include "core/frame/ImageBitmap.h"
7 7
8 #include "core/html/HTMLCanvasElement.h" 8 #include "core/html/HTMLCanvasElement.h"
9 #include "core/html/HTMLVideoElement.h" 9 #include "core/html/HTMLVideoElement.h"
10 #include "core/html/ImageData.h" 10 #include "core/html/ImageData.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 ASSERT(canvas->isPaintable()); 91 ASSERT(canvas->isPaintable());
92 m_bitmap = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration), cr opRect); 92 m_bitmap = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration), cr opRect);
93 } 93 }
94 94
95 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) 95 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
96 : m_imageElement(nullptr) 96 : m_imageElement(nullptr)
97 , m_cropRect(cropRect) 97 , m_cropRect(cropRect)
98 , m_bitmapOffset(IntPoint()) 98 , m_bitmapOffset(IntPoint())
99 { 99 {
100 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); 100 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size()));
101 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size()); 101 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size(), Opaque, DoNot InitializeImagePixels);
102 if (!buffer) 102 if (!buffer)
103 return; 103 return;
104 104
105 if (srcRect.width() > 0 && srcRect.height() > 0) 105 if (srcRect.width() > 0 && srcRect.height() > 0)
106 buffer->putByteArray(Premultiplied, data->data()->data(), data->size(), srcRect, IntPoint(std::min(0, -cropRect.x()), std::min(0, -cropRect.y()))); 106 buffer->putByteArray(Premultiplied, data->data()->data(), data->size(), srcRect, IntPoint(std::min(0, -cropRect.x()), std::min(0, -cropRect.y())));
107 107
108 m_bitmap = buffer->newImageSnapshot(); 108 m_bitmap = buffer->newImageSnapshot();
109 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); 109 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size());
110 } 110 }
111 111
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return FloatSize(width(), height()); 220 return FloatSize(width(), height());
221 } 221 }
222 222
223 DEFINE_TRACE(ImageBitmap) 223 DEFINE_TRACE(ImageBitmap)
224 { 224 {
225 visitor->trace(m_imageElement); 225 visitor->trace(m_imageElement);
226 ImageLoaderClient::trace(visitor); 226 ImageLoaderClient::trace(visitor);
227 } 227 }
228 228
229 } // namespace blink 229 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698