| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r) { | 70 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r) { |
| 71 if (!m_image) | 71 if (!m_image) |
| 72 return true; | 72 return true; |
| 73 | 73 |
| 74 // With impl-side painting, it is unsafe to use a gpu-backed SkImage | 74 // With impl-side painting, it is unsafe to use a gpu-backed SkImage |
| 75 DCHECK( | 75 DCHECK( |
| 76 !m_image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()) | 76 !m_image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()) |
| 77 ->isTextureBacked()); | 77 ->isTextureBacked()); |
| 78 gc.drawImage(m_image.get(), r, nullptr, creationAttributes().alpha() | 78 gc.drawImage( |
| 79 ? SkBlendMode::kSrcOver | 79 m_image.get(), r, nullptr, |
| 80 : SkBlendMode::kSrc); | 80 creationAttributes().alpha() ? SkBlendMode::kSrcOver : SkBlendMode::kSrc); |
| 81 | 81 |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 CanvasRenderingContext* ImageBitmapRenderingContext::Factory::create( | 85 CanvasRenderingContext* ImageBitmapRenderingContext::Factory::create( |
| 86 HTMLCanvasElement* canvas, | 86 HTMLCanvasElement* canvas, |
| 87 const CanvasContextCreationAttributes& attrs, | 87 const CanvasContextCreationAttributes& attrs, |
| 88 Document& document) { | 88 Document& document) { |
| 89 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) | 89 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) |
| 90 return nullptr; | 90 return nullptr; |
| 91 return new ImageBitmapRenderingContext(canvas, attrs, document); | 91 return new ImageBitmapRenderingContext(canvas, attrs, document); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void ImageBitmapRenderingContext::stop() { | 94 void ImageBitmapRenderingContext::stop() { |
| 95 m_image.clear(); | 95 m_image.clear(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // blink | 98 } // blink |
| OLD | NEW |