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 "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(PassRefPtr<StaticBitmapI
mage> image) | 165 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(PassRefPtr<StaticBitmapI
mage> image) |
166 { | 166 { |
167 return adoptRefWillBeNoop(new ImageBitmap(image)); | 167 return adoptRefWillBeNoop(new ImageBitmap(image)); |
168 } | 168 } |
169 | 169 |
170 PassOwnPtr<uint8_t[]> ImageBitmap::copyBitmapData() | 170 PassOwnPtr<uint8_t[]> ImageBitmap::copyBitmapData() |
171 { | 171 { |
172 SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorTy
pe, kUnpremul_SkAlphaType); | 172 SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorTy
pe, kUnpremul_SkAlphaType); |
173 OwnPtr<uint8_t[]> dstPixels = adoptArrayPtr(new uint8_t[width() * height() *
info.bytesPerPixel()]); | 173 OwnPtr<uint8_t[]> dstPixels = adoptArrayPtr(new uint8_t[width() * height() *
info.bytesPerPixel()]); |
174 size_t dstRowBytes = 4 * width(); | 174 size_t dstRowBytes = info.bytesPerPixel() * width(); |
175 m_image->imageForCurrentFrame()->readPixels(info, dstPixels.get(), dstRowByt
es, 0, 0); | 175 m_image->imageForCurrentFrame()->readPixels(info, dstPixels.get(), dstRowByt
es, 0, 0); |
176 return dstPixels.release(); | 176 return dstPixels.release(); |
177 } | 177 } |
178 | 178 |
179 unsigned long ImageBitmap::width() const | 179 unsigned long ImageBitmap::width() const |
180 { | 180 { |
181 if (!m_image) | 181 if (!m_image) |
182 return 0; | 182 return 0; |
183 ASSERT(m_image->width() > 0); | 183 ASSERT(m_image->width() > 0); |
184 return m_image->width(); | 184 return m_image->width(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 { | 227 { |
228 return FloatSize(width(), height()); | 228 return FloatSize(width(), height()); |
229 } | 229 } |
230 | 230 |
231 DEFINE_TRACE(ImageBitmap) | 231 DEFINE_TRACE(ImageBitmap) |
232 { | 232 { |
233 ImageLoaderClient::trace(visitor); | 233 ImageLoaderClient::trace(visitor); |
234 } | 234 } |
235 | 235 |
236 } // namespace blink | 236 } // namespace blink |
OLD | NEW |