| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect, Docum
ent* document, const ImageBitmapOptions& options) | 163 ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect, Docum
ent* document, const ImageBitmapOptions& options) |
| 164 { | 164 { |
| 165 bool flipY; | 165 bool flipY; |
| 166 parseOptions(options, flipY); | 166 parseOptions(options, flipY); |
| 167 | 167 |
| 168 m_image = cropImage(image->cachedImage()->image(), cropRect, flipY, m_isPrem
ultiplied, PremultiplyAlpha); | 168 m_image = cropImage(image->cachedImage()->image(), cropRect, flipY, m_isPrem
ultiplied, PremultiplyAlpha); |
| 169 if (!m_image) | 169 if (!m_image) |
| 170 return; | 170 return; |
| 171 m_image->setOriginClean(!image->wouldTaintOrigin(document->securityOrigin())
); | 171 m_image->setOriginClean(!image->wouldTaintOrigin(document->getSecurityOrigin
())); |
| 172 } | 172 } |
| 173 | 173 |
| 174 ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect, Docum
ent* document, const ImageBitmapOptions& options) | 174 ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect, Docum
ent* document, const ImageBitmapOptions& options) |
| 175 { | 175 { |
| 176 IntSize playerSize; | 176 IntSize playerSize; |
| 177 if (video->webMediaPlayer()) | 177 if (video->webMediaPlayer()) |
| 178 playerSize = video->webMediaPlayer()->naturalSize(); | 178 playerSize = video->webMediaPlayer()->naturalSize(); |
| 179 | 179 |
| 180 IntRect videoRect = IntRect(IntPoint(), playerSize); | 180 IntRect videoRect = IntRect(IntPoint(), playerSize); |
| 181 IntRect srcRect = intersection(cropRect, videoRect); | 181 IntRect srcRect = intersection(cropRect, videoRect); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 192 if (flipY || !m_isPremultiplied) { | 192 if (flipY || !m_isPremultiplied) { |
| 193 RefPtr<SkImage> skiaImage = buffer->newSkImageSnapshot(PreferNoAccelerat
ion, SnapshotReasonUnknown); | 193 RefPtr<SkImage> skiaImage = buffer->newSkImageSnapshot(PreferNoAccelerat
ion, SnapshotReasonUnknown); |
| 194 if (flipY) | 194 if (flipY) |
| 195 skiaImage = flipSkImageVertically(skiaImage.get(), PremultiplyAlpha)
; | 195 skiaImage = flipSkImageVertically(skiaImage.get(), PremultiplyAlpha)
; |
| 196 if (!m_isPremultiplied) | 196 if (!m_isPremultiplied) |
| 197 skiaImage = premulSkImageToUnPremul(skiaImage.get()); | 197 skiaImage = premulSkImageToUnPremul(skiaImage.get()); |
| 198 m_image = StaticBitmapImage::create(skiaImage.release()); | 198 m_image = StaticBitmapImage::create(skiaImage.release()); |
| 199 } else { | 199 } else { |
| 200 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoA
cceleration, SnapshotReasonUnknown)); | 200 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoA
cceleration, SnapshotReasonUnknown)); |
| 201 } | 201 } |
| 202 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin())
); | 202 m_image->setOriginClean(!video->wouldTaintOrigin(document->getSecurityOrigin
())); |
| 203 } | 203 } |
| 204 | 204 |
| 205 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) | 205 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) |
| 206 { | 206 { |
| 207 ASSERT(canvas->isPaintable()); | 207 ASSERT(canvas->isPaintable()); |
| 208 bool flipY; | 208 bool flipY; |
| 209 parseOptions(options, flipY); | 209 parseOptions(options, flipY); |
| 210 | 210 |
| 211 // canvas is always premultiplied, so set the last parameter to true and con
vert to un-premul later | 211 // canvas is always premultiplied, so set the last parameter to true and con
vert to un-premul later |
| 212 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect, flipY, true); | 212 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect, flipY, true); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 FloatSize ImageBitmap::elementSize(const FloatSize&) const | 446 FloatSize ImageBitmap::elementSize(const FloatSize&) const |
| 447 { | 447 { |
| 448 return FloatSize(width(), height()); | 448 return FloatSize(width(), height()); |
| 449 } | 449 } |
| 450 | 450 |
| 451 DEFINE_TRACE(ImageBitmap) | 451 DEFINE_TRACE(ImageBitmap) |
| 452 { | 452 { |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace blink | 455 } // namespace blink |
| OLD | NEW |