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

Unified Diff: third_party/WebKit/Source/core/frame/ImageBitmap.h

Issue 1413583004: refractoring ImageBitmap class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix memory leak issue Created 5 years, 1 month 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
Index: third_party/WebKit/Source/core/frame/ImageBitmap.h
diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.h b/third_party/WebKit/Source/core/frame/ImageBitmap.h
index 8dc3a51e7070dd73fd00cf08973306fd253b6a49..71fd4a52f3b7c348eb5679ca5c961ad580afda69 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.h
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.h
@@ -11,7 +11,9 @@
#include "core/html/canvas/CanvasImageSource.h"
#include "platform/geometry/IntRect.h"
#include "platform/graphics/Image.h"
+#include "platform/graphics/ImageBuffer.h"
#include "platform/heap/Handle.h"
+#include "third_party/skia/include/core/SkImage.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
@@ -32,14 +34,10 @@ public:
static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageBitmap*, const IntRect&);
static PassRefPtrWillBeRawPtr<ImageBitmap> create(Image*, const IntRect&);
- PassRefPtr<Image> bitmapImage() const;
- PassRefPtrWillBeRawPtr<HTMLImageElement> imageElement() const { return m_imageElement; }
-
- IntRect bitmapRect() const { return m_bitmapRect; }
-
- int width() const { return m_cropRect.width(); }
- int height() const { return m_cropRect.height(); }
- IntSize size() const { return m_cropRect.size(); }
+ SkImage* skImage() const { return (m_image) ? m_image.get() : nullptr; }
+ int width() const { return (m_image) ? m_image->width(): 0; }
+ int height() const { return (m_image) ? m_image->height(): 0; }
+ IntSize size() const { return (m_image) ? IntSize(m_image->width(), m_image->height()) : IntSize(); }
~ImageBitmap() override;
@@ -59,23 +57,13 @@ private:
ImageBitmap(ImageBitmap*, const IntRect&);
ImageBitmap(Image*, const IntRect&);
+ PassRefPtr<SkImage> cropImage(PassRefPtr<SkImage>, const IntRect&);
+
// ImageLoaderClient
void notifyImageSourceChanged() override;
bool requestsHighLiveResourceCachePriority() override { return true; }
- // ImageBitmaps constructed from HTMLImageElements hold a reference to the HTMLImageElement until
- // the image source changes.
- RefPtrWillBeMember<HTMLImageElement> m_imageElement;
- RefPtr<Image> m_bitmap;
-
- IntRect m_bitmapRect; // The rect where the underlying Image should be placed in reference to the ImageBitmap.
- IntRect m_cropRect;
-
- // The offset by which the desired Image is stored internally.
- // ImageBitmaps constructed from HTMLImageElements reference the entire ImageResource and may have a non-zero bitmap offset.
- // ImageBitmaps not constructed from HTMLImageElements always pre-crop and store the image at (0, 0).
- IntPoint m_bitmapOffset;
-
+ RefPtr<SkImage> m_image;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698