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

Side by Side Diff: src/pipe/SkGPipeWrite.cpp

Issue 285693007: Reland one more bug fix from "4x allocation in PipeController is probably overkill.". (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 if (this->needOpBytes(path.writeToMemory(NULL))) { 755 if (this->needOpBytes(path.writeToMemory(NULL))) {
756 this->writeOp(kDrawPath_DrawOp); 756 this->writeOp(kDrawPath_DrawOp);
757 fWriter.writePath(path); 757 fWriter.writePath(path);
758 } 758 }
759 } 759 }
760 760
761 bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op, 761 bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op,
762 unsigned flags, 762 unsigned flags,
763 size_t opBytesNeeded, 763 size_t opBytesNeeded,
764 const SkPaint* paint) { 764 const SkPaint* paint) {
765 if (fDone) {
766 return false;
767 }
768
765 if (paint != NULL) { 769 if (paint != NULL) {
766 flags |= kDrawBitmap_HasPaint_DrawOpFlag; 770 flags |= kDrawBitmap_HasPaint_DrawOpFlag;
767 this->writePaint(*paint); 771 this->writePaint(*paint);
768 } 772 }
773 // This needs to run first so its calls to needOpBytes() and its writes
774 // don't interlace with the needOpBytes() and write below.
775 SkASSERT(fBitmapHeap != NULL);
776 int32_t bitmapIndex = fBitmapHeap->insert(bm);
777 if (SkBitmapHeap::INVALID_SLOT == bitmapIndex) {
778 return false;
779 }
780
769 if (this->needOpBytes(opBytesNeeded)) { 781 if (this->needOpBytes(opBytesNeeded)) {
770 SkASSERT(fBitmapHeap != NULL);
771 int32_t bitmapIndex = fBitmapHeap->insert(bm);
772 if (SkBitmapHeap::INVALID_SLOT == bitmapIndex) {
773 return false;
774 }
775 this->writeOp(op, flags, bitmapIndex); 782 this->writeOp(op, flags, bitmapIndex);
776 return true; 783 return true;
777 } 784 }
778 return false; 785 return false;
779 } 786 }
780 787
781 void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top, 788 void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top,
782 const SkPaint* paint) { 789 const SkPaint* paint) {
783 NOTIFY_SETUP(this); 790 NOTIFY_SETUP(this);
784 size_t opBytesNeeded = sizeof(SkScalar) * 2; 791 size_t opBytesNeeded = sizeof(SkScalar) * 2;
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 return fCanvas->shuttleBitmap(bitmap, slot); 1257 return fCanvas->shuttleBitmap(bitmap, slot);
1251 } 1258 }
1252 1259
1253 void BitmapShuttle::removeCanvas() { 1260 void BitmapShuttle::removeCanvas() {
1254 if (NULL == fCanvas) { 1261 if (NULL == fCanvas) {
1255 return; 1262 return;
1256 } 1263 }
1257 fCanvas->unref(); 1264 fCanvas->unref();
1258 fCanvas = NULL; 1265 fCanvas = NULL;
1259 } 1266 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698