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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 sk_sp<SkSurface> surface = | 55 sk_sp<SkSurface> surface = |
56 SkSurface::MakeRasterN32Premul(skImage->width(), skImage->height()); | 56 SkSurface::MakeRasterN32Premul(skImage->width(), skImage->height()); |
57 if (!surface) { | 57 if (!surface) { |
58 // silent failure | 58 // silent failure |
59 m_image.clear(); | 59 m_image.clear(); |
60 return; | 60 return; |
61 } | 61 } |
62 surface->getCanvas()->drawImage(skImage, 0, 0); | 62 surface->getCanvas()->drawImage(skImage, 0, 0); |
63 m_image = StaticBitmapImage::create(surface->makeImageSnapshot()); | 63 m_image = StaticBitmapImage::create(surface->makeImageSnapshot()); |
64 } | 64 } |
65 canvas()->didDraw( | 65 didDraw(skImage->bounds()); |
66 FloatRect(FloatPoint(), FloatSize(m_image->width(), m_image->height()))); | |
67 imageBitmap->close(); | 66 imageBitmap->close(); |
68 } | 67 } |
69 | 68 |
70 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r) { | 69 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r) { |
71 if (!m_image) | 70 if (!m_image) |
72 return true; | 71 return true; |
73 | 72 |
74 // With impl-side painting, it is unsafe to use a gpu-backed SkImage | 73 // With impl-side painting, it is unsafe to use a gpu-backed SkImage |
75 DCHECK( | 74 DCHECK( |
76 !m_image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()) | 75 !m_image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()) |
(...skipping 12 matching lines...) Expand all Loading... |
89 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) | 88 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) |
90 return nullptr; | 89 return nullptr; |
91 return new ImageBitmapRenderingContext(canvas, attrs, document); | 90 return new ImageBitmapRenderingContext(canvas, attrs, document); |
92 } | 91 } |
93 | 92 |
94 void ImageBitmapRenderingContext::stop() { | 93 void ImageBitmapRenderingContext::stop() { |
95 m_image.clear(); | 94 m_image.clear(); |
96 } | 95 } |
97 | 96 |
98 } // blink | 97 } // blink |
OLD | NEW |