2010-05-01 Evan Stade <estade@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 May 2010 07:01:31 +0000 (07:01 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 May 2010 07:01:31 +0000 (07:01 +0000)
        Reviewed by David Levin.

        [chromium] Skia needs to fade DragImages
        https://bugs.webkit.org/show_bug.cgi?id=38008

        tested by DragImageTest

        * platform/chromium/DragImageChromiumSkia.cpp:
        (WebCore::dissolveDragImageToFraction):implement
        (WebCore::createDragImageFromImage):deep copy instead of shallow
2010-05-01  Evan Stade  <estade@chromium.org>

        Reviewed by David Levin

        [chromium] Skia needs to fade DragImages
        https://bugs.webkit.org/show_bug.cgi?id=38008

        * tests/DragImageTest.cpp:
        (DragImageTest.CreateDragImage): test that the drag image is a deep copy

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@58641 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/chromium/DragImageChromiumSkia.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/tests/DragImageTest.cpp

index ad13715..1591308 100644 (file)
@@ -1,3 +1,16 @@
+2010-05-01  Evan Stade  <estade@chromium.org>
+
+        Reviewed by David Levin.
+
+        [chromium] Skia needs to fade DragImages
+        https://bugs.webkit.org/show_bug.cgi?id=38008
+
+        tested by DragImageTest
+
+        * platform/chromium/DragImageChromiumSkia.cpp:
+        (WebCore::dissolveDragImageToFraction):implement
+        (WebCore::createDragImageFromImage):deep copy instead of shallow
+
 2010-05-01  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Sam Weinig.
 2010-05-01  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Sam Weinig.
index 24bd8fd..e5c1cee 100644 (file)
@@ -68,9 +68,26 @@ DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
     return scaledImage;
 }
 
     return scaledImage;
 }
 
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
+DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
 {
 {
-    notImplemented();
+    if (!image)
+        return 0;
+
+    image->setIsOpaque(false);
+    image->lockPixels();
+
+    for (int row = 0; row < image->height(); ++row) {
+        for (int column = 0; column < image->width(); ++column) {
+            uint32_t* pixel = image->getAddr32(column, row);
+            *pixel = SkPreMultiplyARGB(SkColorGetA(*pixel) * fraction,
+                                       SkColorGetR(*pixel),
+                                       SkColorGetG(*pixel),
+                                       SkColorGetB(*pixel));
+        }
+    }
+
+    image->unlockPixels();
+
     return image;
 }
 
     return image;
 }
 
@@ -80,7 +97,12 @@ DragImageRef createDragImageFromImage(Image* image)
         return 0;
 
     NativeImageSkia* bitmap = image->nativeImageForCurrentFrame();
         return 0;
 
     NativeImageSkia* bitmap = image->nativeImageForCurrentFrame();
-    return bitmap ? new SkBitmap(*bitmap) : 0;
+    if (!bitmap)
+        return 0;
+
+    SkBitmap* dragImage = new SkBitmap();
+    bitmap->copyTo(dragImage, SkBitmap::kARGB_8888_Config);
+    return dragImage;
 }
 
 DragImageRef createDragImageIconForCachedImage(CachedImage*)
 }
 
 DragImageRef createDragImageIconForCachedImage(CachedImage*)
index d731545..d81b9ad 100644 (file)
@@ -1,3 +1,13 @@
+2010-05-01  Evan Stade  <estade@chromium.org>
+
+        Reviewed by David Levin
+
+        [chromium] Skia needs to fade DragImages
+        https://bugs.webkit.org/show_bug.cgi?id=38008
+
+        * tests/DragImageTest.cpp:
+        (DragImageTest.CreateDragImage): test that the drag image is a deep copy
+
 2010-04-30  Jian Li  <jianli@chromium.org>
 
         Reviewed by Darin Fisher.
 2010-04-30  Jian Li  <jianli@chromium.org>
 
         Reviewed by Darin Fisher.
index 6c9718e..7b7d4ee 100644 (file)
@@ -118,19 +118,29 @@ TEST(DragImageTest, NonNullHandling)
     EXPECT_EQ(1, size.width());
     EXPECT_EQ(1, size.height());
 
     EXPECT_EQ(1, size.width());
     EXPECT_EQ(1, size.height());
 
-    // This is not implemented, so we don't do any output validation.
     dragImage = dissolveDragImageToFraction(dragImage, 0.5);
     ASSERT_TRUE(dragImage);
 
     deleteDragImage(dragImage);
 }
 
     dragImage = dissolveDragImageToFraction(dragImage, 0.5);
     ASSERT_TRUE(dragImage);
 
     deleteDragImage(dragImage);
 }
 
-TEST(DragImageTest, CreateDragImageReturningNull)
+TEST(DragImageTest, CreateDragImage)
 {
 {
-    // Tests that the DrageImage implementation doesn't choke on null values
-    // of nativeImageForCurrentFrame().
-    TestImage testImage((IntSize()));
-    EXPECT_FALSE(createDragImageFromImage(&testImage));
+    {
+        // Tests that the DrageImage implementation doesn't choke on null values
+        // of nativeImageForCurrentFrame().
+        TestImage testImage((IntSize()));
+        EXPECT_FALSE(createDragImageFromImage(&testImage));
+    }
+
+    {
+        // Tests that the drag image is a deep copy.
+        TestImage testImage(IntSize(1, 1));
+        DragImageRef dragImage = createDragImageFromImage(&testImage);
+        ASSERT_TRUE(dragImage);
+        SkAutoLockPixels lock1(*dragImage), lock2(*testImage.nativeImageForCurrentFrame());
+        EXPECT_NE(dragImage->getPixels(), testImage.nativeImageForCurrentFrame()->getPixels());
+    }
 }
 
 } // anonymous namespace
 }
 
 } // anonymous namespace