Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/image-decoders/ImageDecoder.h" | 11 #include "platform/image-decoders/ImageDecoder.h" |
| 11 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
| 12 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 static const char* imageOrientationFlipY = "flipY"; | 17 static const char* imageOrientationFlipY = "flipY"; |
| 17 static const char* imageBitmapOptionNone = "none"; | 18 static const char* imageBitmapOptionNone = "none"; |
| 18 | 19 |
| 19 // The following two functions are helpers used in cropImage | 20 // The following two functions are helpers used in cropImage |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 } | 396 } |
| 396 | 397 |
| 397 void ImageBitmap::close() | 398 void ImageBitmap::close() |
| 398 { | 399 { |
| 399 if (!m_image || m_isNeutered) | 400 if (!m_image || m_isNeutered) |
| 400 return; | 401 return; |
| 401 m_image.clear(); | 402 m_image.clear(); |
| 402 m_isNeutered = true; | 403 m_isNeutered = true; |
| 403 } | 404 } |
| 404 | 405 |
| 406 // static | |
| 407 ImageBitmap* ImageBitmap::take(ScriptPromiseResolver*, sk_sp<SkImage> image) | |
| 408 { | |
| 409 return ImageBitmap::create(StaticBitmapImage::create(fromSkSp(image))); | |
|
Justin Novosad
2016/04/27 15:03:17
You must determine whether 'image' is tainted with
mcasas
2016/04/27 17:48:18
|image| comes from a MediaStream so it's origin is
| |
| 410 } | |
| 411 | |
| 405 PassOwnPtr<uint8_t[]> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp) | 412 PassOwnPtr<uint8_t[]> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp) |
| 406 { | 413 { |
| 407 SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorTy pe, (alphaOp == PremultiplyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType) ; | 414 SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorTy pe, (alphaOp == PremultiplyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType) ; |
| 408 OwnPtr<uint8_t[]> dstPixels = copySkImageData(m_image->imageForCurrentFrame( ).get(), info); | 415 OwnPtr<uint8_t[]> dstPixels = copySkImageData(m_image->imageForCurrentFrame( ).get(), info); |
| 409 return dstPixels.release(); | 416 return dstPixels.release(); |
| 410 } | 417 } |
| 411 | 418 |
| 412 unsigned long ImageBitmap::width() const | 419 unsigned long ImageBitmap::width() const |
| 413 { | 420 { |
| 414 if (!m_image) | 421 if (!m_image) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 FloatSize ImageBitmap::elementSize(const FloatSize&) const | 478 FloatSize ImageBitmap::elementSize(const FloatSize&) const |
| 472 { | 479 { |
| 473 return FloatSize(width(), height()); | 480 return FloatSize(width(), height()); |
| 474 } | 481 } |
| 475 | 482 |
| 476 DEFINE_TRACE(ImageBitmap) | 483 DEFINE_TRACE(ImageBitmap) |
| 477 { | 484 { |
| 478 } | 485 } |
| 479 | 486 |
| 480 } // namespace blink | 487 } // namespace blink |
| OLD | NEW |