aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkImageGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-04-07 12:04:23 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-07 16:59:42 +0000
commit4e3abc1ad5f078ed55cbc0c0ef0e14062a39bd13 (patch)
treef471bfd8072bf90d07860b6cf02345ebd9da324c /src/core/SkImageGenerator.cpp
parent45cde31b2e4e192e26984d15ffb2f718ef5f1055 (diff)
cacherator upscales colortables to unify caching
Bug: skia: Change-Id: Ib63f96b83d696743bbe4335c998acd4d2ea8acdb Reviewed-on: https://skia-review.googlesource.com/11787 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkImageGenerator.cpp')
-rw-r--r--src/core/SkImageGenerator.cpp70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index 2f209ca99c..f47bb1d160 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -120,76 +120,6 @@ bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb
#include "SkBitmap.h"
#include "SkColorTable.h"
-static bool reset_and_return_false(SkBitmap* bitmap) {
- bitmap->reset();
- return false;
-}
-
-bool SkImageGenerator::tryGenerateBitmap(SkBitmap* bitmap, const SkImageInfo& info,
- SkBitmap::Allocator* allocator) {
- if (0 == info.getSafeSize(info.minRowBytes())) {
- return false;
- }
- if (!bitmap->setInfo(info)) {
- return reset_and_return_false(bitmap);
- }
-
- SkPMColor ctStorage[256];
- memset(ctStorage, 0xFF, sizeof(ctStorage)); // init with opaque-white for the moment
- sk_sp<SkColorTable> ctable(new SkColorTable(ctStorage, 256));
- if (!bitmap->tryAllocPixels(allocator, ctable.get())) {
- // SkResourceCache's custom allcator can'thandle ctables, so it may fail on
- // kIndex_8_SkColorTable.
- // https://bug.skia.org/4355
-#if 1
- // ignore the allocator, and see if we can succeed without it
- if (!bitmap->tryAllocPixels(nullptr, ctable.get())) {
- return reset_and_return_false(bitmap);
- }
-#else
- // this is the up-scale technique, not fully debugged, but we keep it here at the moment
- // to remind ourselves that this might be better than ignoring the allocator.
-
- info = SkImageInfo::MakeN32(info.width(), info.height(), info.alphaType());
- if (!bitmap->setInfo(info)) {
- return reset_and_return_false(bitmap);
- }
- // we pass nullptr for the ctable arg, since we are now explicitly N32
- if (!bitmap->tryAllocPixels(allocator, nullptr)) {
- return reset_and_return_false(bitmap);
- }
-#endif
- }
-
- bitmap->lockPixels();
- if (!bitmap->getPixels()) {
- return reset_and_return_false(bitmap);
- }
-
- int ctCount = 0;
- if (!this->getPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes(),
- ctStorage, &ctCount)) {
- return reset_and_return_false(bitmap);
- }
-
- if (ctCount > 0) {
- SkASSERT(kIndex_8_SkColorType == bitmap->colorType());
- // we and bitmap should be owners
- SkASSERT(!ctable->unique());
-
- // Now we need to overwrite the ctable we built earlier, with the correct colors.
- // This does mean that we may have made the table too big, but that cannot be avoided
- // until we can change SkImageGenerator's API to return us the ctable *before* we have to
- // allocate space for all the pixels.
- ctable->dangerous_overwriteColors(ctStorage, ctCount);
- } else {
- SkASSERT(kIndex_8_SkColorType != bitmap->colorType());
- // we should be the only owner
- SkASSERT(ctable->unique());
- }
- return true;
-}
-
#include "SkGraphics.h"
static SkGraphics::ImageGeneratorFromEncodedDataFactory gFactory;