Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/modules/imagebitmap/ImageBitmapRenderingContext.cpp

Issue 1732563007: [NOT FOR COMMIT] Pass defaultObjectSize to get image size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/frame/ImageBitmap.h" 7 #include "core/frame/ImageBitmap.h"
8 #include "platform/graphics/GraphicsContext.h" 8 #include "platform/graphics/GraphicsContext.h"
9 #include "platform/graphics/StaticBitmapImage.h" 9 #include "platform/graphics/StaticBitmapImage.h"
10 #include "third_party/skia/include/core/SkImage.h" 10 #include "third_party/skia/include/core/SkImage.h"
(...skipping 19 matching lines...) Expand all
30 // TODO(junov): crbug.com/585607 Eliminate this readback and use an Exte rnalTextureLayer 30 // 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())); 31 RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(skIma ge->width(), skImage->height()));
32 if (!surface) { 32 if (!surface) {
33 // silent failure 33 // silent failure
34 m_image.clear(); 34 m_image.clear();
35 return; 35 return;
36 } 36 }
37 surface->getCanvas()->drawImage(skImage.get(), 0, 0); 37 surface->getCanvas()->drawImage(skImage.get(), 0, 0);
38 m_image = StaticBitmapImage::create(adoptRef(surface->newImageSnapshot() )); 38 m_image = StaticBitmapImage::create(adoptRef(surface->newImageSnapshot() ));
39 } 39 }
40 canvas()->didDraw(FloatRect(FloatPoint(), FloatSize(m_image->width(), m_imag e->height()))); 40 canvas()->didDraw(FloatRect(FloatPoint(), FloatSize(m_image->defaultConcrete ObjectSizeWidth(), m_image->defaultConcreteObjectSizeHeight())));
41 } 41 }
42 42
43 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r) 43 bool ImageBitmapRenderingContext::paint(GraphicsContext& gc, const IntRect& r)
44 { 44 {
45 if (!m_image) 45 if (!m_image)
46 return true; 46 return true;
47 47
48 // With impl-side painting, it is unsafe to use a gpu-backed SkImage 48 // With impl-side painting, it is unsafe to use a gpu-backed SkImage
49 ASSERT(!m_image->imageForCurrentFrame()->isTextureBacked()); 49 ASSERT(!m_image->imageForCurrentFrame()->isTextureBacked());
50 gc.drawImage(m_image.get(), r, m_hasAlpha ? SkXfermode::kSrcOver_Mode : SkXf ermode::kSrc_Mode); 50 gc.drawImage(m_image.get(), r, m_hasAlpha ? SkXfermode::kSrcOver_Mode : SkXf ermode::kSrc_Mode);
51 51
52 return true; 52 return true;
53 } 53 }
54 54
55 PassOwnPtrWillBeRawPtr<CanvasRenderingContext> ImageBitmapRenderingContext::Fact ory::create(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& at trs, Document& document) 55 PassOwnPtrWillBeRawPtr<CanvasRenderingContext> ImageBitmapRenderingContext::Fact ory::create(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& at trs, Document& document)
56 { 56 {
57 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) 57 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled())
58 return nullptr; 58 return nullptr;
59 return adoptPtrWillBeNoop(new ImageBitmapRenderingContext(canvas, attrs, doc ument)); 59 return adoptPtrWillBeNoop(new ImageBitmapRenderingContext(canvas, attrs, doc ument));
60 } 60 }
61 61
62 void ImageBitmapRenderingContext::stop() 62 void ImageBitmapRenderingContext::stop()
63 { 63 {
64 m_image.clear(); 64 m_image.clear();
65 } 65 }
66 66
67 } // blink 67 } // blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698