| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin())
); | 175 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin())
); |
| 176 } | 176 } |
| 177 | 177 |
| 178 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) | 178 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) |
| 179 { | 179 { |
| 180 ASSERT(canvas->isPaintable()); | 180 ASSERT(canvas->isPaintable()); |
| 181 bool imageOrientationFlipYFlag; | 181 bool imageOrientationFlipYFlag; |
| 182 bool premultiplyAlphaEnabledFlag; | 182 bool premultiplyAlphaEnabledFlag; |
| 183 parseOptions(options, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag
); | 183 parseOptions(options, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag
); |
| 184 // canvas is always premultiplied, so set the last parameter to true and con
vert to un-premul later | 184 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag); |
| 185 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect, imageOrientationFlipYFlag, true); | |
| 186 if (!premultiplyAlphaEnabledFlag) | |
| 187 m_image = StaticBitmapImage::create(adoptRef(premulSkImageToUnPremul(m_i
mage->imageForCurrentFrame().get()))); | |
| 188 m_image->setOriginClean(canvas->originClean()); | 185 m_image->setOriginClean(canvas->originClean()); |
| 189 } | 186 } |
| 190 | 187 |
| 191 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi
tmapOptions& options) | 188 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi
tmapOptions& options) |
| 192 { | 189 { |
| 193 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); | 190 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); |
| 194 | 191 |
| 195 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque,
DoNotInitializeImagePixels); | 192 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque,
DoNotInitializeImagePixels); |
| 196 if (!buffer) | 193 if (!buffer) |
| 197 return; | 194 return; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 { | 351 { |
| 355 return FloatSize(width(), height()); | 352 return FloatSize(width(), height()); |
| 356 } | 353 } |
| 357 | 354 |
| 358 DEFINE_TRACE(ImageBitmap) | 355 DEFINE_TRACE(ImageBitmap) |
| 359 { | 356 { |
| 360 ImageLoaderClient::trace(visitor); | 357 ImageLoaderClient::trace(visitor); |
| 361 } | 358 } |
| 362 | 359 |
| 363 } // namespace blink | 360 } // namespace blink |
| OLD | NEW |