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

Side by Side Diff: third_party/WebKit/Source/core/frame/ImageBitmap.h

Issue 2035113002: Implement ImageBitmapOptions resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef ImageBitmap_h 5 #ifndef ImageBitmap_h
6 #define ImageBitmap_h 6 #define ImageBitmap_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/html/HTMLImageElement.h" 10 #include "core/html/HTMLImageElement.h"
(...skipping 20 matching lines...) Expand all
31 DontPremultiplyAlpha, 31 DontPremultiplyAlpha,
32 }; 32 };
33 enum DataColorFormat { 33 enum DataColorFormat {
34 RGBAColorType, 34 RGBAColorType,
35 N32ColorType, 35 N32ColorType,
36 }; 36 };
37 37
38 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource { 38 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource {
39 DEFINE_WRAPPERTYPEINFO(); 39 DEFINE_WRAPPERTYPEINFO();
40 public: 40 public:
41 static ImageBitmap* create(HTMLImageElement*, const IntRect&, Document*, con st ImageBitmapOptions& = ImageBitmapOptions()); 41 static ImageBitmap* create(HTMLImageElement*, Optional<IntRect>, Document*, const ImageBitmapOptions& = ImageBitmapOptions());
42 static ImageBitmap* create(HTMLVideoElement*, const IntRect&, Document*, con st ImageBitmapOptions& = ImageBitmapOptions()); 42 static ImageBitmap* create(HTMLVideoElement*, Optional<IntRect>, Document*, const ImageBitmapOptions& = ImageBitmapOptions());
43 static ImageBitmap* create(HTMLCanvasElement*, const IntRect&, const ImageBi tmapOptions& = ImageBitmapOptions()); 43 static ImageBitmap* create(HTMLCanvasElement*, Optional<IntRect>, const Imag eBitmapOptions& = ImageBitmapOptions());
44 static ImageBitmap* create(ImageData*, const IntRect&, const ImageBitmapOpti ons& = ImageBitmapOptions()); 44 static ImageBitmap* create(ImageData*, Optional<IntRect>, const ImageBitmapO ptions& = ImageBitmapOptions());
45 static ImageBitmap* create(ImageBitmap*, const IntRect&, const ImageBitmapOp tions& = ImageBitmapOptions()); 45 static ImageBitmap* create(ImageBitmap*, Optional<IntRect>, const ImageBitma pOptions& = ImageBitmapOptions());
46 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); 46 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>);
47 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, const IntRect&, co nst ImageBitmapOptions& = ImageBitmapOptions()); 47 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, Optional<IntRect>, const ImageBitmapOptions& = ImageBitmapOptions());
48 static ImageBitmap* create(WebExternalTextureMailbox&); 48 static ImageBitmap* create(WebExternalTextureMailbox&);
49 // This function is called by structured-cloning an ImageBitmap. 49 // This function is called by structured-cloning an ImageBitmap.
50 // isImageBitmapPremultiplied indicates whether the original ImageBitmap is premultiplied or not. 50 // isImageBitmapPremultiplied indicates whether the original ImageBitmap is premultiplied or not.
51 // isImageBitmapOriginClean indicates whether the original ImageBitmap is or igin clean or not. 51 // isImageBitmapOriginClean indicates whether the original ImageBitmap is or igin clean or not.
52 static ImageBitmap* create(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean) ; 52 static ImageBitmap* create(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean) ;
53 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode r>); 53 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode r>);
54 static bool isResizeOptionValid(const ImageBitmapOptions&, ExceptionState&);
55 static bool isSourceSizeValid(int sourceWidth, int sourceHeight, ExceptionSt ate&);
54 56
55 // Type and helper function required by CallbackPromiseAdapter: 57 // Type and helper function required by CallbackPromiseAdapter:
56 using WebType = sk_sp<SkImage>; 58 using WebType = sk_sp<SkImage>;
57 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>); 59 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>);
58 60
59 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() : nullptr; } 61 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() : nullptr; }
60 std::unique_ptr<uint8_t[]> copyBitmapData(AlphaDisposition alphaOp = DontPre multiplyAlpha, DataColorFormat format = RGBAColorType); 62 std::unique_ptr<uint8_t[]> copyBitmapData(AlphaDisposition alphaOp = DontPre multiplyAlpha, DataColorFormat format = RGBAColorType);
61 unsigned long width() const; 63 unsigned long width() const;
62 unsigned long height() const; 64 unsigned long height() const;
63 IntSize size() const; 65 IntSize size() const;
(...skipping 11 matching lines...) Expand all
75 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi nt, SnapshotReason, const FloatSize&) const override; 77 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi nt, SnapshotReason, const FloatSize&) const override;
76 bool wouldTaintOrigin(SecurityOrigin*) const override { return !m_image->ori ginClean(); } 78 bool wouldTaintOrigin(SecurityOrigin*) const override { return !m_image->ori ginClean(); }
77 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override; 79 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override;
78 FloatSize elementSize(const FloatSize&) const override; 80 FloatSize elementSize(const FloatSize&) const override;
79 bool isImageBitmap() const override { return true; } 81 bool isImageBitmap() const override { return true; }
80 int sourceWidth() override { return m_image ? m_image->width() : 0; } 82 int sourceWidth() override { return m_image ? m_image->width() : 0; }
81 int sourceHeight() override { return m_image ? m_image->height() : 0; } 83 int sourceHeight() override { return m_image ? m_image->height() : 0; }
82 84
83 // ImageBitmapSource implementation 85 // ImageBitmapSource implementation
84 IntSize bitmapSourceSize() const override { return size(); } 86 IntSize bitmapSourceSize() const override { return size(); }
85 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy, int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; 87 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, Optional<IntRect >, const ImageBitmapOptions&, ExceptionState&) override;
86 88
87 DECLARE_VIRTUAL_TRACE(); 89 DECLARE_VIRTUAL_TRACE();
88 90
89 private: 91 private:
90 ImageBitmap(HTMLImageElement*, const IntRect&, Document*, const ImageBitmapO ptions&); 92 ImageBitmap(HTMLImageElement*, Optional<IntRect>, Document*, const ImageBitm apOptions&);
91 ImageBitmap(HTMLVideoElement*, const IntRect&, Document*, const ImageBitmapO ptions&); 93 ImageBitmap(HTMLVideoElement*, Optional<IntRect>, Document*, const ImageBitm apOptions&);
92 ImageBitmap(HTMLCanvasElement*, const IntRect&, const ImageBitmapOptions&); 94 ImageBitmap(HTMLCanvasElement*, Optional<IntRect>, const ImageBitmapOptions& );
93 ImageBitmap(ImageData*, const IntRect&, const ImageBitmapOptions&); 95 ImageBitmap(ImageData*, Optional<IntRect>, const ImageBitmapOptions&);
94 ImageBitmap(ImageBitmap*, const IntRect&, const ImageBitmapOptions&); 96 ImageBitmap(ImageBitmap*, Optional<IntRect>, const ImageBitmapOptions&);
95 ImageBitmap(PassRefPtr<StaticBitmapImage>); 97 ImageBitmap(PassRefPtr<StaticBitmapImage>);
96 ImageBitmap(PassRefPtr<StaticBitmapImage>, const IntRect&, const ImageBitmap Options&); 98 ImageBitmap(PassRefPtr<StaticBitmapImage>, Optional<IntRect>, const ImageBit mapOptions&);
97 ImageBitmap(WebExternalTextureMailbox&); 99 ImageBitmap(WebExternalTextureMailbox&);
98 ImageBitmap(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height , bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean); 100 ImageBitmap(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height , bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean);
99 101
100 void parseOptions(const ImageBitmapOptions&, bool&, bool&);
101
102 RefPtr<StaticBitmapImage> m_image; 102 RefPtr<StaticBitmapImage> m_image;
103 bool m_isNeutered = false; 103 bool m_isNeutered = false;
104 }; 104 };
105 105
106 } // namespace blink 106 } // namespace blink
107 107
108 #endif // ImageBitmap_h 108 #endif // ImageBitmap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698