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

Unified Diff: src/lazy/SkBitmapFactory.cpp

Issue 103033002: Big Cleanup: SkBitmapFactory, SkLazyPixelRef, SkImageCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase one last time 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | src/lazy/SkDiscardableMemoryPool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lazy/SkBitmapFactory.cpp
diff --git a/src/lazy/SkBitmapFactory.cpp b/src/lazy/SkBitmapFactory.cpp
deleted file mode 100644
index 17ecf47c86b1968c43752e635cd00b8ab7c5aa49..0000000000000000000000000000000000000000
--- a/src/lazy/SkBitmapFactory.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkBitmapFactory.h"
-
-#include "SkBitmap.h"
-#include "SkData.h"
-#include "SkImageCache.h"
-#include "SkImagePriv.h"
-#include "SkLazyPixelRef.h"
-
-SkBitmapFactory::SkBitmapFactory(SkBitmapFactory::DecodeProc proc)
- : fDecodeProc(proc)
- , fImageCache(NULL)
- , fCacheSelector(NULL) {
- SkASSERT(fDecodeProc != NULL);
-}
-
-SkBitmapFactory::~SkBitmapFactory() {
- SkSafeUnref(fImageCache);
- SkSafeUnref(fCacheSelector);
-}
-
-void SkBitmapFactory::setImageCache(SkImageCache *cache) {
- SkRefCnt_SafeAssign(fImageCache, cache);
- if (cache != NULL) {
- SkSafeUnref(fCacheSelector);
- fCacheSelector = NULL;
- }
-}
-
-void SkBitmapFactory::setCacheSelector(CacheSelector* selector) {
- SkRefCnt_SafeAssign(fCacheSelector, selector);
- if (selector != NULL) {
- SkSafeUnref(fImageCache);
- fImageCache = NULL;
- }
-}
-
-bool SkBitmapFactory::installPixelRef(SkData* data, SkBitmap* dst) {
- if (NULL == data || 0 == data->size() || dst == NULL) {
- return false;
- }
-
- SkImageInfo info;
- if (!fDecodeProc(data->data(), data->size(), &info, NULL)) {
- return false;
- }
-
- SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
-
- Target target;
- // FIMXE: There will be a problem if this rowbytes is calculated differently from
- // in SkLazyPixelRef.
- target.fRowBytes = SkImageMinRowBytes(info);
- dst->setConfig(config, info.fWidth, info.fHeight, target.fRowBytes, info.fAlphaType);
-
- // fImageCache and fCacheSelector are mutually exclusive.
- SkASSERT(NULL == fImageCache || NULL == fCacheSelector);
-
- SkImageCache* cache = NULL == fCacheSelector ? fImageCache : fCacheSelector->selectCache(info);
-
- if (cache != NULL) {
- // Now set a new LazyPixelRef on dst.
- SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef,
- (data, fDecodeProc, cache)));
- dst->setPixelRef(lazyRef);
- return true;
- } else {
- dst->allocPixels();
- target.fAddr = dst->getPixels();
- return fDecodeProc(data->data(), data->size(), &info, &target);
- }
-}
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | src/lazy/SkDiscardableMemoryPool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698