Chromium Code Reviews| 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, CanvasContextCreationAttributes attrs, Document& document) |
| 17 : CanvasRenderingContext(canvas) | 17 : CanvasRenderingContext(canvas) |
| 18 , m_hasAlpha(attrs.alpha()) | 18 , m_hasAlpha(attrs.alpha()) |
| 19 { } | 19 { } |
| 20 | 20 |
| 21 ImageBitmapRenderingContext::~ImageBitmapRenderingContext() { } | 21 ImageBitmapRenderingContext::~ImageBitmapRenderingContext() { } |
| 22 | 22 |
| 23 void ImageBitmapRenderingContext::setCanvasGetContextResult(RenderingContext& re sult) | 23 void ImageBitmapRenderingContext::setCanvasGetContextResult(RenderingContext& re sult) |
| 24 { | 24 { |
| 25 result.setImageBitmapRenderingContext(this); | 25 result.setImageBitmapRenderingContext(this); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ImageBitmapRenderingContext::transferFromImageBitmap(ImageBitmap* imageBitm ap) | 28 void ImageBitmapRenderingContext::transferFromImageBitmap(ImageBitmap* imageBitm ap) |
| 29 { | 29 { |
| 30 if (!imageBitmap) | |
| 31 return; | |
|
Justin Novosad
2016/08/16 19:38:55
This is not the correct behavior. Passing null is
zakerinasab
2016/08/16 20:34:49
Done.
| |
| 32 | |
| 30 m_image = imageBitmap->bitmapImage(); | 33 m_image = imageBitmap->bitmapImage(); |
| 31 if (!m_image) | 34 if (!m_image) |
| 32 return; | 35 return; |
| 33 | 36 |
| 34 RefPtr<SkImage> skImage = m_image->imageForCurrentFrame(); | 37 RefPtr<SkImage> skImage = m_image->imageForCurrentFrame(); |
| 35 if (skImage->isTextureBacked()) { | 38 if (skImage->isTextureBacked()) { |
| 36 // TODO(junov): crbug.com/585607 Eliminate this readback and use an Exte rnalTextureLayer | 39 // TODO(junov): crbug.com/585607 Eliminate this readback and use an Exte rnalTextureLayer |
| 37 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(skImage->width (), skImage->height()); | 40 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(skImage->width (), skImage->height()); |
| 38 if (!surface) { | 41 if (!surface) { |
| 39 // silent failure | 42 // silent failure |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 64 return nullptr; | 67 return nullptr; |
| 65 return new ImageBitmapRenderingContext(canvas, attrs, document); | 68 return new ImageBitmapRenderingContext(canvas, attrs, document); |
| 66 } | 69 } |
| 67 | 70 |
| 68 void ImageBitmapRenderingContext::stop() | 71 void ImageBitmapRenderingContext::stop() |
| 69 { | 72 { |
| 70 m_image.clear(); | 73 m_image.clear(); |
| 71 } | 74 } |
| 72 | 75 |
| 73 } // blink | 76 } // blink |
| OLD | NEW |