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

Unified Diff: Source/platform/graphics/ImageBufferSurface.cpp

Issue 799103002: Fix display list canvas not rendering correctly on high dpi displays (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: corrections Created 6 years 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: Source/platform/graphics/ImageBufferSurface.cpp
diff --git a/Source/platform/graphics/ImageBufferSurface.cpp b/Source/platform/graphics/ImageBufferSurface.cpp
index 038814f54a4b3e95155d4dcc69e7232acb6c3d10..d7d16d71d5d69e44c2feb93d74ccaf54f8a494eb 100644
--- a/Source/platform/graphics/ImageBufferSurface.cpp
+++ b/Source/platform/graphics/ImageBufferSurface.cpp
@@ -32,6 +32,8 @@
#include "platform/graphics/ImageBufferSurface.h"
+#include "platform/graphics/BitmapImage.h"
+#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/ImageBuffer.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"
@@ -86,4 +88,28 @@ PassRefPtr<SkImage> ImageBufferSurface::newImageSnapshot() const
return nullptr;
}
+static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
+{
+ SkBitmap tmp;
+ if (!bitmap.deepCopyTo(&tmp))
+ bitmap.copyTo(&tmp, bitmap.colorType());
+
+ return tmp;
+}
+
+void ImageBufferSurface::draw(GraphicsContext* context, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, WebBlendMode blendMode, bool needsCopy)
+{
+ SkBitmap bmp = bitmap();
+ // For ImageBufferSurface that enables cachedBitmap, Use the cached bitmap for CPU side usage
+ // if it is available, otherwise generate and use it.
+ if (!context->isAccelerated() && isAccelerated() && cachedBitmapEnabled() && isValid()) {
+ updateCachedBitmapIfNeeded();
+ bmp = cachedBitmap();
+ }
+
+ RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(needsCopy ? deepSkBitmapCopy(bmp) : bmp));
+
+ context->drawImage(image.get(), destRect, srcRect, op, blendMode, DoNotRespectImageOrientation);
+}
+
} // namespace blink
« no previous file with comments | « Source/platform/graphics/ImageBufferSurface.h ('k') | Source/platform/graphics/RecordingImageBufferSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698