| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 183 } |
| 184 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin())
); | 184 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin())
); |
| 185 } | 185 } |
| 186 | 186 |
| 187 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) | 187 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) |
| 188 { | 188 { |
| 189 ASSERT(canvas->isPaintable()); | 189 ASSERT(canvas->isPaintable()); |
| 190 bool imageOrientationFlipYFlag; | 190 bool imageOrientationFlipYFlag; |
| 191 bool premultiplyAlphaEnabledFlag; | 191 bool premultiplyAlphaEnabledFlag; |
| 192 parseOptions(options, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag
); | 192 parseOptions(options, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag
); |
| 193 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag); | 193 // canvas is always premultiplied, so set the last parameter to true and con
vert to un-premul later |
| 194 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect, imageOrientationFlipYFlag, true); |
| 195 if (!premultiplyAlphaEnabledFlag) |
| 196 m_image = StaticBitmapImage::create(premulSkImageToUnPremul(m_image->ima
geForCurrentFrame().get())); |
| 194 m_image->setOriginClean(canvas->originClean()); | 197 m_image->setOriginClean(canvas->originClean()); |
| 195 } | 198 } |
| 196 | 199 |
| 197 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi
tmapOptions& options) | 200 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi
tmapOptions& options) |
| 198 { | 201 { |
| 199 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); | 202 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); |
| 200 | 203 |
| 201 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque,
DoNotInitializeImagePixels); | 204 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque,
DoNotInitializeImagePixels); |
| 202 if (!buffer) | 205 if (!buffer) |
| 203 return; | 206 return; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 { | 363 { |
| 361 return FloatSize(width(), height()); | 364 return FloatSize(width(), height()); |
| 362 } | 365 } |
| 363 | 366 |
| 364 DEFINE_TRACE(ImageBitmap) | 367 DEFINE_TRACE(ImageBitmap) |
| 365 { | 368 { |
| 366 ImageLoaderClient::trace(visitor); | 369 ImageLoaderClient::trace(visitor); |
| 367 } | 370 } |
| 368 | 371 |
| 369 } // namespace blink | 372 } // namespace blink |
| OLD | NEW |