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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 "core/frame/ImageBitmap.h" 5 #include "core/frame/ImageBitmap.h"
6 6
7 #include "core/html/HTMLCanvasElement.h" 7 #include "core/html/HTMLCanvasElement.h"
8 #include "core/html/HTMLVideoElement.h" 8 #include "core/html/HTMLVideoElement.h"
9 #include "core/html/ImageData.h" 9 #include "core/html/ImageData.h"
10 #include "platform/graphics/skia/SkiaUtils.h" 10 #include "platform/graphics/skia/SkiaUtils.h"
11 #include "platform/image-decoders/ImageDecoder.h" 11 #include "platform/image-decoders/ImageDecoder.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkSurface.h" 13 #include "third_party/skia/include/core/SkSurface.h"
14 #include "wtf/PtrUtil.h"
15 #include "wtf/RefPtr.h" 14 #include "wtf/RefPtr.h"
16 #include <memory>
17 15
18 namespace blink { 16 namespace blink {
19 17
20 static const char* imageOrientationFlipY = "flipY"; 18 static const char* imageOrientationFlipY = "flipY";
21 static const char* imageBitmapOptionNone = "none"; 19 static const char* imageBitmapOptionNone = "none";
22 20
23 // The following two functions are helpers used in cropImage 21 // The following two functions are helpers used in cropImage
24 static inline IntRect normalizeRect(const IntRect& rect) 22 static inline IntRect normalizeRect(const IntRect& rect)
25 { 23 {
26 return IntRect(std::min(rect.x(), rect.maxX()), 24 return IntRect(std::min(rect.x(), rect.maxX()),
27 std::min(rect.y(), rect.maxY()), 25 std::min(rect.y(), rect.maxY()),
28 std::max(rect.width(), -rect.width()), 26 std::max(rect.width(), -rect.width()),
29 std::max(rect.height(), -rect.height())); 27 std::max(rect.height(), -rect.height()));
30 } 28 }
31 29
32 static bool frameIsValid(const SkBitmap& frameBitmap) 30 static bool frameIsValid(const SkBitmap& frameBitmap)
33 { 31 {
34 ASSERT(!frameBitmap.isNull() && !frameBitmap.empty() && frameBitmap.isImmuta ble()); 32 ASSERT(!frameBitmap.isNull() && !frameBitmap.empty() && frameBitmap.isImmuta ble());
35 return frameBitmap.colorType() == kN32_SkColorType; 33 return frameBitmap.colorType() == kN32_SkColorType;
36 } 34 }
37 35
38 static std::unique_ptr<uint8_t[]> copySkImageData(SkImage* input, const SkImageI nfo& info) 36 static PassOwnPtr<uint8_t[]> copySkImageData(SkImage* input, const SkImageInfo& info)
39 { 37 {
40 std::unique_ptr<uint8_t[]> dstPixels = wrapArrayUnique(new uint8_t[input->wi dth() * input->height() * info.bytesPerPixel()]); 38 OwnPtr<uint8_t[]> dstPixels = adoptArrayPtr(new uint8_t[input->width() * inp ut->height() * info.bytesPerPixel()]);
41 input->readPixels(info, dstPixels.get(), input->width() * info.bytesPerPixel (), 0, 0); 39 input->readPixels(info, dstPixels.get(), input->width() * info.bytesPerPixel (), 0, 0);
42 return dstPixels; 40 return dstPixels;
43 } 41 }
44 42
45 static PassRefPtr<SkImage> newSkImageFromRaster(const SkImageInfo& info, std::un ique_ptr<uint8_t[]> imagePixels, int imageRowBytes) 43 static PassRefPtr<SkImage> newSkImageFromRaster(const SkImageInfo& info, PassOwn Ptr<uint8_t[]> imagePixels, int imageRowBytes)
46 { 44 {
47 return fromSkSp(SkImage::MakeFromRaster(SkPixmap(info, imagePixels.release() , imageRowBytes), 45 return fromSkSp(SkImage::MakeFromRaster(SkPixmap(info, imagePixels.leakPtr() , imageRowBytes),
48 [](const void* pixels, void*) 46 [](const void* pixels, void*)
49 { 47 {
50 delete[] static_cast<const uint8_t*>(pixels); 48 delete[] static_cast<const uint8_t*>(pixels);
51 }, nullptr)); 49 }, nullptr));
52 } 50 }
53 51
54 static void swizzleImageData(unsigned char* srcAddr, int height, int bytesPerRow , bool flipY) 52 static void swizzleImageData(unsigned char* srcAddr, int height, int bytesPerRow , bool flipY)
55 { 53 {
56 if (flipY) { 54 if (flipY) {
57 for (int i = 0; i < height / 2; i++) { 55 for (int i = 0; i < height / 2; i++) {
(...skipping 11 matching lines...) Expand all
69 std::swap(srcAddr[i], srcAddr[i + 2]); 67 std::swap(srcAddr[i], srcAddr[i + 2]);
70 } 68 }
71 } 69 }
72 70
73 static PassRefPtr<SkImage> flipSkImageVertically(SkImage* input, AlphaDispositio n alphaOp) 71 static PassRefPtr<SkImage> flipSkImageVertically(SkImage* input, AlphaDispositio n alphaOp)
74 { 72 {
75 int width = input->width(); 73 int width = input->width();
76 int height = input->height(); 74 int height = input->height();
77 SkImageInfo info = SkImageInfo::MakeN32(width, height, (alphaOp == Premultip lyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); 75 SkImageInfo info = SkImageInfo::MakeN32(width, height, (alphaOp == Premultip lyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType);
78 int imageRowBytes = width * info.bytesPerPixel(); 76 int imageRowBytes = width * info.bytesPerPixel();
79 std::unique_ptr<uint8_t[]> imagePixels = copySkImageData(input, info); 77 OwnPtr<uint8_t[]> imagePixels = copySkImageData(input, info);
80 for (int i = 0; i < height / 2; i++) { 78 for (int i = 0; i < height / 2; i++) {
81 int topFirstElement = i * imageRowBytes; 79 int topFirstElement = i * imageRowBytes;
82 int topLastElement = (i + 1) * imageRowBytes; 80 int topLastElement = (i + 1) * imageRowBytes;
83 int bottomFirstElement = (height - 1 - i) * imageRowBytes; 81 int bottomFirstElement = (height - 1 - i) * imageRowBytes;
84 std::swap_ranges(imagePixels.get() + topFirstElement, imagePixels.get() + topLastElement, imagePixels.get() + bottomFirstElement); 82 std::swap_ranges(imagePixels.get() + topFirstElement, imagePixels.get() + topLastElement, imagePixels.get() + bottomFirstElement);
85 } 83 }
86 return newSkImageFromRaster(info, std::move(imagePixels), imageRowBytes); 84 return newSkImageFromRaster(info, std::move(imagePixels), imageRowBytes);
87 } 85 }
88 86
89 static PassRefPtr<SkImage> premulSkImageToUnPremul(SkImage* input) 87 static PassRefPtr<SkImage> premulSkImageToUnPremul(SkImage* input)
90 { 88 {
91 SkImageInfo info = SkImageInfo::Make(input->width(), input->height(), kN32_S kColorType, kUnpremul_SkAlphaType); 89 SkImageInfo info = SkImageInfo::Make(input->width(), input->height(), kN32_S kColorType, kUnpremul_SkAlphaType);
92 std::unique_ptr<uint8_t[]> dstPixels = copySkImageData(input, info); 90 OwnPtr<uint8_t[]> dstPixels = copySkImageData(input, info);
93 return newSkImageFromRaster(info, std::move(dstPixels), input->width() * inf o.bytesPerPixel()); 91 return newSkImageFromRaster(info, std::move(dstPixels), input->width() * inf o.bytesPerPixel());
94 } 92 }
95 93
96 static PassRefPtr<SkImage> unPremulSkImageToPremul(SkImage* input) 94 static PassRefPtr<SkImage> unPremulSkImageToPremul(SkImage* input)
97 { 95 {
98 SkImageInfo info = SkImageInfo::Make(input->width(), input->height(), kN32_S kColorType, kPremul_SkAlphaType); 96 SkImageInfo info = SkImageInfo::Make(input->width(), input->height(), kN32_S kColorType, kPremul_SkAlphaType);
99 std::unique_ptr<uint8_t[]> dstPixels = copySkImageData(input, info); 97 OwnPtr<uint8_t[]> dstPixels = copySkImageData(input, info);
100 return newSkImageFromRaster(info, std::move(dstPixels), input->width() * inf o.bytesPerPixel()); 98 return newSkImageFromRaster(info, std::move(dstPixels), input->width() * inf o.bytesPerPixel());
101 } 99 }
102 100
103 PassRefPtr<SkImage> ImageBitmap::getSkImageFromDecoder(std::unique_ptr<ImageDeco der> decoder) 101 PassRefPtr<SkImage> ImageBitmap::getSkImageFromDecoder(PassOwnPtr<ImageDecoder> decoder)
104 { 102 {
105 if (!decoder->frameCount()) 103 if (!decoder->frameCount())
106 return nullptr; 104 return nullptr;
107 ImageFrame* frame = decoder->frameBufferAtIndex(0); 105 ImageFrame* frame = decoder->frameBufferAtIndex(0);
108 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) 106 if (!frame || frame->getStatus() != ImageFrame::FrameComplete)
109 return nullptr; 107 return nullptr;
110 SkBitmap bitmap = frame->bitmap(); 108 SkBitmap bitmap = frame->bitmap();
111 if (!frameIsValid(bitmap)) 109 if (!frameIsValid(bitmap))
112 return nullptr; 110 return nullptr;
113 return fromSkSp(SkImage::MakeFromBitmap(bitmap)); 111 return fromSkSp(SkImage::MakeFromBitmap(bitmap));
114 } 112 }
115 113
116 // The parameter imageFormat indicates whether the first parameter "image" is un premultiplied or not. 114 // The parameter imageFormat indicates whether the first parameter "image" is un premultiplied or not.
117 // imageFormat = PremultiplyAlpha means the image is in premuliplied format 115 // imageFormat = PremultiplyAlpha means the image is in premuliplied format
118 // For example, if the image is already in unpremultiplied format and we want th e created ImageBitmap 116 // For example, if the image is already in unpremultiplied format and we want th e created ImageBitmap
119 // in the same format, then we don't need to use the ImageDecoder to decode the image. 117 // in the same format, then we don't need to use the ImageDecoder to decode the image.
120 static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const IntRect& crop Rect, bool flipY, bool premultiplyAlpha, AlphaDisposition imageFormat = Premulti plyAlpha, ImageDecoder::GammaAndColorProfileOption colorSpaceOp = ImageDecoder:: GammaAndColorProfileApplied) 118 static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const IntRect& crop Rect, bool flipY, bool premultiplyAlpha, AlphaDisposition imageFormat = Premulti plyAlpha, ImageDecoder::GammaAndColorProfileOption colorSpaceOp = ImageDecoder:: GammaAndColorProfileApplied)
121 { 119 {
122 ASSERT(image); 120 ASSERT(image);
123 121
124 IntRect imgRect(IntPoint(), IntSize(image->width(), image->height())); 122 IntRect imgRect(IntPoint(), IntSize(image->width(), image->height()));
125 const IntRect srcRect = intersection(imgRect, cropRect); 123 const IntRect srcRect = intersection(imgRect, cropRect);
126 124
127 // In the case when cropRect doesn't intersect the source image and it requi res a umpremul image 125 // In the case when cropRect doesn't intersect the source image and it requi res a umpremul image
128 // We immediately return a transparent black image with cropRect.size() 126 // We immediately return a transparent black image with cropRect.size()
129 if (srcRect.isEmpty() && !premultiplyAlpha) { 127 if (srcRect.isEmpty() && !premultiplyAlpha) {
130 SkImageInfo info = SkImageInfo::Make(cropRect.width(), cropRect.height() , kN32_SkColorType, kUnpremul_SkAlphaType); 128 SkImageInfo info = SkImageInfo::Make(cropRect.width(), cropRect.height() , kN32_SkColorType, kUnpremul_SkAlphaType);
131 std::unique_ptr<uint8_t[]> dstPixels = wrapArrayUnique(new uint8_t[cropR ect.width() * cropRect.height() * info.bytesPerPixel()]()); 129 OwnPtr<uint8_t[]> dstPixels = adoptArrayPtr(new uint8_t[cropRect.width() * cropRect.height() * info.bytesPerPixel()]());
132 return StaticBitmapImage::create(newSkImageFromRaster(info, std::move(ds tPixels), cropRect.width() * info.bytesPerPixel())); 130 return StaticBitmapImage::create(newSkImageFromRaster(info, std::move(ds tPixels), cropRect.width() * info.bytesPerPixel()));
133 } 131 }
134 132
135 RefPtr<SkImage> skiaImage = image->imageForCurrentFrame(); 133 RefPtr<SkImage> skiaImage = image->imageForCurrentFrame();
136 // Attempt to get raw unpremultiplied image data, executed only when skiaIma ge is premultiplied. 134 // Attempt to get raw unpremultiplied image data, executed only when skiaIma ge is premultiplied.
137 if ((((!premultiplyAlpha && !skiaImage->isOpaque()) || !skiaImage) && image- >data() && imageFormat == PremultiplyAlpha) || colorSpaceOp == ImageDecoder::Gam maAndColorProfileIgnored) { 135 if ((((!premultiplyAlpha && !skiaImage->isOpaque()) || !skiaImage) && image- >data() && imageFormat == PremultiplyAlpha) || colorSpaceOp == ImageDecoder::Gam maAndColorProfileIgnored) {
138 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(*(image->data ()), 136 OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*(image->data()),
139 premultiplyAlpha ? ImageDecoder::AlphaPremultiplied : ImageDecoder:: AlphaNotPremultiplied, 137 premultiplyAlpha ? ImageDecoder::AlphaPremultiplied : ImageDecoder:: AlphaNotPremultiplied,
140 colorSpaceOp)); 138 colorSpaceOp));
141 if (!decoder) 139 if (!decoder)
142 return nullptr; 140 return nullptr;
143 decoder->setData(image->data(), true); 141 decoder->setData(image->data(), true);
144 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); 142 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder));
145 if (!skiaImage) 143 if (!skiaImage)
146 return nullptr; 144 return nullptr;
147 } 145 }
148 146
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 207 }
210 208
211 ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect, Docum ent* document, const ImageBitmapOptions& options) 209 ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect, Docum ent* document, const ImageBitmapOptions& options)
212 { 210 {
213 IntSize playerSize; 211 IntSize playerSize;
214 if (video->webMediaPlayer()) 212 if (video->webMediaPlayer())
215 playerSize = video->webMediaPlayer()->naturalSize(); 213 playerSize = video->webMediaPlayer()->naturalSize();
216 214
217 IntRect videoRect = IntRect(IntPoint(), playerSize); 215 IntRect videoRect = IntRect(IntPoint(), playerSize);
218 IntRect srcRect = intersection(cropRect, videoRect); 216 IntRect srcRect = intersection(cropRect, videoRect);
219 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), N onOpaque, DoNotInitializeImagePixels); 217 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque, DoNotInitializeImagePixels);
220 if (!buffer) 218 if (!buffer)
221 return; 219 return;
222 220
223 IntPoint dstPoint = IntPoint(std::max(0, -cropRect.x()), std::max(0, -cropRe ct.y())); 221 IntPoint dstPoint = IntPoint(std::max(0, -cropRect.x()), std::max(0, -cropRe ct.y()));
224 video->paintCurrentFrame(buffer->canvas(), IntRect(dstPoint, srcRect.size()) , nullptr); 222 video->paintCurrentFrame(buffer->canvas(), IntRect(dstPoint, srcRect.size()) , nullptr);
225 223
226 bool flipY; 224 bool flipY;
227 bool premultiplyAlpha; 225 bool premultiplyAlpha;
228 parseOptions(options, flipY, premultiplyAlpha); 226 parseOptions(options, flipY, premultiplyAlpha);
229 227
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 else 276 else
279 info = SkImageInfo::Make(cropRect.width(), dstHeight, kBGRA_8888_SkC olorType, kPremul_SkAlphaType); 277 info = SkImageInfo::Make(cropRect.width(), dstHeight, kBGRA_8888_SkC olorType, kPremul_SkAlphaType);
280 int srcPixelBytesPerRow = info.bytesPerPixel() * data->size().width(); 278 int srcPixelBytesPerRow = info.bytesPerPixel() * data->size().width();
281 int dstPixelBytesPerRow = info.bytesPerPixel() * cropRect.width(); 279 int dstPixelBytesPerRow = info.bytesPerPixel() * cropRect.width();
282 if (cropRect == IntRect(IntPoint(), data->size())) { 280 if (cropRect == IntRect(IntPoint(), data->size())) {
283 swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, flipY); 281 swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, flipY);
284 m_image = StaticBitmapImage::create(fromSkSp(SkImage::MakeRasterCopy (SkPixmap(info, srcAddr, dstPixelBytesPerRow)))); 282 m_image = StaticBitmapImage::create(fromSkSp(SkImage::MakeRasterCopy (SkPixmap(info, srcAddr, dstPixelBytesPerRow))));
285 // restore the original ImageData 283 // restore the original ImageData
286 swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, flipY); 284 swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, flipY);
287 } else { 285 } else {
288 std::unique_ptr<uint8_t[]> copiedDataBuffer = wrapArrayUnique(new ui nt8_t[dstHeight * dstPixelBytesPerRow]()); 286 OwnPtr<uint8_t[]> copiedDataBuffer = adoptArrayPtr(new uint8_t[dstHe ight * dstPixelBytesPerRow]());
289 if (!srcRect.isEmpty()) { 287 if (!srcRect.isEmpty()) {
290 IntPoint srcPoint = IntPoint((cropRect.x() > 0) ? cropRect.x() : 0, (cropRect.y() > 0) ? cropRect.y() : 0); 288 IntPoint srcPoint = IntPoint((cropRect.x() > 0) ? cropRect.x() : 0, (cropRect.y() > 0) ? cropRect.y() : 0);
291 IntPoint dstPoint = IntPoint((cropRect.x() >= 0) ? 0 : -cropRect .x(), (cropRect.y() >= 0) ? 0 : -cropRect.y()); 289 IntPoint dstPoint = IntPoint((cropRect.x() >= 0) ? 0 : -cropRect .x(), (cropRect.y() >= 0) ? 0 : -cropRect.y());
292 int copyHeight = srcHeight - srcPoint.y(); 290 int copyHeight = srcHeight - srcPoint.y();
293 if (cropRect.height() < copyHeight) 291 if (cropRect.height() < copyHeight)
294 copyHeight = cropRect.height(); 292 copyHeight = cropRect.height();
295 int copyWidth = data->size().width() - srcPoint.x(); 293 int copyWidth = data->size().width() - srcPoint.x();
296 if (cropRect.width() < copyWidth) 294 if (cropRect.width() < copyWidth)
297 copyWidth = cropRect.width(); 295 copyWidth = cropRect.width();
298 for (int i = 0; i < copyHeight; i++) { 296 for (int i = 0; i < copyHeight; i++) {
(...skipping 13 matching lines...) Expand all
312 copiedDataBuffer[dstStartCopyPosition + j] = srcAddr [srcStartCopyPosition + j]; 310 copiedDataBuffer[dstStartCopyPosition + j] = srcAddr [srcStartCopyPosition + j];
313 } 311 }
314 } 312 }
315 } 313 }
316 m_image = StaticBitmapImage::create(newSkImageFromRaster(info, std:: move(copiedDataBuffer), dstPixelBytesPerRow)); 314 m_image = StaticBitmapImage::create(newSkImageFromRaster(info, std:: move(copiedDataBuffer), dstPixelBytesPerRow));
317 } 315 }
318 m_image->setPremultiplied(premultiplyAlpha); 316 m_image->setPremultiplied(premultiplyAlpha);
319 return; 317 return;
320 } 318 }
321 319
322 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), N onOpaque, DoNotInitializeImagePixels); 320 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque, DoNotInitializeImagePixels);
323 if (!buffer) 321 if (!buffer)
324 return; 322 return;
325 323
326 if (srcRect.isEmpty()) { 324 if (srcRect.isEmpty()) {
327 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoA cceleration, SnapshotReasonUnknown)); 325 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoA cceleration, SnapshotReasonUnknown));
328 return; 326 return;
329 } 327 }
330 328
331 IntPoint dstPoint = IntPoint(std::min(0, -cropRect.x()), std::min(0, -cropRe ct.y())); 329 IntPoint dstPoint = IntPoint(std::min(0, -cropRect.x()), std::min(0, -cropRe ct.y()));
332 if (cropRect.x() < 0) 330 if (cropRect.x() < 0)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 m_image.clear(); 436 m_image.clear();
439 m_isNeutered = true; 437 m_isNeutered = true;
440 } 438 }
441 439
442 // static 440 // static
443 ImageBitmap* ImageBitmap::take(ScriptPromiseResolver*, sk_sp<SkImage> image) 441 ImageBitmap* ImageBitmap::take(ScriptPromiseResolver*, sk_sp<SkImage> image)
444 { 442 {
445 return ImageBitmap::create(StaticBitmapImage::create(fromSkSp(image))); 443 return ImageBitmap::create(StaticBitmapImage::create(fromSkSp(image)));
446 } 444 }
447 445
448 std::unique_ptr<uint8_t[]> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp) 446 PassOwnPtr<uint8_t[]> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp)
449 { 447 {
450 SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorTy pe, (alphaOp == PremultiplyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType) ; 448 SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorTy pe, (alphaOp == PremultiplyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType) ;
451 std::unique_ptr<uint8_t[]> dstPixels = copySkImageData(m_image->imageForCurr entFrame().get(), info); 449 OwnPtr<uint8_t[]> dstPixels = copySkImageData(m_image->imageForCurrentFrame( ).get(), info);
452 return dstPixels; 450 return dstPixels;
453 } 451 }
454 452
455 unsigned long ImageBitmap::width() const 453 unsigned long ImageBitmap::width() const
456 { 454 {
457 if (!m_image) 455 if (!m_image)
458 return 0; 456 return 0;
459 ASSERT(m_image->width() > 0); 457 ASSERT(m_image->width() > 0);
460 return m_image->width(); 458 return m_image->width();
461 } 459 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 FloatSize ImageBitmap::elementSize(const FloatSize&) const 512 FloatSize ImageBitmap::elementSize(const FloatSize&) const
515 { 513 {
516 return FloatSize(width(), height()); 514 return FloatSize(width(), height());
517 } 515 }
518 516
519 DEFINE_TRACE(ImageBitmap) 517 DEFINE_TRACE(ImageBitmap)
520 { 518 {
521 } 519 }
522 520
523 } // namespace blink 521 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.h ('k') | third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698