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

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

Issue 354143004: remove unnecessary bitmapdevice references (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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/animator/SkDrawBitmap.cpp ('k') | src/lazy/SkCachingPixelRef.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 /* 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 HeapAllocator stdalloc; 359 HeapAllocator stdalloc;
360 360
361 if (NULL == allocator) { 361 if (NULL == allocator) {
362 allocator = &stdalloc; 362 allocator = &stdalloc;
363 } 363 }
364 return allocator->allocPixelRef(this, ctable); 364 return allocator->allocPixelRef(this, ctable);
365 } 365 }
366 366
367 /////////////////////////////////////////////////////////////////////////////// 367 ///////////////////////////////////////////////////////////////////////////////
368 368
369 bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) {
370 if (kIndex_8_SkColorType == requestedInfo.colorType()) {
371 return reset_return_false(this);
372 }
373 if (!this->setInfo(requestedInfo)) {
374 return reset_return_false(this);
375 }
376
377 // setInfo may have corrected info (e.g. 565 is always opaque).
378 const SkImageInfo& correctedInfo = this->info();
379 if (!correctedInfo.validRowBytes(rowBytes)) {
380 return reset_return_false(this);
381 }
382
383 SkMallocPixelRef::PRFactory defaultFactory;
384
385 SkPixelRef* pr = defaultFactory.create(correctedInfo, NULL);
386 if (NULL == pr) {
387 return reset_return_false(this);
388 }
389 this->setPixelRef(pr)->unref();
390
391 // TODO: lockPixels could/should return bool or void*/NULL
392 this->lockPixels();
393 if (NULL == this->getPixels()) {
394 return reset_return_false(this);
395 }
396 return true;
397 }
398
369 bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactory* factory, 399 bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactory* factory,
370 SkColorTable* ctable) { 400 SkColorTable* ctable) {
371 if (kIndex_8_SkColorType == requestedInfo.fColorType && NULL == ctable) { 401 if (kIndex_8_SkColorType == requestedInfo.fColorType && NULL == ctable) {
372 return reset_return_false(this); 402 return reset_return_false(this);
373 } 403 }
374 if (!this->setInfo(requestedInfo)) { 404 if (!this->setInfo(requestedInfo)) {
375 return reset_return_false(this); 405 return reset_return_false(this);
376 } 406 }
377 407
378 // setInfo may have corrected info (e.g. 565 is always opaque). 408 // setInfo may have corrected info (e.g. 565 is always opaque).
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 /////////////////////////////////////////////////////////////////////////////// 1456 ///////////////////////////////////////////////////////////////////////////////
1427 1457
1428 #ifdef SK_DEBUG 1458 #ifdef SK_DEBUG
1429 void SkImageInfo::validate() const { 1459 void SkImageInfo::validate() const {
1430 SkASSERT(fWidth >= 0); 1460 SkASSERT(fWidth >= 0);
1431 SkASSERT(fHeight >= 0); 1461 SkASSERT(fHeight >= 0);
1432 SkASSERT(SkColorTypeIsValid(fColorType)); 1462 SkASSERT(SkColorTypeIsValid(fColorType));
1433 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1463 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1434 } 1464 }
1435 #endif 1465 #endif
OLDNEW
« no previous file with comments | « src/animator/SkDrawBitmap.cpp ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698