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

Side by Side Diff: skia/ext/skia_utils_mac.mm

Issue 22796028: Updating Chromium to Skia SkBaseDevice/SkBitmapDevice split (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs Created 7 years, 3 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
« no previous file with comments | « skia/ext/platform_device_mac.cc ('k') | skia/ext/vector_canvas.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/skia_utils_mac.h" 5 #include "skia/ext/skia_utils_mac.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 count:4]; 185 count:4];
186 } 186 }
187 187
188 SkBitmap CGImageToSkBitmap(CGImageRef image) { 188 SkBitmap CGImageToSkBitmap(CGImageRef image) {
189 if (!image) 189 if (!image)
190 return SkBitmap(); 190 return SkBitmap();
191 191
192 int width = CGImageGetWidth(image); 192 int width = CGImageGetWidth(image);
193 int height = CGImageGetHeight(image); 193 int height = CGImageGetHeight(image);
194 194
195 scoped_ptr<SkDevice> device( 195 scoped_ptr<SkBaseDevice> device(
196 skia::BitmapPlatformDevice::Create(NULL, width, height, false)); 196 skia::BitmapPlatformDevice::Create(NULL, width, height, false));
197 197
198 CGContextRef context = skia::GetBitmapContext(device.get()); 198 CGContextRef context = skia::GetBitmapContext(device.get());
199 199
200 // We need to invert the y-axis of the canvas so that Core Graphics drawing 200 // We need to invert the y-axis of the canvas so that Core Graphics drawing
201 // happens right-side up. Skia has an upper-left origin and CG has a lower- 201 // happens right-side up. Skia has an upper-left origin and CG has a lower-
202 // left one. 202 // left one.
203 CGContextScaleCTM(context, 1.0, -1.0); 203 CGContextScaleCTM(context, 1.0, -1.0);
204 CGContextTranslateCTM(context, 0, -height); 204 CGContextTranslateCTM(context, 0, -height);
205 205
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 canvas_->save(); 355 canvas_->save();
356 canvas_->concat(inverse); 356 canvas_->concat(inverse);
357 canvas_->drawBitmap(subset, bounds.fLeft, bounds.fTop); 357 canvas_->drawBitmap(subset, bounds.fLeft, bounds.fTop);
358 canvas_->restore(); 358 canvas_->restore();
359 } 359 }
360 CGContextRelease(cgContext_); 360 CGContextRelease(cgContext_);
361 cgContext_ = 0; 361 cgContext_ = 0;
362 } 362 }
363 363
364 CGContextRef SkiaBitLocker::cgContext() { 364 CGContextRef SkiaBitLocker::cgContext() {
365 SkDevice* device = canvas_->getTopDevice(); 365 SkBaseDevice* device = canvas_->getTopDevice();
366 DCHECK(device); 366 DCHECK(device);
367 if (!device) 367 if (!device)
368 return 0; 368 return 0;
369 releaseIfNeeded(); // This flushes any prior bitmap use 369 releaseIfNeeded(); // This flushes any prior bitmap use
370 const SkBitmap& deviceBits = device->accessBitmap(true); 370 const SkBitmap& deviceBits = device->accessBitmap(true);
371 useDeviceBits_ = deviceBits.getPixels(); 371 useDeviceBits_ = deviceBits.getPixels();
372 if (useDeviceBits_) { 372 if (useDeviceBits_) {
373 bitmap_ = deviceBits; 373 bitmap_ = deviceBits;
374 bitmap_.lockPixels(); 374 bitmap_.lockPixels();
375 } else { 375 } else {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Apply content matrix. 420 // Apply content matrix.
421 SkMatrix skMatrix = canvas_->getTotalMatrix(); 421 SkMatrix skMatrix = canvas_->getTotalMatrix();
422 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY)); 422 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY));
423 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix); 423 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix);
424 CGContextConcatCTM(cgContext_, affine); 424 CGContextConcatCTM(cgContext_, affine);
425 425
426 return cgContext_; 426 return cgContext_;
427 } 427 }
428 428
429 } // namespace gfx 429 } // namespace gfx
OLDNEW
« no previous file with comments | « skia/ext/platform_device_mac.cc ('k') | skia/ext/vector_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698