| 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 "core/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/StaticBitmapImage.h" | 10 #include "platform/graphics/StaticBitmapImage.h" |
| 10 #include "third_party/skia/include/core/SkImage.h" | 11 #include "third_party/skia/include/core/SkImage.h" |
| 11 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 ImageBitmapRenderingContext::ImageBitmapRenderingContext(HTMLCanvasElement* canv
as, CanvasContextCreationAttributes attrs, Document& document) | 16 ImageBitmapRenderingContext::ImageBitmapRenderingContext(HTMLCanvasElement* canv
as, CanvasContextCreationAttributes attrs, Document& document) |
| 16 : CanvasRenderingContext(canvas) | 17 : CanvasRenderingContext(canvas) |
| 17 , m_hasAlpha(attrs.alpha()) | 18 , m_hasAlpha(attrs.alpha()) |
| 18 { } | 19 { } |
| 19 | 20 |
| 20 ImageBitmapRenderingContext::~ImageBitmapRenderingContext() { } | 21 ImageBitmapRenderingContext::~ImageBitmapRenderingContext() { } |
| 21 | 22 |
| 23 void ImageBitmapRenderingContext::setCanvasGetContextResult(RenderingContext& re
sult) |
| 24 { |
| 25 result.setImageBitmapRenderingContext(PassRefPtrWillBeRawPtr<ImageBitmapRend
eringContext>(this)); |
| 26 } |
| 27 |
| 22 void ImageBitmapRenderingContext::transferImageBitmap(ImageBitmap* imageBitmap) | 28 void ImageBitmapRenderingContext::transferImageBitmap(ImageBitmap* imageBitmap) |
| 23 { | 29 { |
| 24 m_image = imageBitmap->bitmapImage(); | 30 m_image = imageBitmap->bitmapImage(); |
| 25 if (!m_image) | 31 if (!m_image) |
| 26 return; | 32 return; |
| 27 | 33 |
| 28 RefPtr<SkImage> skImage = m_image->imageForCurrentFrame(); | 34 RefPtr<SkImage> skImage = m_image->imageForCurrentFrame(); |
| 29 if (skImage->isTextureBacked()) { | 35 if (skImage->isTextureBacked()) { |
| 30 // 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 |
| 31 RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(skIma
ge->width(), skImage->height())); | 37 RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(skIma
ge->width(), skImage->height())); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 return nullptr; | 64 return nullptr; |
| 59 return adoptPtrWillBeNoop(new ImageBitmapRenderingContext(canvas, attrs, doc
ument)); | 65 return adoptPtrWillBeNoop(new ImageBitmapRenderingContext(canvas, attrs, doc
ument)); |
| 60 } | 66 } |
| 61 | 67 |
| 62 void ImageBitmapRenderingContext::stop() | 68 void ImageBitmapRenderingContext::stop() |
| 63 { | 69 { |
| 64 m_image.clear(); | 70 m_image.clear(); |
| 65 } | 71 } |
| 66 | 72 |
| 67 } // blink | 73 } // blink |
| OLD | NEW |