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

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

Issue 20748002: Blob creation methods for ImageBitmap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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/dom/ScriptExecutionContext.h" 9 #include "core/fileapi/FileReaderLoader.h"
10 #include "core/fileapi/FileReaderLoaderClient.h"
11 #include "core/loader/cache/CachedImage.h"
12 #include "core/loader/cache/CachedImageClient.h"
13 #include "core/loader/cache/CachedResourceHandle.h"
14 #include "core/page/DOMWindow.h"
15 #include "core/page/ImageBitmapCallback.h"
10 #include "core/platform/graphics/BitmapImage.h" 16 #include "core/platform/graphics/BitmapImage.h"
11 #include "core/platform/graphics/ImageBuffer.h" 17 #include "core/platform/graphics/ImageBuffer.h"
12 #include "core/platform/graphics/IntRect.h" 18 #include "core/platform/graphics/IntRect.h"
13 #include "wtf/PassRefPtr.h" 19 #include "wtf/PassRefPtr.h"
14 #include "wtf/RefCounted.h" 20 #include "wtf/RefCounted.h"
15 21
16 namespace WebCore { 22 namespace WebCore {
17 23
24 class Blob;
25 class FileError;
18 class HTMLCanvasElement; 26 class HTMLCanvasElement;
19 class HTMLImageElement; 27 class HTMLImageElement;
20 class HTMLVideoElement; 28 class HTMLVideoElement;
21 class ImageData; 29 class ImageData;
22 class ImageBitmapCallback; 30 class ImageBitmapCallback;
23 31
24 class ImageBitmap : public RefCounted<ImageBitmap>, public ScriptWrappable { 32 class ImageBitmap : public RefCounted<ImageBitmap>, public FileReaderLoaderClien t, public CachedImageClient, public ScriptWrappable {
25 33
26 public: 34 public:
27 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, IntRect); 35 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, IntRect);
28 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, IntRect); 36 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, IntRect);
29 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, IntRect); 37 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, IntRect);
30 static PassRefPtr<ImageBitmap> create(ImageData*, IntRect); 38 static PassRefPtr<ImageBitmap> create(ImageData*, IntRect);
39 static PassRefPtr<ImageBitmap> create(DOMWindow*, PassRefPtr<ImageBitmapCall back>, Blob*, IntRect);
31 static PassRefPtr<ImageBitmap> create(ImageBitmap*, IntRect); 40 static PassRefPtr<ImageBitmap> create(ImageBitmap*, IntRect);
32 41
33 BitmapImage* bitmapImage() const { return m_bitmap.get(); } 42 ~ImageBitmap();
43
44 Image* bitmapImage() const { return m_bitmap.get(); }
34 45
35 int bitmapWidth() const { return m_bitmap->width(); } 46 int bitmapWidth() const { return m_bitmap->width(); }
36 int bitmapHeight() const { return m_bitmap->height(); } 47 int bitmapHeight() const { return m_bitmap->height(); }
37 IntSize bitmapSize() const { return m_bitmap->size(); } 48 IntSize bitmapSize() const { return m_bitmap->size(); }
38 IntPoint bitmapOffset() const { return m_bitmapOffset; } 49 IntPoint bitmapOffset() const { return m_bitmapOffset; }
39 50
40 int width() const { return m_size.width(); } 51 int width() const { return m_cropRect.width(); }
41 int height() const { return m_size.height(); } 52 int height() const { return m_cropRect.height(); }
42 IntSize size() const { return m_size; } 53 IntSize size() const { return m_cropRect.size(); }
43 54
44 ~ImageBitmap() { };
45 55
46 private: 56 private:
47 ImageBitmap(HTMLImageElement*, IntRect); 57 ImageBitmap(HTMLImageElement*, IntRect);
48 ImageBitmap(HTMLVideoElement*, IntRect); 58 ImageBitmap(HTMLVideoElement*, IntRect);
49 ImageBitmap(HTMLCanvasElement*, IntRect); 59 ImageBitmap(HTMLCanvasElement*, IntRect);
60 ImageBitmap(DOMWindow*, PassRefPtr<ImageBitmapCallback>, Blob*, IntRect);
50 ImageBitmap(ImageData*, IntRect); 61 ImageBitmap(ImageData*, IntRect);
51 ImageBitmap(ImageBitmap*, IntRect); 62 ImageBitmap(ImageBitmap*, IntRect);
52 63
53 RefPtr<BitmapImage> m_bitmap; 64 // FileReaderLoaderClient
65 virtual void didStartLoading() { }
66 virtual void didReceiveData() { }
67 virtual void didFinishLoading();
68 virtual void didFail(FileError::ErrorCode);
69
70 // CachedImageClient
71 virtual void notifyFinished(CachedResource*);
72
73 CachedResourceHandle<CachedImage> m_pendingCachedImage;
74 RefPtr<Image> m_bitmap;
54 OwnPtr<ImageBuffer> m_buffer; 75 OwnPtr<ImageBuffer> m_buffer;
55 76 OwnPtr<FileReaderLoader> m_loader;
77 RefPtr<ImageBitmapCallback> m_callback;
78 DOMWindow* m_window;
56 IntPoint m_bitmapOffset; // offset applied to the image when it is drawn to the context 79 IntPoint m_bitmapOffset; // offset applied to the image when it is drawn to the context
57 IntSize m_size; // user defined size of the ImageBitmap 80 IntRect m_cropRect;
58 }; 81 };
59 82
60 } // namespace WebCore 83 } // namespace WebCore
61 84
62 #endif // ImageBitmap_h 85 #endif // ImageBitmap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698