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

Unified Diff: Source/core/page/ImageBitmap.h

Issue 19393004: Allow eviction of ImageBitmaps that are created from ImageElements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix for assertion failure. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/loader/cache/Resource.cpp ('k') | Source/core/page/ImageBitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/ImageBitmap.h
diff --git a/Source/core/page/ImageBitmap.h b/Source/core/page/ImageBitmap.h
index 4a5833a0e3490becb034eacf18bb2122c91662c5..102fa62542e219b514d12426121c2d17085a8e52 100644
--- a/Source/core/page/ImageBitmap.h
+++ b/Source/core/page/ImageBitmap.h
@@ -6,8 +6,8 @@
#define ImageBitmap_h
#include "bindings/v8/ScriptWrappable.h"
-#include "core/dom/ScriptExecutionContext.h"
-#include "core/platform/graphics/BitmapImage.h"
+#include "core/html/HTMLImageElement.h"
+#include "core/platform/graphics/Image.h"
#include "core/platform/graphics/ImageBuffer.h"
#include "core/platform/graphics/IntRect.h"
#include "wtf/PassRefPtr.h"
@@ -16,44 +16,48 @@
namespace WebCore {
class HTMLCanvasElement;
-class HTMLImageElement;
class HTMLVideoElement;
class ImageData;
-class ImageBitmap : public RefCounted<ImageBitmap>, public ScriptWrappable {
+class ImageBitmap : public RefCounted<ImageBitmap>, public ScriptWrappable, public ImageLoaderClient {
public:
- static PassRefPtr<ImageBitmap> create(HTMLImageElement*, IntRect);
- static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, IntRect);
- static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, IntRect);
- static PassRefPtr<ImageBitmap> create(ImageData*, IntRect);
- static PassRefPtr<ImageBitmap> create(ImageBitmap*, IntRect);
+ static PassRefPtr<ImageBitmap> create(HTMLImageElement*, const IntRect&);
+ static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, const IntRect&);
+ static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, const IntRect&);
+ static PassRefPtr<ImageBitmap> create(ImageData*, const IntRect&);
+ static PassRefPtr<ImageBitmap> create(ImageBitmap*, const IntRect&);
- BitmapImage* bitmapImage() const { return m_bitmap.get(); }
+ PassRefPtr<Image> bitmapImage() const;
+ PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; }
- int bitmapWidth() const { return m_bitmap->width(); }
- int bitmapHeight() const { return m_bitmap->height(); }
- IntSize bitmapSize() const { return m_bitmap->size(); }
- IntPoint bitmapOffset() const { return m_bitmapOffset; }
+ IntRect bitmapRect() const { return m_bitmapRect; }
- int width() const { return m_size.width(); }
- int height() const { return m_size.height(); }
- IntSize size() const { return m_size; }
+ int width() const { return m_cropRect.width(); }
+ int height() const { return m_cropRect.height(); }
+ IntSize size() const { return m_cropRect.size(); }
- ~ImageBitmap() { };
+ ~ImageBitmap();
private:
- ImageBitmap(HTMLImageElement*, IntRect);
- ImageBitmap(HTMLVideoElement*, IntRect);
- ImageBitmap(HTMLCanvasElement*, IntRect);
- ImageBitmap(ImageData*, IntRect);
- ImageBitmap(ImageBitmap*, IntRect);
+ ImageBitmap(HTMLImageElement*, const IntRect&);
+ ImageBitmap(HTMLVideoElement*, const IntRect&);
+ ImageBitmap(HTMLCanvasElement*, const IntRect&);
+ ImageBitmap(ImageData*, const IntRect&);
+ ImageBitmap(ImageBitmap*, const IntRect&);
- RefPtr<BitmapImage> m_bitmap;
+ // ImageLoaderClient
+ virtual void notifyImageSourceChanged();
+ virtual bool requestsHighLiveResourceCachePriority() { return true; }
+
+ // ImageBitmaps constructed from HTMLImageElements hold a reference to the HTMLImageElement until
+ // the image source changes.
+ RefPtr<HTMLImageElement> m_imageElement;
+ RefPtr<Image> m_bitmap;
OwnPtr<ImageBuffer> m_buffer;
- IntPoint m_bitmapOffset; // offset applied to the image when it is drawn to the context
- IntSize m_size; // user defined size of the ImageBitmap
+ IntRect m_bitmapRect; // The rect where the underlying Image should be placed in reference to the ImageBitmap.
+ IntRect m_cropRect;
};
} // namespace WebCore
« no previous file with comments | « Source/core/loader/cache/Resource.cpp ('k') | Source/core/page/ImageBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698