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

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

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix for mac build Created 6 years, 9 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 | Annotate | Revision Log
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/v8/ScriptWrappable.h" 8 #include "bindings/v8/ScriptWrappable.h"
9 #include "core/html/HTMLImageElement.h" 9 #include "core/html/HTMLImageElement.h"
10 #include "core/html/canvas/CanvasImageSource.h"
10 #include "platform/geometry/IntRect.h" 11 #include "platform/geometry/IntRect.h"
11 #include "platform/graphics/Image.h" 12 #include "platform/graphics/Image.h"
12 #include "wtf/PassRefPtr.h" 13 #include "wtf/PassRefPtr.h"
13 #include "wtf/RefCounted.h" 14 #include "wtf/RefCounted.h"
14 15
15 namespace WebCore { 16 namespace WebCore {
16 17
17 class HTMLCanvasElement; 18 class HTMLCanvasElement;
18 class HTMLVideoElement; 19 class HTMLVideoElement;
19 class ImageData; 20 class ImageData;
20 21
21 class ImageBitmap FINAL : public RefCounted<ImageBitmap>, public ScriptWrappable , public ImageLoaderClient { 22 class ImageBitmap FINAL : public RefCounted<ImageBitmap>, public ScriptWrappable , public ImageLoaderClient, public CanvasImageSource {
22 23
23 public: 24 public:
24 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, const IntRect&); 25 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, const IntRect&);
25 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, const IntRect&); 26 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, const IntRect&);
26 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, const IntRect&); 27 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, const IntRect&);
27 static PassRefPtr<ImageBitmap> create(ImageData*, const IntRect&); 28 static PassRefPtr<ImageBitmap> create(ImageData*, const IntRect&);
28 static PassRefPtr<ImageBitmap> create(ImageBitmap*, const IntRect&); 29 static PassRefPtr<ImageBitmap> create(ImageBitmap*, const IntRect&);
29 static PassRefPtr<ImageBitmap> create(Image*, const IntRect&); 30 static PassRefPtr<ImageBitmap> create(Image*, const IntRect&);
30 31
31 PassRefPtr<Image> bitmapImage() const; 32 PassRefPtr<Image> bitmapImage() const;
32 PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; } 33 PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; }
33 34
34 IntRect bitmapRect() const { return m_bitmapRect; } 35 IntRect bitmapRect() const { return m_bitmapRect; }
35 IntPoint bitmapOffset() const { return m_bitmapOffset; } 36 virtual IntPoint bitmapOffset() const { return m_bitmapOffset; }
Stephen White 2014/03/06 16:06:17 Nit: is this still necessary?
36 37
37 int width() const { return m_cropRect.width(); } 38 int width() const { return m_cropRect.width(); }
38 int height() const { return m_cropRect.height(); } 39 int height() const { return m_cropRect.height(); }
39 IntSize size() const { return m_cropRect.size(); } 40 IntSize size() const { return m_cropRect.size(); }
40 41
41 virtual ~ImageBitmap(); 42 virtual ~ImageBitmap();
42 43
44 // CanvasImageSource implementation
45 virtual PassRefPtr<Image> getSourceImageForCanvas(ExceptionState&, CanvasIma geSourceUsage, bool* isVolatile) const OVERRIDE;
46 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE { return false ; };
47 virtual void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const O VERRIDE;
48 virtual FloatSize sourceSize() const OVERRIDE;
49
43 private: 50 private:
44 ImageBitmap(HTMLImageElement*, const IntRect&); 51 ImageBitmap(HTMLImageElement*, const IntRect&);
45 ImageBitmap(HTMLVideoElement*, const IntRect&); 52 ImageBitmap(HTMLVideoElement*, const IntRect&);
46 ImageBitmap(HTMLCanvasElement*, const IntRect&); 53 ImageBitmap(HTMLCanvasElement*, const IntRect&);
47 ImageBitmap(ImageData*, const IntRect&); 54 ImageBitmap(ImageData*, const IntRect&);
48 ImageBitmap(ImageBitmap*, const IntRect&); 55 ImageBitmap(ImageBitmap*, const IntRect&);
49 ImageBitmap(Image*, const IntRect&); 56 ImageBitmap(Image*, const IntRect&);
50 57
51 // ImageLoaderClient 58 // ImageLoaderClient
52 virtual void notifyImageSourceChanged() OVERRIDE; 59 virtual void notifyImageSourceChanged() OVERRIDE;
(...skipping 10 matching lines...) Expand all
63 // The offset by which the desired Image is stored internally. 70 // The offset by which the desired Image is stored internally.
64 // ImageBitmaps constructed from HTMLImageElements reference the entire Imag eResource and may have a non-zero bitmap offset. 71 // ImageBitmaps constructed from HTMLImageElements reference the entire Imag eResource and may have a non-zero bitmap offset.
65 // ImageBitmaps not constructed from HTMLImageElements always pre-crop and s tore the image at (0, 0). 72 // ImageBitmaps not constructed from HTMLImageElements always pre-crop and s tore the image at (0, 0).
66 IntPoint m_bitmapOffset; 73 IntPoint m_bitmapOffset;
67 74
68 }; 75 };
69 76
70 } // namespace WebCore 77 } // namespace WebCore
71 78
72 #endif // ImageBitmap_h 79 #endif // ImageBitmap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698