| 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/RenderingContext.h" | 7 #include "bindings/modules/v8/RenderingContext.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 21 matching lines...) Expand all Loading... |
| 32 m_image.release(); | 32 m_image.release(); |
| 33 return; | 33 return; |
| 34 } | 34 } |
| 35 | 35 |
| 36 m_image = imageBitmap->bitmapImage(); | 36 m_image = imageBitmap->bitmapImage(); |
| 37 if (!m_image) | 37 if (!m_image) |
| 38 return; | 38 return; |
| 39 | 39 |
| 40 sk_sp<SkImage> skImage = m_image->imageForCurrentFrame(); | 40 sk_sp<SkImage> skImage = m_image->imageForCurrentFrame(); |
| 41 if (skImage->isTextureBacked()) { | 41 if (skImage->isTextureBacked()) { |
| 42 // TODO(junov): crbug.com/585607 Eliminate this readback and use an External
TextureLayer | 42 // TODO(junov): crbug.com/585607 Eliminate this readback and use an |
| 43 // ExternalTextureLayer |
| 43 sk_sp<SkSurface> surface = | 44 sk_sp<SkSurface> surface = |
| 44 SkSurface::MakeRasterN32Premul(skImage->width(), skImage->height()); | 45 SkSurface::MakeRasterN32Premul(skImage->width(), skImage->height()); |
| 45 if (!surface) { | 46 if (!surface) { |
| 46 // silent failure | 47 // silent failure |
| 47 m_image.clear(); | 48 m_image.clear(); |
| 48 return; | 49 return; |
| 49 } | 50 } |
| 50 surface->getCanvas()->drawImage(skImage, 0, 0); | 51 surface->getCanvas()->drawImage(skImage, 0, 0); |
| 51 m_image = StaticBitmapImage::create(surface->makeImageSnapshot()); | 52 m_image = StaticBitmapImage::create(surface->makeImageSnapshot()); |
| 52 } | 53 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 74 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) | 75 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) |
| 75 return nullptr; | 76 return nullptr; |
| 76 return new ImageBitmapRenderingContext(canvas, attrs, document); | 77 return new ImageBitmapRenderingContext(canvas, attrs, document); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void ImageBitmapRenderingContext::stop() { | 80 void ImageBitmapRenderingContext::stop() { |
| 80 m_image.clear(); | 81 m_image.clear(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // blink | 84 } // blink |
| OLD | NEW |