| 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" |
| 11 #include "third_party/skia/include/core/SkImage.h" | 11 #include "third_party/skia/include/core/SkImage.h" |
| 12 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 ImageBitmapRenderingContext::ImageBitmapRenderingContext(HTMLCanvasElement* canv
as, CanvasContextCreationAttributes attrs, Document& document) | 16 ImageBitmapRenderingContext::ImageBitmapRenderingContext(HTMLCanvasElement* canv
as, const CanvasContextCreationAttributes& attrs, Document& document) |
| 17 : CanvasRenderingContext(canvas) | 17 : CanvasRenderingContext(canvas, nullptr, attrs) |
| 18 , m_hasAlpha(attrs.alpha()) | |
| 19 { } | 18 { } |
| 20 | 19 |
| 21 ImageBitmapRenderingContext::~ImageBitmapRenderingContext() { } | 20 ImageBitmapRenderingContext::~ImageBitmapRenderingContext() { } |
| 22 | 21 |
| 23 void ImageBitmapRenderingContext::setCanvasGetContextResult(RenderingContext& re
sult) | 22 void ImageBitmapRenderingContext::setCanvasGetContextResult(RenderingContext& re
sult) |
| 24 { | 23 { |
| 25 result.setImageBitmapRenderingContext(this); | 24 result.setImageBitmapRenderingContext(this); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void ImageBitmapRenderingContext::transferFromImageBitmap(ImageBitmap* imageBitm
ap) | 27 void ImageBitmapRenderingContext::transferFromImageBitmap(ImageBitmap* imageBitm
ap) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 46 canvas()->didDraw(FloatRect(FloatPoint(), FloatSize(m_image->width(), m_imag
e->height()))); | 45 canvas()->didDraw(FloatRect(FloatPoint(), FloatSize(m_image->width(), m_imag
e->height()))); |
| 47 } | 46 } |
| 48 | 47 |
| 49 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r) | 48 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r) |
| 50 { | 49 { |
| 51 if (!m_image) | 50 if (!m_image) |
| 52 return true; | 51 return true; |
| 53 | 52 |
| 54 // With impl-side painting, it is unsafe to use a gpu-backed SkImage | 53 // With impl-side painting, it is unsafe to use a gpu-backed SkImage |
| 55 ASSERT(!m_image->imageForCurrentFrame()->isTextureBacked()); | 54 ASSERT(!m_image->imageForCurrentFrame()->isTextureBacked()); |
| 56 gc.drawImage(m_image.get(), r, nullptr, m_hasAlpha ? SkXfermode::kSrcOver_Mo
de : SkXfermode::kSrc_Mode); | 55 gc.drawImage(m_image.get(), r, nullptr, creationAttributes().alpha() ? SkXfe
rmode::kSrcOver_Mode : SkXfermode::kSrc_Mode); |
| 57 | 56 |
| 58 return true; | 57 return true; |
| 59 } | 58 } |
| 60 | 59 |
| 61 CanvasRenderingContext* ImageBitmapRenderingContext::Factory::create(HTMLCanvasE
lement* canvas, const CanvasContextCreationAttributes& attrs, Document& document
) | 60 CanvasRenderingContext* ImageBitmapRenderingContext::Factory::create(HTMLCanvasE
lement* canvas, const CanvasContextCreationAttributes& attrs, Document& document
) |
| 62 { | 61 { |
| 63 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) | 62 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) |
| 64 return nullptr; | 63 return nullptr; |
| 65 return new ImageBitmapRenderingContext(canvas, attrs, document); | 64 return new ImageBitmapRenderingContext(canvas, attrs, document); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void ImageBitmapRenderingContext::stop() | 67 void ImageBitmapRenderingContext::stop() |
| 69 { | 68 { |
| 70 m_image.clear(); | 69 m_image.clear(); |
| 71 } | 70 } |
| 72 | 71 |
| 73 } // blink | 72 } // blink |
| OLD | NEW |