aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-09-24 00:21:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-24 00:21:20 -0700
commitdd42e5c05ce2f5e6da9a055544849dd8ae4e6733 (patch)
tree2c39bb67b7a22a3d2c38bcb5fff48533295e4551 /src
parentef2e4ac2347d8d6f1db5960388597b97ae73378b (diff)
Revert "Revert of remove unused SkCachingPixelRef (patchset #1 id:1 of https://codereview.chromium.org/1364743002/ )"
removed test for unsupported SkInstallDiscardable... This reverts commit 60c73d51808b9d78f65381b83f628a3f523042fe. BUG=skia: TBR= Review URL: https://codereview.chromium.org/1369443002
Diffstat (limited to 'src')
-rw-r--r--src/lazy/SkCachingPixelRef.cpp74
-rw-r--r--src/lazy/SkCachingPixelRef.h67
2 files changed, 0 insertions, 141 deletions
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp
deleted file mode 100644
index 692e4ea3d6..0000000000
--- a/src/lazy/SkCachingPixelRef.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkCachingPixelRef.h"
-#include "SkBitmapCache.h"
-#include "SkRect.h"
-
-bool SkCachingPixelRef::Install(SkImageGenerator* generator,
- SkBitmap* dst) {
- SkASSERT(dst != nullptr);
- if (nullptr == generator) {
- return false;
- }
- const SkImageInfo info = generator->getInfo();
- if (!dst->setInfo(info)) {
- delete generator;
- return false;
- }
- SkAutoTUnref<SkCachingPixelRef> ref(new SkCachingPixelRef(info, generator, dst->rowBytes()));
- dst->setPixelRef(ref);
- return true;
-}
-
-SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info,
- SkImageGenerator* generator,
- size_t rowBytes)
- : INHERITED(info)
- , fImageGenerator(generator)
- , fErrorInDecoding(false)
- , fRowBytes(rowBytes) {
- SkASSERT(fImageGenerator != nullptr);
-}
-SkCachingPixelRef::~SkCachingPixelRef() {
- delete fImageGenerator;
- // Assert always unlock before unref.
-}
-
-bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) {
- if (fErrorInDecoding) {
- return false; // don't try again.
- }
-
- const SkImageInfo& info = this->info();
- if (!SkBitmapCache::Find(
- this->getGenerationID(), info.bounds(), &fLockedBitmap)) {
- // Cache has been purged, must re-decode.
- if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) {
- fErrorInDecoding = true;
- return false;
- }
- if (!fImageGenerator->getPixels(info, fLockedBitmap.getPixels(), fRowBytes)) {
- fErrorInDecoding = true;
- return false;
- }
- fLockedBitmap.setImmutable();
- SkBitmapCache::Add(this, info.bounds(), fLockedBitmap);
- }
-
- // Now bitmap should contain a concrete PixelRef of the decoded image.
- void* pixels = fLockedBitmap.getPixels();
- SkASSERT(pixels != nullptr);
- rec->fPixels = pixels;
- rec->fColorTable = nullptr;
- rec->fRowBytes = fLockedBitmap.rowBytes();
- return true;
-}
-
-void SkCachingPixelRef::onUnlockPixels() {
- fLockedBitmap.reset();
-}
diff --git a/src/lazy/SkCachingPixelRef.h b/src/lazy/SkCachingPixelRef.h
deleted file mode 100644
index 1057441d5e..0000000000
--- a/src/lazy/SkCachingPixelRef.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkCachingPixelRef_DEFINED
-#define SkCachingPixelRef_DEFINED
-
-#include "SkBitmapCache.h"
-#include "SkImageInfo.h"
-#include "SkImageGenerator.h"
-#include "SkPixelRef.h"
-
-class SkColorTable;
-
-/**
- * PixelRef which defers decoding until SkBitmap::lockPixels() is
- * called. Caches the decoded images in the global
- * SkScaledImageCache. When the pixels are unlocked, this cache may
- * or be destroyed before the next lock. If so, onLockPixels will
- * attempt to re-decode.
- *
- * Decoding is handled by the SkImageGenerator
- */
-class SkCachingPixelRef : public SkPixelRef {
-public:
-
- /**
- * Takes ownership of SkImageGenerator. If this method fails for
- * whatever reason, it will return false and immediatetely delete
- * the generator. If it succeeds, it will modify destination
- * bitmap.
- *
- * If Install fails or when the SkCachingPixelRef that is
- * installed into destination is destroyed, it will call
- * `delete` on the generator. Therefore, generator should be
- * allocated with `new`.
- */
- static bool Install(SkImageGenerator* gen, SkBitmap* dst);
-
-protected:
- virtual ~SkCachingPixelRef();
- bool onNewLockPixels(LockRec*) override;
- void onUnlockPixels() override;
- bool onLockPixelsAreWritable() const override { return false; }
-
- SkData* onRefEncodedData() override {
- return fImageGenerator->refEncodedData();
- }
-
- bool onIsLazyGenerated() const override { return true; }
-
-private:
- SkImageGenerator* const fImageGenerator;
- bool fErrorInDecoding;
- const size_t fRowBytes;
-
- SkBitmap fLockedBitmap;
-
- SkCachingPixelRef(const SkImageInfo&, SkImageGenerator*, size_t rowBytes);
-
- typedef SkPixelRef INHERITED;
-};
-
-#endif // SkCachingPixelRef_DEFINED