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

Side by Side Diff: src/core/SkCanvas.cpp

Issue 736583004: allow pictures to have a full bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use new roundOut Created 6 years, 1 month 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 /* 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
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(SkIRect::MakeWH(device->width(), device->hei ght())); 434 fMCRec->fRasterClip.setRect(device->getGlobalBounds());
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(int width, int height) : INHERITED(make_nopixels(widt h, height)) {} 456 SkNoPixelsBitmapDevice(const SkIRect& bounds)
457 : INHERITED(make_nopixels(bounds.width(), bounds.height()))
458 {
459 this->setOrigin(bounds.x(), bounds.y());
460 }
457 461
458 private: 462 private:
459 463
460 typedef SkBitmapDevice INHERITED; 464 typedef SkBitmapDevice INHERITED;
461 }; 465 };
462 466
463 SkCanvas::SkCanvas(int width, int height) 467 SkCanvas::SkCanvas(int width, int height)
464 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 468 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
465 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) 469 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
466 { 470 {
467 inc_canvas(); 471 inc_canvas();
468 472
469 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), kDefault_Ini tFlags)->unref(); 473 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice,
474 (SkIRect::MakeWH(width, height))), kDefault_InitFlags) ->unref();
470 } 475 }
471 476
472 SkCanvas::SkCanvas(int width, int height, InitFlags flags) 477 SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
473 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 478 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
474 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) 479 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
475 { 480 {
476 inc_canvas(); 481 inc_canvas();
477 482
478 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), flags)->unre f(); 483 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (bounds)), flags)->unref();
479 } 484 }
480 485
481 SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags flags) 486 SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags flags)
482 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 487 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
483 , fProps(SkSurfacePropsCopyOrDefault(props)) 488 , fProps(SkSurfacePropsCopyOrDefault(props))
484 { 489 {
485 inc_canvas(); 490 inc_canvas();
486 491
487 this->init(device, flags); 492 this->init(device, flags);
488 } 493 }
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 } 2584 }
2580 2585
2581 if (matrix) { 2586 if (matrix) {
2582 canvas->concat(*matrix); 2587 canvas->concat(*matrix);
2583 } 2588 }
2584 } 2589 }
2585 2590
2586 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2591 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2587 fCanvas->restoreToCount(fSaveCount); 2592 fCanvas->restoreToCount(fSaveCount);
2588 } 2593 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698