| OLD | NEW | 
|---|
| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 369     return; | 369     return; | 
| 370   if (useDeviceBits_) { | 370   if (useDeviceBits_) { | 
| 371     bitmap_.unlockPixels(); | 371     bitmap_.unlockPixels(); | 
| 372   } else if (!bitmapIsDummy_) { | 372   } else if (!bitmapIsDummy_) { | 
| 373     // Find the bits that were drawn to. | 373     // Find the bits that were drawn to. | 
| 374     SkIRect bounds = computeDirtyRect(); | 374     SkIRect bounds = computeDirtyRect(); | 
| 375     SkBitmap subset; | 375     SkBitmap subset; | 
| 376     if (!bitmap_.extractSubset(&subset, bounds)) { | 376     if (!bitmap_.extractSubset(&subset, bounds)) { | 
| 377         return; | 377         return; | 
| 378     } | 378     } | 
| 379     // Neutralize the global matrix by concatenating the inverse. In the | 379     subset.setImmutable();  // Prevents a defensive copy inside Skia. | 
| 380     // future, Skia may provide some mechanism to set the device portion of |  | 
| 381     // the matrix to identity without clobbering any hosting matrix (e.g., the |  | 
| 382     // picture's matrix). |  | 
| 383     const SkMatrix& skMatrix = canvas_->getTotalMatrix(); |  | 
| 384     SkMatrix inverse; |  | 
| 385     if (!skMatrix.invert(&inverse)) |  | 
| 386       return; |  | 
| 387     canvas_->save(); | 380     canvas_->save(); | 
| 388     canvas_->concat(inverse); | 381     canvas_->setMatrix(SkMatrix::I());  // Reset back to device space. | 
| 389     canvas_->translate(bounds.x() + bitmapOffset_.x(), | 382     canvas_->translate(bounds.x() + bitmapOffset_.x(), | 
| 390                        bounds.y() + bitmapOffset_.y()); | 383                        bounds.y() + bitmapOffset_.y()); | 
| 391     canvas_->scale(1.f / bitmapScaleFactor_, 1.f / bitmapScaleFactor_); | 384     canvas_->scale(1.f / bitmapScaleFactor_, 1.f / bitmapScaleFactor_); | 
| 392     canvas_->drawBitmap(subset, 0, 0); | 385     canvas_->drawBitmap(subset, 0, 0); | 
| 393     canvas_->restore(); | 386     canvas_->restore(); | 
| 394   } | 387   } | 
| 395   CGContextRelease(cgContext_); | 388   CGContextRelease(cgContext_); | 
| 396   cgContext_ = 0; | 389   cgContext_ = 0; | 
| 397   useDeviceBits_ = false; | 390   useDeviceBits_ = false; | 
| 398   bitmapIsDummy_ = false; | 391   bitmapIsDummy_ = false; | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 460   CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix)); | 453   CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix)); | 
| 461 | 454 | 
| 462   return cgContext_; | 455   return cgContext_; | 
| 463 } | 456 } | 
| 464 | 457 | 
| 465 bool SkiaBitLocker::hasEmptyClipRegion() const { | 458 bool SkiaBitLocker::hasEmptyClipRegion() const { | 
| 466   return canvas_->isClipEmpty(); | 459   return canvas_->isClipEmpty(); | 
| 467 } | 460 } | 
| 468 | 461 | 
| 469 }  // namespace gfx | 462 }  // namespace gfx | 
| OLD | NEW | 
|---|