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

Side by Side Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 834633006: add ImageGenerator::NewFromData to porting layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add helper for SkInstallDiscardablePixelRef(SkData*, ...) Created 5 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDiscardablePixelRef.h" 8 #include "SkDiscardablePixelRef.h"
9 #include "SkDiscardableMemory.h" 9 #include "SkDiscardableMemory.h"
10 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (dst->empty()) { // Use a normal pixelref. 109 if (dst->empty()) { // Use a normal pixelref.
110 return dst->tryAllocPixels(); 110 return dst->tryAllocPixels();
111 } 111 }
112 SkAutoTUnref<SkDiscardablePixelRef> ref( 112 SkAutoTUnref<SkDiscardablePixelRef> ref(
113 SkNEW_ARGS(SkDiscardablePixelRef, 113 SkNEW_ARGS(SkDiscardablePixelRef,
114 (info, autoGenerator.detach(), dst->rowBytes(), factory))); 114 (info, autoGenerator.detach(), dst->rowBytes(), factory)));
115 dst->setPixelRef(ref); 115 dst->setPixelRef(ref);
116 return true; 116 return true;
117 } 117 }
118 118
119 // This is the public API 119 // These are the public API
120
120 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) { 121 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) {
121 return SkInstallDiscardablePixelRef(generator, dst, NULL); 122 return SkInstallDiscardablePixelRef(generator, dst, NULL);
122 } 123 }
124
125 bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
126 SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded);
127 return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : fals e;
128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698