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

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

Issue 21485: Bitmap transport (Closed)
Patch Set: Fix some mac crashes Created 11 years, 10 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
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 "SkMatrix.h" 9 #include "SkMatrix.h"
10 #include "SkRegion.h" 10 #include "SkRegion.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 bitmap.setIsOpaque(is_opaque); 161 bitmap.setIsOpaque(is_opaque);
162 162
163 if (is_opaque) { 163 if (is_opaque) {
164 #ifndef NDEBUG 164 #ifndef NDEBUG
165 // To aid in finding bugs, we set the background color to something 165 // To aid in finding bugs, we set the background color to something
166 // obviously wrong so it will be noticable when it is not cleared 166 // obviously wrong so it will be noticable when it is not cleared
167 bitmap.eraseARGB(255, 0, 255, 128); // bright bluish green 167 bitmap.eraseARGB(255, 0, 255, 128); // bright bluish green
168 #endif 168 #endif
169 } 169 }
170 170
171 CGColorSpaceRef color_space = 171 if (!context) {
172 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 172 CGColorSpaceRef color_space =
173 // allocate a bitmap context with 4 components per pixel (BGRA). Apple 173 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
174 // recommends these flags for improved CG performance. 174 // allocate a bitmap context with 4 components per pixel (BGRA). Apple
175 CGContextRef bitmap_context = 175 // recommends these flags for improved CG performance.
176 CGBitmapContextCreate(data, width, height, 8, width*4, 176 context =
177 color_space, 177 CGBitmapContextCreate(data, width, height, 8, width*4,
178 kCGImageAlphaPremultipliedFirst | 178 color_space,
179 kCGBitmapByteOrder32Host); 179 kCGImageAlphaPremultipliedFirst |
180 kCGBitmapByteOrder32Host);
180 181
181 // Change the coordinate system to match WebCore's 182 // Change the coordinate system to match WebCore's
182 CGContextTranslateCTM(bitmap_context, 0, height); 183 CGContextTranslateCTM(context, 0, height);
183 CGContextScaleCTM(bitmap_context, 1.0, -1.0); 184 CGContextScaleCTM(context, 1.0, -1.0);
184 CGColorSpaceRelease(color_space); 185 CGColorSpaceRelease(color_space);
186 }
185 187
186 // The device object will take ownership of the graphics context. 188 // The device object will take ownership of the graphics context.
187 return new BitmapPlatformDeviceMac( 189 return new BitmapPlatformDeviceMac(
188 new BitmapPlatformDeviceMacData(bitmap_context), bitmap); 190 new BitmapPlatformDeviceMacData(context), bitmap);
189 } 191 }
190 192
191 // The device will own the bitmap, which corresponds to also owning the pixel 193 // The device will own the bitmap, which corresponds to also owning the pixel
192 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. 194 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap.
193 BitmapPlatformDeviceMac::BitmapPlatformDeviceMac( 195 BitmapPlatformDeviceMac::BitmapPlatformDeviceMac(
194 BitmapPlatformDeviceMacData* data, const SkBitmap& bitmap) 196 BitmapPlatformDeviceMacData* data, const SkBitmap& bitmap)
195 : PlatformDeviceMac(bitmap), 197 : PlatformDeviceMac(bitmap),
196 data_(data) { 198 data_(data) {
197 } 199 }
198 200
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 size_t offset = (i + bitmap_start_y) * row_words + bitmap_start_x; 290 size_t offset = (i + bitmap_start_y) * row_words + bitmap_start_x;
289 for (int j = 0; j < width; j++) { 291 for (int j = 0; j < width; j++) {
290 adjustor(data + offset + j); 292 adjustor(data + offset + j);
291 } 293 }
292 } 294 }
293 } 295 }
294 } 296 }
295 297
296 } // namespace skia 298 } // namespace skia
297 299
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698