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

Unified Diff: ui/gfx/skia_util.cc

Issue 10316019: Aura: Adds custom cursors for drag and drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 8 months 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: ui/gfx/skia_util.cc
diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc
index bfee3789f24df275ffe52d0b42b11b29196a3b1d..a459cddf944ca5de42579f2ce993a0209c794244 100644
--- a/ui/gfx/skia_util.cc
+++ b/ui/gfx/skia_util.cc
@@ -8,6 +8,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkShader.h"
+#include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/gfx/rect.h"
@@ -101,4 +102,28 @@ string16 RemoveAcceleratorChar(const string16& s,
return accelerator_removed;
}
+void ConvertSkiaToRGBA(const unsigned char* skia,
+ int pixel_width,
+ unsigned char* rgba) {
+ int total_length = pixel_width * 4;
+ for (int i = 0; i < total_length; i += 4) {
+ const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]);
+
+ // Pack the components here.
+ int alpha = SkGetPackedA32(pixel_in);
+ if (alpha != 0 && alpha != 255) {
+ SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in);
+ rgba[i + 0] = SkColorGetR(unmultiplied);
+ rgba[i + 1] = SkColorGetG(unmultiplied);
+ rgba[i + 2] = SkColorGetB(unmultiplied);
+ rgba[i + 3] = alpha;
+ } else {
+ rgba[i + 0] = SkGetPackedR32(pixel_in);
+ rgba[i + 1] = SkGetPackedG32(pixel_in);
+ rgba[i + 2] = SkGetPackedB32(pixel_in);
+ rgba[i + 3] = alpha;
+ }
+ }
+}
+
} // namespace gfx
« content/test/DEPS ('K') | « ui/gfx/skia_util.h ('k') | ui/resources/ui_resources_2x.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698