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/image-decoders/ImageDecoder.h" | 10 #include "platform/image-decoders/ImageDecoder.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 395 } |
396 | 396 |
397 void ImageBitmap::close() | 397 void ImageBitmap::close() |
398 { | 398 { |
399 if (!m_image || m_isNeutered) | 399 if (!m_image || m_isNeutered) |
400 return; | 400 return; |
401 m_image.clear(); | 401 m_image.clear(); |
402 m_isNeutered = true; | 402 m_isNeutered = true; |
403 } | 403 } |
404 | 404 |
| 405 // static |
| 406 ImageBitmap* ImageBitmap::take(ScriptPromiseResolver*, PassOwnPtr<SkBitmap> bitm
ap) |
| 407 { |
| 408 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create( |
| 409 adoptRef(SkImage::NewFromBitmap(*bitmap))); |
| 410 |
| 411 return ImageBitmap::create(image); |
| 412 } |
| 413 |
405 PassOwnPtr<uint8_t[]> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp) | 414 PassOwnPtr<uint8_t[]> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp) |
406 { | 415 { |
407 SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorTy
pe, (alphaOp == PremultiplyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType)
; | 416 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); | 417 OwnPtr<uint8_t[]> dstPixels = copySkImageData(m_image->imageForCurrentFrame(
).get(), info); |
409 return dstPixels.release(); | 418 return dstPixels.release(); |
410 } | 419 } |
411 | 420 |
412 unsigned long ImageBitmap::width() const | 421 unsigned long ImageBitmap::width() const |
413 { | 422 { |
414 if (!m_image) | 423 if (!m_image) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 FloatSize ImageBitmap::elementSize(const FloatSize&) const | 480 FloatSize ImageBitmap::elementSize(const FloatSize&) const |
472 { | 481 { |
473 return FloatSize(width(), height()); | 482 return FloatSize(width(), height()); |
474 } | 483 } |
475 | 484 |
476 DEFINE_TRACE(ImageBitmap) | 485 DEFINE_TRACE(ImageBitmap) |
477 { | 486 { |
478 } | 487 } |
479 | 488 |
480 } // namespace blink | 489 } // namespace blink |
OLD | NEW |