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

Side by Side Diff: skia/ext/bitmap_platform_device_mac.cc

Issue 141037: Get our color channels straight. The reason why the color swap was required... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: ... Created 11 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/ext/skia_utils_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "skia/ext/bitmap_platform_device_mac.h" 5 #include "skia/ext/bitmap_platform_device_mac.h"
6 6
7 #include <time.h> 7 #include <time.h>
8 8
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "skia/ext/skia_utils_mac.h" 10 #include "skia/ext/skia_utils_mac.h"
(...skipping 29 matching lines...) Expand all
40 } else { 40 } else {
41 // Fill up available size. 41 // Fill up available size.
42 *size = available_size - *position; 42 *size = available_size - *position;
43 } 43 }
44 return true; 44 return true;
45 } 45 }
46 46
47 static CGContextRef CGContextForData(void* data, int width, int height) { 47 static CGContextRef CGContextForData(void* data, int width, int height) {
48 CGColorSpaceRef color_space = 48 CGColorSpaceRef color_space =
49 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 49 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
50 #define HAS_ARGB_SHIFTS(a, r, g, b) \
51 (SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \
52 && SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b))
53 #if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 16, 8, 0)
50 // Allocate a bitmap context with 4 components per pixel (BGRA). Apple 54 // Allocate a bitmap context with 4 components per pixel (BGRA). Apple
51 // recommends these flags for improved CG performance. 55 // recommends these flags for improved CG performance.
52 CGContextRef context = 56 CGContextRef context =
53 CGBitmapContextCreate(data, width, height, 8, width * 4, 57 CGBitmapContextCreate(data, width, height, 8, width * 4,
54 color_space, 58 color_space,
55 kCGImageAlphaPremultipliedFirst | 59 kCGImageAlphaPremultipliedFirst |
56 kCGBitmapByteOrder32Host); 60 kCGBitmapByteOrder32Host);
61 #else
62 #error We require that Skia's and CoreGraphics's recommended \
63 image memory layout match.
64 #endif
65 #undef HAS_ARGB_SHIFTS
57 CGColorSpaceRelease(color_space); 66 CGColorSpaceRelease(color_space);
58 67
59 if (!context) 68 if (!context)
60 return NULL; 69 return NULL;
61 70
62 // Change the coordinate system to match WebCore's 71 // Change the coordinate system to match WebCore's
63 CGContextTranslateCTM(context, 0, height); 72 CGContextTranslateCTM(context, 0, height);
64 CGContextScaleCTM(context, 1.0, -1.0); 73 CGContextScaleCTM(context, 1.0, -1.0);
65 74
66 return context; 75 return context;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 for (int i = 0; i < height; i++) { 348 for (int i = 0; i < height; i++) {
340 size_t offset = (i + bitmap_start_y) * row_words + bitmap_start_x; 349 size_t offset = (i + bitmap_start_y) * row_words + bitmap_start_x;
341 for (int j = 0; j < width; j++) { 350 for (int j = 0; j < width; j++) {
342 adjustor(data + offset + j); 351 adjustor(data + offset + j);
343 } 352 }
344 } 353 }
345 } 354 }
346 } 355 }
347 356
348 } // namespace skia 357 } // namespace skia
OLDNEW
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/ext/skia_utils_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698