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

Unified Diff: third_party/WebKit/Source/platform/DragImage.cpp

Issue 1331533002: [poc] curve-filter Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Ensure screen device profiles are matrix Created 5 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: third_party/WebKit/Source/platform/DragImage.cpp
diff --git a/third_party/WebKit/Source/platform/DragImage.cpp b/third_party/WebKit/Source/platform/DragImage.cpp
index bb2049ed8fb49676a7ca6e682c9adc9ed6f9b621..b9af85d4ffbe4af5cb270d687952f86a38fe17b4 100644
--- a/third_party/WebKit/Source/platform/DragImage.cpp
+++ b/third_party/WebKit/Source/platform/DragImage.cpp
@@ -36,6 +36,7 @@
#include "platform/graphics/BitmapImage.h"
#include "platform/graphics/Color.h"
#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/GraphicsScreen.h"
#include "platform/graphics/Image.h"
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/paint/DrawingRecorder.h"
@@ -136,24 +137,31 @@ PassOwnPtr<DragImage> DragImage::create(Image* image,
RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScaleFactor,
InterpolationQuality interpolationQuality, float opacity, FloatSize imageScale)
{
- if (!image)
- return nullptr;
+ RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr;
- RefPtr<SkImage> skImage = image->imageForCurrentFrame();
- if (!skImage)
- return nullptr;
+ if (imageColorProfilesEnabled())
+ RELEASE_ASSERT(currentScreenId()); // There should be an active graphics screen.
+
+ if (skImage && imageColorProfilesEnabled() && image->isBitmapImage() && toBitmapImage(image)->hasColorProfile()) {
+ OwnPtr<ImageBuffer> buffer = ImageBuffer::create(image->size());
+ IntRect source = IntRect(IntPoint(), image->size());
+ image->draw(buffer->canvas(), SkPaint(), source, source, DoNotRespectImageOrientation, Image::ClampImageToSourceRect);
+ skImage = buffer->newSkImageSnapshot(PreferNoAcceleration);
+ }
ImageOrientation orientation;
- if (shouldRespectImageOrientation == RespectImageOrientation && image->isBitmapImage())
+ if (skImage && shouldRespectImageOrientation == RespectImageOrientation && image->isBitmapImage())
orientation = toBitmapImage(image)->currentFrameOrientation();
- SkBitmap bm;
- RefPtr<SkImage> resizedImage =
- resizeAndOrientImage(skImage.release(), orientation, imageScale, opacity, interpolationQuality);
- if (!resizedImage || !resizedImage->asLegacyBitmap(&bm, SkImage::kRO_LegacyBitmapMode))
+ RefPtr<SkImage> dragImage;
+ if (skImage)
+ dragImage = resizeAndOrientImage(skImage.release(), orientation, imageScale, opacity, interpolationQuality);
+
+ SkBitmap bitmap;
+ if (!dragImage || !dragImage->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode))
return nullptr;
- return adoptPtr(new DragImage(bm, deviceScaleFactor, interpolationQuality));
+ return adoptPtr(new DragImage(bitmap, deviceScaleFactor, interpolationQuality));
}
static Font deriveDragLabelFont(int size, FontWeight fontWeight, const FontDescription& systemFont)

Powered by Google App Engine
This is Rietveld 408576698