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

Unified Diff: third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: No long keep WeakPtr<DrawingBuffer> Created 4 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/platform/graphics/StaticBitmapImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
index b2b642d21862fee4ab4df96881d19b0daaea1007..daee5911d955febc1dd3f9c2cb80a609935d96b9 100644
--- a/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
@@ -7,11 +7,10 @@
#include "platform/graphics/AcceleratedStaticBitmapImage.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/ImageObserver.h"
+#include "platform/graphics/UnacceleratedStaticBitmapImage.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPaint.h"
-#include "wtf/PtrUtil.h"
-#include <memory>
namespace blink {
@@ -21,51 +20,26 @@ PassRefPtr<StaticBitmapImage> StaticBitmapImage::create(sk_sp<SkImage> image) {
if (image->isTextureBacked())
return AcceleratedStaticBitmapImage::createFromSharedContextImage(
std::move(image));
- return adoptRef(new StaticBitmapImage(std::move(image)));
+ return UnacceleratedStaticBitmapImage::create(std::move(image));
}
-StaticBitmapImage::StaticBitmapImage(sk_sp<SkImage> image)
- : m_image(std::move(image)) {
- ASSERT(m_image);
-}
-
-StaticBitmapImage::StaticBitmapImage() {}
-
-StaticBitmapImage::~StaticBitmapImage() {}
-
-IntSize StaticBitmapImage::size() const {
- return IntSize(m_image->width(), m_image->height());
-}
-
-bool StaticBitmapImage::isTextureBacked() {
- return m_image && m_image->isTextureBacked();
-}
-
-bool StaticBitmapImage::currentFrameKnownToBeOpaque(MetadataMode) {
- return m_image->isOpaque();
-}
-
-void StaticBitmapImage::draw(SkCanvas* canvas,
- const SkPaint& paint,
- const FloatRect& dstRect,
- const FloatRect& srcRect,
- RespectImageOrientationEnum,
- ImageClampingMode clampMode) {
+void StaticBitmapImage::drawHelper(SkCanvas* canvas,
+ const SkPaint& paint,
+ const FloatRect& dstRect,
+ const FloatRect& srcRect,
+ ImageClampingMode clampMode,
+ sk_sp<SkImage> image) {
FloatRect adjustedSrcRect = srcRect;
- adjustedSrcRect.intersect(SkRect::Make(m_image->bounds()));
+ adjustedSrcRect.intersect(SkRect::Make(image->bounds()));
if (dstRect.isEmpty() || adjustedSrcRect.isEmpty())
return; // Nothing to draw.
- canvas->drawImageRect(m_image.get(), adjustedSrcRect, dstRect, &paint,
+ canvas->drawImageRect(image.get(), adjustedSrcRect, dstRect, &paint,
WebCoreClampingModeToSkiaRectConstraint(clampMode));
if (ImageObserver* observer = getImageObserver())
observer->didDraw(this);
}
-sk_sp<SkImage> StaticBitmapImage::imageForCurrentFrame() {
- return m_image;
-}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698