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

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

Issue 2277053002: Add drawRegion() API to SkCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added shader to test Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkImage_Base.h" 9 #include "SkImage_Base.h"
10 #include "SkPatchUtils.h" 10 #include "SkPatchUtils.h"
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 444
445 void SkPictureRecord::onDrawRect(const SkRect& rect, const SkPaint& paint) { 445 void SkPictureRecord::onDrawRect(const SkRect& rect, const SkPaint& paint) {
446 // op + paint index + rect 446 // op + paint index + rect
447 size_t size = 2 * kUInt32Size + sizeof(rect); 447 size_t size = 2 * kUInt32Size + sizeof(rect);
448 size_t initialOffset = this->addDraw(DRAW_RECT, &size); 448 size_t initialOffset = this->addDraw(DRAW_RECT, &size);
449 this->addPaint(paint); 449 this->addPaint(paint);
450 this->addRect(rect); 450 this->addRect(rect);
451 this->validate(initialOffset, size); 451 this->validate(initialOffset, size);
452 } 452 }
453 453
454 void SkPictureRecord::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
455 // op + paint index + region
456 size_t regionBytes = region.writeToMemory(nullptr);
457 size_t size = 2 * kUInt32Size + regionBytes;
458 size_t initialOffset = this->addDraw(DRAW_REGION, &size);
459 this->addPaint(paint);
460 fWriter.writeRegion(region);
461 this->validate(initialOffset, size);
462 }
463
454 void SkPictureRecord::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { 464 void SkPictureRecord::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
455 // op + paint index + rrect 465 // op + paint index + rrect
456 size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory; 466 size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory;
457 size_t initialOffset = this->addDraw(DRAW_RRECT, &size); 467 size_t initialOffset = this->addDraw(DRAW_RRECT, &size);
458 this->addPaint(paint); 468 this->addPaint(paint);
459 this->addRRect(rrect); 469 this->addRRect(rrect);
460 this->validate(initialOffset, size); 470 this->validate(initialOffset, size);
461 } 471 }
462 472
463 void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, 473 void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 982
973 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 983 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
974 int index = fTextBlobRefs.count(); 984 int index = fTextBlobRefs.count();
975 *fTextBlobRefs.append() = blob; 985 *fTextBlobRefs.append() = blob;
976 blob->ref(); 986 blob->ref();
977 // follow the convention of recording a 1-based index 987 // follow the convention of recording a 1-based index
978 this->addInt(index + 1); 988 this->addInt(index + 1);
979 } 989 }
980 990
981 /////////////////////////////////////////////////////////////////////////////// 991 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698