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

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

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add new file Created 6 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 | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
9 #include "SkCanvas.h" 8 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 9 #include "SkCanvasPriv.h"
11 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
12 #include "SkDeviceImageFilterProxy.h" 11 #include "SkDeviceImageFilterProxy.h"
13 #include "SkDraw.h" 12 #include "SkDraw.h"
14 #include "SkDrawFilter.h" 13 #include "SkDrawFilter.h"
15 #include "SkDrawLooper.h" 14 #include "SkDrawLooper.h"
16 #include "SkMetaData.h" 15 #include "SkMetaData.h"
17 #include "SkPathOps.h" 16 #include "SkPathOps.h"
18 #include "SkPatchUtils.h" 17 #include "SkPatchUtils.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 typedef SkTLazy<SkPaint> SkLazyPaint; 59 typedef SkTLazy<SkPaint> SkLazyPaint;
61 60
62 void SkCanvas::predrawNotify() { 61 void SkCanvas::predrawNotify() {
63 if (fSurfaceBase) { 62 if (fSurfaceBase) {
64 fSurfaceBase->aboutToDraw(SkSurface::kRetain_ContentChangeMode); 63 fSurfaceBase->aboutToDraw(SkSurface::kRetain_ContentChangeMode);
65 } 64 }
66 } 65 }
67 66
68 /////////////////////////////////////////////////////////////////////////////// 67 ///////////////////////////////////////////////////////////////////////////////
69 68
69 static uint32_t filter_paint_flags(const SkSurfaceProps& props, uint32_t flags) {
70 const uint32_t propFlags = props.flags();
71 if (propFlags & SkSurfaceProps::kDisallowDither_Flag) {
72 flags &= ~SkPaint::kDither_Flag;
73 }
74 if (propFlags & SkSurfaceProps::kDisallowAntiAlias_Flag) {
75 flags &= ~SkPaint::kAntiAlias_Flag;
76 }
77 return flags;
78 }
79
80 ///////////////////////////////////////////////////////////////////////////////
81
70 /* This is the record we keep for each SkBaseDevice that the user installs. 82 /* This is the record we keep for each SkBaseDevice that the user installs.
71 The clip/matrix/proc are fields that reflect the top of the save/restore 83 The clip/matrix/proc are fields that reflect the top of the save/restore
72 stack. Whenever the canvas changes, it marks a dirty flag, and then before 84 stack. Whenever the canvas changes, it marks a dirty flag, and then before
73 these are used (assuming we're not on a layer) we rebuild these cache 85 these are used (assuming we're not on a layer) we rebuild these cache
74 values: they reflect the top of the save stack, but translated and clipped 86 values: they reflect the top of the save stack, but translated and clipped
75 by the device's XY offset and bitmap-bounds. 87 by the device's XY offset and bitmap-bounds.
76 */ 88 */
77 struct DeviceCM { 89 struct DeviceCM {
78 DeviceCM* fNext; 90 DeviceCM* fNext;
79 SkBaseDevice* fDevice; 91 SkBaseDevice* fDevice;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 const SkPaint* fPaint; // May be null. 255 const SkPaint* fPaint; // May be null.
244 SkBool8 fSkipEmptyClips; 256 SkBool8 fSkipEmptyClips;
245 257
246 typedef SkDraw INHERITED; 258 typedef SkDraw INHERITED;
247 }; 259 };
248 260
249 ///////////////////////////////////////////////////////////////////////////// 261 /////////////////////////////////////////////////////////////////////////////
250 262
251 class AutoDrawLooper { 263 class AutoDrawLooper {
252 public: 264 public:
253 AutoDrawLooper(SkCanvas* canvas, const SkPaint& paint, 265 AutoDrawLooper(SkCanvas* canvas, const SkSurfaceProps& props, const SkPaint& paint,
254 bool skipLayerForImageFilter = false, 266 bool skipLayerForImageFilter = false,
255 const SkRect* bounds = NULL) : fOrigPaint(paint) { 267 const SkRect* bounds = NULL) : fOrigPaint(paint) {
256 fCanvas = canvas; 268 fCanvas = canvas;
257 fFilter = canvas->getDrawFilter(); 269 fFilter = canvas->getDrawFilter();
258 fPaint = NULL; 270 fPaint = &fOrigPaint;
259 fSaveCount = canvas->getSaveCount(); 271 fSaveCount = canvas->getSaveCount();
260 fDoClearImageFilter = false; 272 fDoClearImageFilter = false;
261 fDone = false; 273 fDone = false;
262 274
263 if (!skipLayerForImageFilter && fOrigPaint.getImageFilter()) { 275 if (!skipLayerForImageFilter && fOrigPaint.getImageFilter()) {
264 SkPaint tmp; 276 SkPaint tmp;
265 tmp.setImageFilter(fOrigPaint.getImageFilter()); 277 tmp.setImageFilter(fOrigPaint.getImageFilter());
266 (void)canvas->internalSaveLayer(bounds, &tmp, SkCanvas::kARGB_ClipLa yer_SaveFlag, 278 (void)canvas->internalSaveLayer(bounds, &tmp, SkCanvas::kARGB_ClipLa yer_SaveFlag,
267 true, SkCanvas::kFullLayer_SaveLayer Strategy); 279 true, SkCanvas::kFullLayer_SaveLayer Strategy);
268 // we'll clear the imageFilter for the actual draws in next(), so 280 // we'll clear the imageFilter for the actual draws in next(), so
269 // it will only be applied during the restore(). 281 // it will only be applied during the restore().
270 fDoClearImageFilter = true; 282 fDoClearImageFilter = true;
271 } 283 }
272 284
273 if (SkDrawLooper* looper = paint.getLooper()) { 285 if (SkDrawLooper* looper = paint.getLooper()) {
274 void* buffer = fLooperContextAllocator.reserveT<SkDrawLooper::Contex t>( 286 void* buffer = fLooperContextAllocator.reserveT<SkDrawLooper::Contex t>(
275 looper->contextSize()); 287 looper->contextSize());
276 fLooperContext = looper->createContext(canvas, buffer); 288 fLooperContext = looper->createContext(canvas, buffer);
277 fIsSimple = false; 289 fIsSimple = false;
278 } else { 290 } else {
279 fLooperContext = NULL; 291 fLooperContext = NULL;
280 // can we be marked as simple? 292 // can we be marked as simple?
281 fIsSimple = !fFilter && !fDoClearImageFilter; 293 fIsSimple = !fFilter && !fDoClearImageFilter;
282 } 294 }
295
296 uint32_t oldFlags = paint.getFlags();
297 fNewPaintFlags = filter_paint_flags(props, oldFlags);
298 if (fIsSimple && (fNewPaintFlags != oldFlags)) {
299 SkPaint* paint = fLazyPaint.set(fOrigPaint);
300 paint->setFlags(fNewPaintFlags);
301 fPaint = paint;
302 // if we're not simple, doNext() will take care of calling setFlags( )
303 }
283 } 304 }
284 305
285 ~AutoDrawLooper() { 306 ~AutoDrawLooper() {
286 if (fDoClearImageFilter) { 307 if (fDoClearImageFilter) {
287 fCanvas->internalRestore(); 308 fCanvas->internalRestore();
288 } 309 }
289 SkASSERT(fCanvas->getSaveCount() == fSaveCount); 310 SkASSERT(fCanvas->getSaveCount() == fSaveCount);
290 } 311 }
291 312
292 const SkPaint& paint() const { 313 const SkPaint& paint() const {
293 SkASSERT(fPaint); 314 SkASSERT(fPaint);
294 return *fPaint; 315 return *fPaint;
295 } 316 }
296 317
297 bool next(SkDrawFilter::Type drawType) { 318 bool next(SkDrawFilter::Type drawType) {
298 if (fDone) { 319 if (fDone) {
299 return false; 320 return false;
300 } else if (fIsSimple) { 321 } else if (fIsSimple) {
301 fDone = true; 322 fDone = true;
302 fPaint = &fOrigPaint;
303 return !fPaint->nothingToDraw(); 323 return !fPaint->nothingToDraw();
304 } else { 324 } else {
305 return this->doNext(drawType); 325 return this->doNext(drawType);
306 } 326 }
307 } 327 }
308 328
309 private: 329 private:
310 SkLazyPaint fLazyPaint; 330 SkLazyPaint fLazyPaint;
311 SkCanvas* fCanvas; 331 SkCanvas* fCanvas;
312 const SkPaint& fOrigPaint; 332 const SkPaint& fOrigPaint;
313 SkDrawFilter* fFilter; 333 SkDrawFilter* fFilter;
314 const SkPaint* fPaint; 334 const SkPaint* fPaint;
315 int fSaveCount; 335 int fSaveCount;
336 uint32_t fNewPaintFlags;
316 bool fDoClearImageFilter; 337 bool fDoClearImageFilter;
317 bool fDone; 338 bool fDone;
318 bool fIsSimple; 339 bool fIsSimple;
319 SkDrawLooper::Context* fLooperContext; 340 SkDrawLooper::Context* fLooperContext;
320 SkSmallAllocator<1, 32> fLooperContextAllocator; 341 SkSmallAllocator<1, 32> fLooperContextAllocator;
321 342
322 bool doNext(SkDrawFilter::Type drawType); 343 bool doNext(SkDrawFilter::Type drawType);
323 }; 344 };
324 345
325 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { 346 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
326 fPaint = NULL; 347 fPaint = NULL;
327 SkASSERT(!fIsSimple); 348 SkASSERT(!fIsSimple);
328 SkASSERT(fLooperContext || fFilter || fDoClearImageFilter); 349 SkASSERT(fLooperContext || fFilter || fDoClearImageFilter);
329 350
330 SkPaint* paint = fLazyPaint.set(fOrigPaint); 351 SkPaint* paint = fLazyPaint.set(fOrigPaint);
352 paint->setFlags(fNewPaintFlags);
331 353
332 if (fDoClearImageFilter) { 354 if (fDoClearImageFilter) {
333 paint->setImageFilter(NULL); 355 paint->setImageFilter(NULL);
334 } 356 }
335 357
336 if (fLooperContext && !fLooperContext->next(fCanvas, paint)) { 358 if (fLooperContext && !fLooperContext->next(fCanvas, paint)) {
337 fDone = true; 359 fDone = true;
338 return false; 360 return false;
339 } 361 }
340 if (fFilter) { 362 if (fFilter) {
(...skipping 14 matching lines...) Expand all
355 } 377 }
356 378
357 // call this after any possible paint modifiers 379 // call this after any possible paint modifiers
358 if (fPaint->nothingToDraw()) { 380 if (fPaint->nothingToDraw()) {
359 fPaint = NULL; 381 fPaint = NULL;
360 return false; 382 return false;
361 } 383 }
362 return true; 384 return true;
363 } 385 }
364 386
365 #include "SkColorPriv.h"
366
367 ////////// macros to place around the internal draw calls ////////////////// 387 ////////// macros to place around the internal draw calls //////////////////
368 388
369 #define LOOPER_BEGIN_DRAWDEVICE(paint, type) \ 389 #define LOOPER_BEGIN_DRAWDEVICE(paint, type) \
370 this->predrawNotify(); \ 390 this->predrawNotify(); \
371 AutoDrawLooper looper(this, paint, true); \ 391 AutoDrawLooper looper(this, fProps, paint, true); \
372 while (looper.next(type)) { \ 392 while (looper.next(type)) { \
373 SkDrawIter iter(this); 393 SkDrawIter iter(this);
374 394
375 #define LOOPER_BEGIN(paint, type, bounds) \ 395 #define LOOPER_BEGIN(paint, type, bounds) \
376 this->predrawNotify(); \ 396 this->predrawNotify(); \
377 AutoDrawLooper looper(this, paint, false, bounds); \ 397 AutoDrawLooper looper(this, fProps, paint, false, bounds); \
378 while (looper.next(type)) { \ 398 while (looper.next(type)) { \
379 SkDrawIter iter(this); 399 SkDrawIter iter(this);
380 400
381 #define LOOPER_END } 401 #define LOOPER_END }
382 402
383 //////////////////////////////////////////////////////////////////////////// 403 ////////////////////////////////////////////////////////////////////////////
384 404
405 void SkCanvas::setupDevice(SkBaseDevice* device) {
406 device->setPixelGeometry(fProps.pixelGeometry());
407 }
408
385 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { 409 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
386 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ; 410 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ;
387 fCachedLocalClipBounds.setEmpty(); 411 fCachedLocalClipBounds.setEmpty();
388 fCachedLocalClipBoundsDirty = true; 412 fCachedLocalClipBoundsDirty = true;
389 fAllowSoftClip = true; 413 fAllowSoftClip = true;
390 fAllowSimplifyClip = false; 414 fAllowSimplifyClip = false;
391 fDeviceCMDirty = true; 415 fDeviceCMDirty = true;
392 fSaveLayerCount = 0; 416 fSaveLayerCount = 0;
393 fCullCount = 0; 417 fCullCount = 0;
394 fMetaData = NULL; 418 fMetaData = NULL;
395 419
396 if (device && device->forceConservativeRasterClip()) {
397 fConservativeRasterClip = true;
398 }
399
400 fMCRec = (MCRec*)fMCStack.push_back(); 420 fMCRec = (MCRec*)fMCStack.push_back();
401 new (fMCRec) MCRec(fConservativeRasterClip); 421 new (fMCRec) MCRec(fConservativeRasterClip);
402 422
403 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL, fConservative RasterClip)); 423 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL, fConservative RasterClip));
404 fMCRec->fTopLayer = fMCRec->fLayer; 424 fMCRec->fTopLayer = fMCRec->fLayer;
405 425
406 fSurfaceBase = NULL; 426 fSurfaceBase = NULL;
407 427
408 if (device) { 428 if (device) {
429 this->setupDevice(device);
430 if (device->forceConservativeRasterClip()) {
431 fConservativeRasterClip = true;
432 }
409 device->onAttachToCanvas(this); 433 device->onAttachToCanvas(this);
410 fMCRec->fLayer->fDevice = SkRef(device); 434 fMCRec->fLayer->fDevice = SkRef(device);
411 fMCRec->fRasterClip.setRect(SkIRect::MakeWH(device->width(), device->hei ght())); 435 fMCRec->fRasterClip.setRect(SkIRect::MakeWH(device->width(), device->hei ght()));
412 } 436 }
413 return device; 437 return device;
414 } 438 }
415 439
416 SkCanvas::SkCanvas() 440 SkCanvas::SkCanvas()
417 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 441 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
442 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
418 { 443 {
419 inc_canvas(); 444 inc_canvas();
420 445
421 this->init(NULL, kDefault_InitFlags); 446 this->init(NULL, kDefault_InitFlags);
422 } 447 }
423 448
424 static SkBitmap make_nopixels(int width, int height) { 449 static SkBitmap make_nopixels(int width, int height) {
425 SkBitmap bitmap; 450 SkBitmap bitmap;
426 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); 451 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height));
427 return bitmap; 452 return bitmap;
428 } 453 }
429 454
430 class SkNoPixelsBitmapDevice : public SkBitmapDevice { 455 class SkNoPixelsBitmapDevice : public SkBitmapDevice {
431 public: 456 public:
432 SkNoPixelsBitmapDevice(int width, int height) : INHERITED(make_nopixels(widt h, height)) {} 457 SkNoPixelsBitmapDevice(int width, int height) : INHERITED(make_nopixels(widt h, height)) {}
433 458
434 private: 459 private:
435 460
436 typedef SkBitmapDevice INHERITED; 461 typedef SkBitmapDevice INHERITED;
437 }; 462 };
438 463
439 SkCanvas::SkCanvas(int width, int height) 464 SkCanvas::SkCanvas(int width, int height)
440 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 465 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
466 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
441 { 467 {
442 inc_canvas(); 468 inc_canvas();
443 469
444 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), kDefault_Ini tFlags)->unref(); 470 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), kDefault_Ini tFlags)->unref();
445 } 471 }
446 472
447 SkCanvas::SkCanvas(int width, int height, InitFlags flags) 473 SkCanvas::SkCanvas(int width, int height, InitFlags flags)
448 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 474 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
475 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
449 { 476 {
450 inc_canvas(); 477 inc_canvas();
451 478
452 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), flags)->unre f(); 479 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), flags)->unre f();
453 } 480 }
454 481
455 SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags) 482 SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags flags)
456 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 483 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
484 , fProps(SkSurfacePropsCopyOrDefault(props))
457 { 485 {
458 inc_canvas(); 486 inc_canvas();
459 487
460 this->init(device, flags); 488 this->init(device, flags);
461 } 489 }
462 490
463 SkCanvas::SkCanvas(SkBaseDevice* device) 491 SkCanvas::SkCanvas(SkBaseDevice* device)
464 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 492 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
493 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
465 { 494 {
466 inc_canvas(); 495 inc_canvas();
467 496
468 this->init(device, kDefault_InitFlags); 497 this->init(device, kDefault_InitFlags);
469 } 498 }
470 499
500 SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
501 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
502 , fProps(props)
503 {
504 inc_canvas();
505
506 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
507 this->init(device, kDefault_InitFlags);
508 }
509
471 SkCanvas::SkCanvas(const SkBitmap& bitmap) 510 SkCanvas::SkCanvas(const SkBitmap& bitmap)
472 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 511 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
512 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
473 { 513 {
474 inc_canvas(); 514 inc_canvas();
475 515
476 this->init(SkNEW_ARGS(SkBitmapDevice, (bitmap)), kDefault_InitFlags)->unref( ); 516 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
517 this->init(device, kDefault_InitFlags);
477 } 518 }
478 519
479 SkCanvas::~SkCanvas() { 520 SkCanvas::~SkCanvas() {
480 // free up the contents of our deque 521 // free up the contents of our deque
481 this->restoreToCount(1); // restore everything but the last 522 this->restoreToCount(1); // restore everything but the last
482 SkASSERT(0 == fSaveLayerCount); 523 SkASSERT(0 == fSaveLayerCount);
483 524
484 this->internalRestore(); // restore the last, since we're going away 525 this->internalRestore(); // restore the last, since we're going away
485 526
486 SkDELETE(fMetaData); 527 SkDELETE(fMetaData);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 598
558 if (device) { 599 if (device) {
559 device->onAttachToCanvas(this); 600 device->onAttachToCanvas(this);
560 } 601 }
561 if (rootDevice) { 602 if (rootDevice) {
562 rootDevice->onDetachFromCanvas(); 603 rootDevice->onDetachFromCanvas();
563 } 604 }
564 605
565 SkRefCnt_SafeAssign(rec->fLayer->fDevice, device); 606 SkRefCnt_SafeAssign(rec->fLayer->fDevice, device);
566 rootDevice = device; 607 rootDevice = device;
608 this->setupDevice(device);
567 609
568 fDeviceCMDirty = true; 610 fDeviceCMDirty = true;
569 611
570 /* Now we update our initial region to have the bounds of the new device, 612 /* Now we update our initial region to have the bounds of the new device,
571 and then intersect all of the clips in our stack with these bounds, 613 and then intersect all of the clips in our stack with these bounds,
572 to ensure that we can't draw outside of the device's bounds (and trash 614 to ensure that we can't draw outside of the device's bounds (and trash
573 memory). 615 memory).
574 616
575 NOTE: this is only a partial-fix, since if the new device is larger than 617 NOTE: this is only a partial-fix, since if the new device is larger than
576 the previous one, we don't know how to "enlarge" the clips in our stack, 618 the previous one, we don't know how to "enlarge" the clips in our stack,
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 if (device) { 934 if (device) {
893 device = device->createCompatibleDevice(info); 935 device = device->createCompatibleDevice(info);
894 } 936 }
895 } else { 937 } else {
896 device = this->createLayerDevice(info); 938 device = this->createLayerDevice(info);
897 } 939 }
898 if (NULL == device) { 940 if (NULL == device) {
899 SkDebugf("Unable to create device for layer."); 941 SkDebugf("Unable to create device for layer.");
900 return count; 942 return count;
901 } 943 }
944 this->setupDevice(device);
902 945
903 device->setOrigin(ir.fLeft, ir.fTop); 946 device->setOrigin(ir.fLeft, ir.fTop);
904 DeviceCM* layer = SkNEW_ARGS(DeviceCM, 947 DeviceCM* layer = SkNEW_ARGS(DeviceCM,
905 (device, ir.fLeft, ir.fTop, paint, this, fConse rvativeRasterClip)); 948 (device, ir.fLeft, ir.fTop, paint, this, fConse rvativeRasterClip));
906 device->unref(); 949 device->unref();
907 950
908 layer->fNext = fMCRec->fTopLayer; 951 layer->fNext = fMCRec->fTopLayer;
909 fMCRec->fLayer = layer; 952 fMCRec->fLayer = layer;
910 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer 953 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer
911 954
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 int n = this->getSaveCount() - count; 1030 int n = this->getSaveCount() - count;
988 for (int i = 0; i < n; ++i) { 1031 for (int i = 0; i < n; ++i) {
989 this->restore(); 1032 this->restore();
990 } 1033 }
991 } 1034 }
992 1035
993 bool SkCanvas::isDrawingToLayer() const { 1036 bool SkCanvas::isDrawingToLayer() const {
994 return fSaveLayerCount > 0; 1037 return fSaveLayerCount > 0;
995 } 1038 }
996 1039
997 SkSurface* SkCanvas::newSurface(const SkImageInfo& info) { 1040 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
998 return this->onNewSurface(info); 1041 if (NULL == props) {
1042 props = &fProps;
1043 }
1044 return this->onNewSurface(info, *props);
999 } 1045 }
1000 1046
1001 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) { 1047 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
1002 SkBaseDevice* dev = this->getDevice(); 1048 SkBaseDevice* dev = this->getDevice();
1003 return dev ? dev->newSurface(info) : NULL; 1049 return dev ? dev->newSurface(info, props) : NULL;
1004 } 1050 }
1005 1051
1006 SkImageInfo SkCanvas::imageInfo() const { 1052 SkImageInfo SkCanvas::imageInfo() const {
1007 SkBaseDevice* dev = this->getDevice(); 1053 SkBaseDevice* dev = this->getDevice();
1008 if (dev) { 1054 if (dev) {
1009 return dev->imageInfo(); 1055 return dev->imageInfo();
1010 } else { 1056 } else {
1011 return SkImageInfo::MakeUnknown(0, 0); 1057 return SkImageInfo::MakeUnknown(0, 0);
1012 } 1058 }
1013 } 1059 }
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 } 2536 }
2491 2537
2492 if (matrix) { 2538 if (matrix) {
2493 canvas->concat(*matrix); 2539 canvas->concat(*matrix);
2494 } 2540 }
2495 } 2541 }
2496 2542
2497 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2543 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2498 fCanvas->restoreToCount(fSaveCount); 2544 fCanvas->restoreToCount(fSaveCount);
2499 } 2545 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698