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

Issue 141037: Get our color channels straight. The reason why the color swap was required... (Closed)

Created:
11 years, 6 months ago by Nico
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com, John Grabowski, Ben Goodger (Google), ---DO NOT USE---rsesek
Visibility:
Public.

Description

Get our color channels straight. The reason why the weird color swap in cocoa_utils_unittest.mm was required was that the SkBitmap that SkBitmapToNSImage() in cocoa_utils received already had messed-up channels when it was passed in from Chromium but not when it was passed in from the test. The reason for it being corrupt when being passed in from Chromium was that CGImageToSkBitmap(), which sends it from the renderer to the browser, assumes that Skia's and CoreGraphic's image memory layout match. This is a reasonable assumption to make (we don't want to swizzle bytes around all the time when converting between the two image types), but it is wrong at the moment. CoreGraphics uses BGRA in memory on little-endian machines with Apple's recommended kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst configuration. Skia is currently configured to use RGBA for some reason -- so the red and blue channels are swapped. Since we can't change CoreGraphics, I changed Skia, and things still seem to work (a small fix to Skia's SkCreateCGImageRef() is required, because this function assumes that Skia's default argb layout is used). I do realize that this is a larger change, so please review carefully. But it _is_ the right thing to do in my eyes. I also added a few preprocessor checks to the places where we make assumptions about Skia's image memory layout. This requires a patch to Skia, too: http://codereview.appspot.com/84041 BUG=http://crbug.com/14020 TEST=Check that favicons in the bookmark bar still look correct and that cocoa_utils_unittest now passes without that weird "swap" flag.

Patch Set 1 #

Patch Set 2 : add bug and test fields #

Patch Set 3 : Improve CL description #

Total comments: 2

Patch Set 4 : s/icon/bitmap/ #

Patch Set 5 : ... #

Unified diffs Side-by-side diffs Delta from patch set Stats (+32 lines, -79 lines) Patch
M chrome/browser/cocoa/cocoa_utils.mm View 1 2 3 4 1 chunk +2 lines, -64 lines 0 comments Download
M chrome/browser/cocoa/cocoa_utils_unittest.mm View 3 chunks +5 lines, -12 lines 0 comments Download
M skia/config/SkUserConfig.h View 1 chunk +7 lines, -3 lines 0 comments Download
M skia/ext/bitmap_platform_device_mac.cc View 2 chunks +9 lines, -0 lines 0 comments Download
M skia/ext/skia_utils_mac.mm View 1 chunk +9 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Nico
I looked into why rsesek's favicon patch for OS X might be flaky, and found ...
11 years, 6 months ago (2009-06-22 05:24:19 UTC) #1
Amanda Walker
Nice detective work! Originally, we tried to accomodate Skia's layout, which worked but meant our ...
11 years, 6 months ago (2009-06-22 12:20:58 UTC) #2
Avi (use Gerrit)
Wow. Any change that takes 60 lines of code out is a good one. LG. ...
11 years, 6 months ago (2009-06-22 14:16:20 UTC) #3
Stephen White
Sorry -- although I have a growing familiarity with Skia, I'm not a Skia reviewer. ...
11 years, 6 months ago (2009-06-22 16:01:44 UTC) #4
John Grabowski
LGTM! Glad to see this problem tracked down.
11 years, 6 months ago (2009-06-22 18:18:26 UTC) #5
Nico
11 years, 6 months ago (2009-06-25 03:13:21 UTC) #6
Amanda submitted this as part of her skia & webkit merges today (thanks!), so
I'm just closing this.

http://codereview.chromium.org/141037/diff/1014/1016
File chrome/browser/cocoa/cocoa_utils.mm (right):

http://codereview.chromium.org/141037/diff/1014/1016#newcode24
Line 24: NSImage* SkBitmapToNSImage(const SkBitmap& icon) {
On 2009/06/22 14:16:21, Avi wrote:
> For generality's sake, can we change the name of the parameter? I can imagine
> situations where we're not converting an icon.

Done.

Powered by Google App Engine
This is Rietveld 408576698