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/SkBitmap.cpp

Issue 108663004: make info real in SkPixelRef, and add bitmap::asImageInfo (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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/SkPixelRef.h ('k') | src/image/SkImagePriv.h » ('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 /* 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 SkASSERT(0 == fPixelLockCount); 354 SkASSERT(0 == fPixelLockCount);
355 fPixels = NULL; 355 fPixels = NULL;
356 if (fColorTable) { 356 if (fColorTable) {
357 fColorTable->unref(); 357 fColorTable->unref();
358 fColorTable = NULL; 358 fColorTable = NULL;
359 } 359 }
360 } 360 }
361 } 361 }
362 } 362 }
363 363
364 static bool config_to_colorType(SkBitmap::Config config, SkColorType* ctOut) {
365 SkColorType ct;
366 switch (config) {
367 case SkBitmap::kA8_Config:
368 ct = kAlpha_8_SkColorType;
369 break;
370 case SkBitmap::kIndex8_Config:
371 ct = kIndex_8_SkColorType;
372 break;
373 case SkBitmap::kRGB_565_Config:
374 ct = kRGB_565_SkColorType;
375 break;
376 case SkBitmap::kARGB_4444_Config:
377 ct = kARGB_4444_SkColorType;
378 break;
379 case SkBitmap::kARGB_8888_Config:
380 ct = kPMColor_SkColorType;
381 break;
382 case SkBitmap::kNo_Config:
383 default:
384 return false;
385 }
386 if (ctOut) {
387 *ctOut = ct;
388 }
389 return true;
390 }
391
392 bool SkBitmap::asImageInfo(SkImageInfo* info) const {
393 SkColorType ct;
394 if (!config_to_colorType(this->config(), &ct)) {
395 return false;
396 }
397 if (info) {
398 info->fWidth = fWidth;
399 info->fHeight = fHeight;
400 info->fAlphaType = this->alphaType();
401 info->fColorType = ct;
402 }
403 return true;
404 }
405
364 SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) { 406 SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) {
365 // do this first, we that we never have a non-zero offset with a null ref 407 // do this first, we that we never have a non-zero offset with a null ref
366 if (NULL == pr) { 408 if (NULL == pr) {
367 offset = 0; 409 offset = 0;
368 } 410 }
369 411
370 if (fPixelRef != pr || fPixelRefOffset != offset) { 412 if (fPixelRef != pr || fPixelRefOffset != offset) {
371 if (fPixelRef != pr) { 413 if (fPixelRef != pr) {
372 this->freePixels(); 414 this->freePixels();
373 SkASSERT(NULL == fPixelRef); 415 SkASSERT(NULL == fPixelRef);
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 if (NULL != uri) { 1699 if (NULL != uri) {
1658 str->appendf(" uri:\"%s\"", uri); 1700 str->appendf(" uri:\"%s\"", uri);
1659 } else { 1701 } else {
1660 str->appendf(" pixelref:%p", pr); 1702 str->appendf(" pixelref:%p", pr);
1661 } 1703 }
1662 } 1704 }
1663 1705
1664 str->append(")"); 1706 str->append(")");
1665 } 1707 }
1666 #endif 1708 #endif
OLDNEW
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/image/SkImagePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698