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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 if (cropRect == srcRect) { | 135 if (cropRect == srcRect) { |
136 if (flipY) | 136 if (flipY) |
137 return StaticBitmapImage::create(flipSkImageVertically(skiaImage->ne
wSubset(srcRect), premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlpha)); | 137 return StaticBitmapImage::create(flipSkImageVertically(skiaImage->ne
wSubset(srcRect), premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlpha)); |
138 SkImage* croppedSkImage = skiaImage->newSubset(srcRect); | 138 SkImage* croppedSkImage = skiaImage->newSubset(srcRect); |
139 // Call preroll to trigger image decoding. | 139 // Call preroll to trigger image decoding. |
140 croppedSkImage->preroll(); | 140 croppedSkImage->preroll(); |
141 return StaticBitmapImage::create(adoptRef(croppedSkImage)); | 141 return StaticBitmapImage::create(adoptRef(croppedSkImage)); |
142 } | 142 } |
143 | 143 |
144 RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(cropRect.
width(), cropRect.height())); | 144 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(cropRect.width(),
cropRect.height()); |
145 if (!surface) | 145 if (!surface) |
146 return nullptr; | 146 return nullptr; |
147 if (srcRect.isEmpty()) | 147 if (srcRect.isEmpty()) |
148 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot())); | 148 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot())); |
149 | 149 |
150 SkScalar dstLeft = std::min(0, -cropRect.x()); | 150 SkScalar dstLeft = std::min(0, -cropRect.x()); |
151 SkScalar dstTop = std::min(0, -cropRect.y()); | 151 SkScalar dstTop = std::min(0, -cropRect.y()); |
152 if (cropRect.x() < 0) | 152 if (cropRect.x() < 0) |
153 dstLeft = -cropRect.x(); | 153 dstLeft = -cropRect.x(); |
154 if (cropRect.y() < 0) | 154 if (cropRect.y() < 0) |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 FloatSize ImageBitmap::elementSize(const FloatSize&) const | 462 FloatSize ImageBitmap::elementSize(const FloatSize&) const |
463 { | 463 { |
464 return FloatSize(width(), height()); | 464 return FloatSize(width(), height()); |
465 } | 465 } |
466 | 466 |
467 DEFINE_TRACE(ImageBitmap) | 467 DEFINE_TRACE(ImageBitmap) |
468 { | 468 { |
469 } | 469 } |
470 | 470 |
471 } // namespace blink | 471 } // namespace blink |
OLD | NEW |