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

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

Issue 140593005: add legacy/helper allocN32Pixels, and convert gm to use it (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkBitmap.h ('k') | 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 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
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 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 releaseProc, context); 542 releaseProc, context);
543 if (!pr) { 543 if (!pr) {
544 this->reset(); 544 this->reset();
545 return false; 545 return false;
546 } 546 }
547 547
548 this->setPixelRef(pr)->unref(); 548 this->setPixelRef(pr)->unref();
549 return true; 549 return true;
550 } 550 }
551 551
552 bool SkBitmap::allocConfigPixels(Config config, int width, int height,
553 bool isOpaque) {
554 SkColorType ct;
555 if (!config_to_colorType(config, &ct)) {
556 return false;
557 }
558
559 SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
560 if (!validate_alphaType(config, at, &at)) {
561 return false;
562 }
563
564 return this->allocPixels(SkImageInfo::Make(width, height, ct, at));
565 }
566
567 ///////////////////////////////////////////////////////////////////////////////
568
552 void SkBitmap::freePixels() { 569 void SkBitmap::freePixels() {
553 // if we're gonna free the pixels, we certainly need to free the mipmap 570 // if we're gonna free the pixels, we certainly need to free the mipmap
554 this->freeMipMap(); 571 this->freeMipMap();
555 572
556 if (NULL != fPixelRef) { 573 if (NULL != fPixelRef) {
557 if (fPixelLockCount > 0) { 574 if (fPixelLockCount > 0) {
558 fPixelRef->unlockPixels(); 575 fPixelRef->unlockPixels();
559 } 576 }
560 fPixelRef->unref(); 577 fPixelRef->unref();
561 fPixelRef = NULL; 578 fPixelRef = NULL;
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 if (NULL != uri) { 1720 if (NULL != uri) {
1704 str->appendf(" uri:\"%s\"", uri); 1721 str->appendf(" uri:\"%s\"", uri);
1705 } else { 1722 } else {
1706 str->appendf(" pixelref:%p", pr); 1723 str->appendf(" pixelref:%p", pr);
1707 } 1724 }
1708 } 1725 }
1709 1726
1710 str->append(")"); 1727 str->append(")");
1711 } 1728 }
1712 #endif 1729 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698