OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/imagebitmap/ImageBitmapRenderingContext.h" | 5 #include "modules/imagebitmap/ImageBitmapRenderingContext.h" |
6 | 6 |
7 #include "bindings/modules/v8/UnionTypesModules.h" | 7 #include "bindings/modules/v8/UnionTypesModules.h" |
8 #include "core/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
10 #include "platform/graphics/StaticBitmapImage.h" | 10 #include "platform/graphics/StaticBitmapImage.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 void ImageBitmapRenderingContext::transferImageBitmap(ImageBitmap* imageBitmap) | 28 void ImageBitmapRenderingContext::transferImageBitmap(ImageBitmap* imageBitmap) |
29 { | 29 { |
30 m_image = imageBitmap->bitmapImage(); | 30 m_image = imageBitmap->bitmapImage(); |
31 if (!m_image) | 31 if (!m_image) |
32 return; | 32 return; |
33 | 33 |
34 RefPtr<SkImage> skImage = m_image->imageForCurrentFrame(); | 34 RefPtr<SkImage> skImage = m_image->imageForCurrentFrame(); |
35 if (skImage->isTextureBacked()) { | 35 if (skImage->isTextureBacked()) { |
36 // TODO(junov): crbug.com/585607 Eliminate this readback and use an Exte
rnalTextureLayer | 36 // TODO(junov): crbug.com/585607 Eliminate this readback and use an Exte
rnalTextureLayer |
37 RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(skIma
ge->width(), skImage->height())); | 37 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(skImage->width
(), skImage->height()); |
38 if (!surface) { | 38 if (!surface) { |
39 // silent failure | 39 // silent failure |
40 m_image.clear(); | 40 m_image.clear(); |
41 return; | 41 return; |
42 } | 42 } |
43 surface->getCanvas()->drawImage(skImage.get(), 0, 0); | 43 surface->getCanvas()->drawImage(skImage.get(), 0, 0); |
44 m_image = StaticBitmapImage::create(adoptRef(surface->newImageSnapshot()
)); | 44 m_image = StaticBitmapImage::create(adoptRef(surface->newImageSnapshot()
)); |
45 } | 45 } |
46 canvas()->didDraw(FloatRect(FloatPoint(), FloatSize(m_image->width(), m_imag
e->height()))); | 46 canvas()->didDraw(FloatRect(FloatPoint(), FloatSize(m_image->width(), m_imag
e->height()))); |
47 } | 47 } |
(...skipping 16 matching lines...) Expand all Loading... |
64 return nullptr; | 64 return nullptr; |
65 return new ImageBitmapRenderingContext(canvas, attrs, document); | 65 return new ImageBitmapRenderingContext(canvas, attrs, document); |
66 } | 66 } |
67 | 67 |
68 void ImageBitmapRenderingContext::stop() | 68 void ImageBitmapRenderingContext::stop() |
69 { | 69 { |
70 m_image.clear(); | 70 m_image.clear(); |
71 } | 71 } |
72 | 72 |
73 } // blink | 73 } // blink |
OLD | NEW |