| 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 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 canvas_->drawBitmap(subset, 0, 0); | 305 canvas_->drawBitmap(subset, 0, 0); |
| 306 canvas_->restore(); | 306 canvas_->restore(); |
| 307 } | 307 } |
| 308 CGContextRelease(cgContext_); | 308 CGContextRelease(cgContext_); |
| 309 cgContext_ = 0; | 309 cgContext_ = 0; |
| 310 useDeviceBits_ = false; | 310 useDeviceBits_ = false; |
| 311 bitmapIsDummy_ = false; | 311 bitmapIsDummy_ = false; |
| 312 } | 312 } |
| 313 | 313 |
| 314 CGContextRef SkiaBitLocker::cgContext() { | 314 CGContextRef SkiaBitLocker::cgContext() { |
| 315 releaseIfNeeded(); // This flushes any prior bitmap use |
| 316 |
| 315 SkIRect clip_bounds; | 317 SkIRect clip_bounds; |
| 316 if (!canvas_->getClipDeviceBounds(&clip_bounds)) { | 318 if (!canvas_->getClipDeviceBounds(&clip_bounds)) { |
| 317 // If the clip is empty, then there is nothing to draw. The caller may | 319 // If the clip is empty, then there is nothing to draw. The caller may |
| 318 // attempt to draw (to-be-clipped) results, so ensure there is a dummy | 320 // attempt to draw (to-be-clipped) results, so ensure there is a dummy |
| 319 // non-NULL CGContext to use. | 321 // non-NULL CGContext to use. |
| 320 bitmapIsDummy_ = true; | 322 bitmapIsDummy_ = true; |
| 321 clip_bounds = SkIRect::MakeXYWH(0, 0, 1, 1); | 323 clip_bounds = SkIRect::MakeXYWH(0, 0, 1, 1); |
| 322 } | 324 } |
| 323 | 325 |
| 324 releaseIfNeeded(); // This flushes any prior bitmap use | |
| 325 | |
| 326 // remember the top/left, in case we need to compose this later | 326 // remember the top/left, in case we need to compose this later |
| 327 bitmapOffset_.set(clip_bounds.x(), clip_bounds.y()); | 327 bitmapOffset_.set(clip_bounds.x(), clip_bounds.y()); |
| 328 | 328 |
| 329 // Now make clip_bounds be relative to the current layer/device | 329 // Now make clip_bounds be relative to the current layer/device |
| 330 if (!bitmapIsDummy_) { | 330 if (!bitmapIsDummy_) { |
| 331 canvas_->temporary_internal_describeTopLayer(nullptr, &clip_bounds); | 331 canvas_->temporary_internal_describeTopLayer(nullptr, &clip_bounds); |
| 332 } | 332 } |
| 333 | 333 |
| 334 SkPixmap devicePixels; | 334 SkPixmap devicePixels; |
| 335 skia::GetWritablePixels(canvas_, &devicePixels); | 335 skia::GetWritablePixels(canvas_, &devicePixels); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix)); | 378 CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix)); |
| 379 | 379 |
| 380 return cgContext_; | 380 return cgContext_; |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool SkiaBitLocker::hasEmptyClipRegion() const { | 383 bool SkiaBitLocker::hasEmptyClipRegion() const { |
| 384 return canvas_->isClipEmpty(); | 384 return canvas_->isClipEmpty(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace skia | 387 } // namespace skia |
| OLD | NEW |