| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkCanvasDrawable.h" | 9 #include "SkCanvasDrawable.h" |
| 10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 424 |
| 425 fSurfaceBase = NULL; | 425 fSurfaceBase = NULL; |
| 426 | 426 |
| 427 if (device) { | 427 if (device) { |
| 428 device->initForRootLayer(fProps.pixelGeometry()); | 428 device->initForRootLayer(fProps.pixelGeometry()); |
| 429 if (device->forceConservativeRasterClip()) { | 429 if (device->forceConservativeRasterClip()) { |
| 430 fConservativeRasterClip = true; | 430 fConservativeRasterClip = true; |
| 431 } | 431 } |
| 432 device->onAttachToCanvas(this); | 432 device->onAttachToCanvas(this); |
| 433 fMCRec->fLayer->fDevice = SkRef(device); | 433 fMCRec->fLayer->fDevice = SkRef(device); |
| 434 fMCRec->fRasterClip.setRect(device->getGlobalBounds()); | 434 fMCRec->fRasterClip.setRect(SkIRect::MakeWH(device->width(), device->hei
ght())); |
| 435 } | 435 } |
| 436 return device; | 436 return device; |
| 437 } | 437 } |
| 438 | 438 |
| 439 SkCanvas::SkCanvas() | 439 SkCanvas::SkCanvas() |
| 440 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 440 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 441 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | 441 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) |
| 442 { | 442 { |
| 443 inc_canvas(); | 443 inc_canvas(); |
| 444 | 444 |
| 445 this->init(NULL, kDefault_InitFlags); | 445 this->init(NULL, kDefault_InitFlags); |
| 446 } | 446 } |
| 447 | 447 |
| 448 static SkBitmap make_nopixels(int width, int height) { | 448 static SkBitmap make_nopixels(int width, int height) { |
| 449 SkBitmap bitmap; | 449 SkBitmap bitmap; |
| 450 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); | 450 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); |
| 451 return bitmap; | 451 return bitmap; |
| 452 } | 452 } |
| 453 | 453 |
| 454 class SkNoPixelsBitmapDevice : public SkBitmapDevice { | 454 class SkNoPixelsBitmapDevice : public SkBitmapDevice { |
| 455 public: | 455 public: |
| 456 SkNoPixelsBitmapDevice(const SkIRect& bounds) | 456 SkNoPixelsBitmapDevice(int width, int height) : INHERITED(make_nopixels(widt
h, height)) {} |
| 457 : INHERITED(make_nopixels(bounds.width(), bounds.height())) | |
| 458 { | |
| 459 this->setOrigin(bounds.x(), bounds.y()); | |
| 460 } | |
| 461 | 457 |
| 462 private: | 458 private: |
| 463 | 459 |
| 464 typedef SkBitmapDevice INHERITED; | 460 typedef SkBitmapDevice INHERITED; |
| 465 }; | 461 }; |
| 466 | 462 |
| 467 SkCanvas::SkCanvas(int width, int height) | 463 SkCanvas::SkCanvas(int width, int height) |
| 468 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 464 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 469 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | 465 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) |
| 470 { | 466 { |
| 471 inc_canvas(); | 467 inc_canvas(); |
| 472 | 468 |
| 473 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, | 469 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), kDefault_Ini
tFlags)->unref(); |
| 474 (SkIRect::MakeWH(width, height))), kDefault_InitFlags)
->unref(); | |
| 475 } | 470 } |
| 476 | 471 |
| 477 SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags) | 472 SkCanvas::SkCanvas(int width, int height, InitFlags flags) |
| 478 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 473 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 479 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | 474 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) |
| 480 { | 475 { |
| 481 inc_canvas(); | 476 inc_canvas(); |
| 482 | 477 |
| 483 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (bounds)), flags)->unref(); | 478 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), flags)->unre
f(); |
| 484 } | 479 } |
| 485 | 480 |
| 486 SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags
flags) | 481 SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags
flags) |
| 487 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 482 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 488 , fProps(SkSurfacePropsCopyOrDefault(props)) | 483 , fProps(SkSurfacePropsCopyOrDefault(props)) |
| 489 { | 484 { |
| 490 inc_canvas(); | 485 inc_canvas(); |
| 491 | 486 |
| 492 this->init(device, flags); | 487 this->init(device, flags); |
| 493 } | 488 } |
| (...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2584 } | 2579 } |
| 2585 | 2580 |
| 2586 if (matrix) { | 2581 if (matrix) { |
| 2587 canvas->concat(*matrix); | 2582 canvas->concat(*matrix); |
| 2588 } | 2583 } |
| 2589 } | 2584 } |
| 2590 | 2585 |
| 2591 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2586 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2592 fCanvas->restoreToCount(fSaveCount); | 2587 fCanvas->restoreToCount(fSaveCount); |
| 2593 } | 2588 } |
| OLD | NEW |