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

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

Issue 19705006: Use SkImage as a backing store for copying 2d Contexts to ImageBitmaps. Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | 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/dom/ScriptExecutionContext.h"
10 #include "core/platform/graphics/BitmapImage.h" 10 #include "core/platform/graphics/BitmapImage.h"
11 #include "core/platform/graphics/ImageBuffer.h" 11 #include "core/platform/graphics/ImageBuffer.h"
12 #include "core/platform/graphics/IntRect.h" 12 #include "core/platform/graphics/IntRect.h"
13 #include "wtf/PassRefPtr.h" 13 #include "wtf/PassRefPtr.h"
14 #include "wtf/RefCounted.h" 14 #include "wtf/RefCounted.h"
15 15
16 class SkImage;
17
16 namespace WebCore { 18 namespace WebCore {
17 19
18 class HTMLCanvasElement; 20 class HTMLCanvasElement;
19 class HTMLImageElement; 21 class HTMLImageElement;
20 class HTMLVideoElement; 22 class HTMLVideoElement;
21 class ImageData; 23 class ImageData;
22 class ImageBitmapCallback; 24 class ImageBitmapCallback;
23 25
24 class ImageBitmap : public RefCounted<ImageBitmap>, public ScriptWrappable { 26 class ImageBitmap : public RefCounted<ImageBitmap>, public ScriptWrappable {
25 27
26 public: 28 public:
27 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, IntRect); 29 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, IntRect);
28 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, IntRect); 30 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, IntRect);
29 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, IntRect); 31 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, IntRect);
30 static PassRefPtr<ImageBitmap> create(ImageData*, IntRect); 32 static PassRefPtr<ImageBitmap> create(ImageData*, IntRect);
31 static PassRefPtr<ImageBitmap> create(ImageBitmap*, IntRect); 33 static PassRefPtr<ImageBitmap> create(ImageBitmap*, IntRect);
32 34
33 BitmapImage* bitmapImage() const { return m_bitmap.get(); } 35 PassRefPtr<Image> bitmapImage() const { return m_bitmap; }
36 SkImage* canvasImage() const { return m_canvasImage; }
34 37
35 int bitmapWidth() const { return m_bitmap->width(); } 38 int bitmapWidth() const { return m_bitmapSize.width(); }
36 int bitmapHeight() const { return m_bitmap->height(); } 39 int bitmapHeight() const { return m_bitmapSize.height(); }
37 IntSize bitmapSize() const { return m_bitmap->size(); } 40 IntSize bitmapSize() const { return m_bitmapSize; }
38 IntPoint bitmapOffset() const { return m_bitmapOffset; } 41 IntPoint bitmapOffset() const { return m_bitmapOffset; }
39 42
40 int width() const { return m_size.width(); } 43 int width() const { return m_cropRect.width(); }
41 int height() const { return m_size.height(); } 44 int height() const { return m_cropRect.height(); }
42 IntSize size() const { return m_size; } 45 IntSize size() const { return m_cropRect.size(); }
46 IntRect cropRect() const { return m_cropRect; }
43 47
44 ~ImageBitmap() { }; 48 ~ImageBitmap() { };
45 49
46 private: 50 private:
47 ImageBitmap(HTMLImageElement*, IntRect); 51 ImageBitmap(HTMLImageElement*, IntRect);
48 ImageBitmap(HTMLVideoElement*, IntRect); 52 ImageBitmap(HTMLVideoElement*, IntRect);
49 ImageBitmap(HTMLCanvasElement*, IntRect); 53 ImageBitmap(HTMLCanvasElement*, IntRect);
50 ImageBitmap(ImageData*, IntRect); 54 ImageBitmap(ImageData*, IntRect);
51 ImageBitmap(ImageBitmap*, IntRect); 55 ImageBitmap(ImageBitmap*, IntRect);
52 56
53 RefPtr<BitmapImage> m_bitmap; 57 RefPtr<Image> m_bitmap;
54 OwnPtr<ImageBuffer> m_buffer; 58 OwnPtr<ImageBuffer> m_buffer;
55 59 SkImage* m_canvasImage;
Justin Novosad 2013/07/22 15:35:41 We should no use SkImage directly. Could we have
56 IntPoint m_bitmapOffset; // offset applied to the image when it is drawn to the context 60 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 61 IntSize m_bitmapSize; // actual size of the BitmapImage
62 IntRect m_cropRect; // user defined size of the ImageBitmap
58 }; 63 };
59 64
60 } // namespace WebCore 65 } // namespace WebCore
61 66
62 #endif // ImageBitmap_h 67 #endif // ImageBitmap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698