blob: 035ddccfb80a34cdf3407ef1d9caaa00112384ed [file] [log] [blame]
reed85d91782015-09-10 14:33:38 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "SkImage_Base.h"
reed85d91782015-09-10 14:33:38 -07009#include "SkImageCacherator.h"
Brian Osmandf7e0752017-04-26 16:20:28 -040010
11#include "SkBitmap.h"
12#include "SkBitmapCache.h"
Brian Osmandf7e0752017-04-26 16:20:28 -040013#include "SkData.h"
14#include "SkImageGenerator.h"
reed85d91782015-09-10 14:33:38 -070015#include "SkImagePriv.h"
Brian Osmandf7e0752017-04-26 16:20:28 -040016#include "SkNextID.h"
reed85d91782015-09-10 14:33:38 -070017#include "SkPixelRef.h"
reed85d91782015-09-10 14:33:38 -070018
Brian Osmandf7e0752017-04-26 16:20:28 -040019#if SK_SUPPORT_GPU
20#include "GrContext.h"
21#include "GrContextPriv.h"
22#include "GrGpuResourcePriv.h"
23#include "GrImageTextureMaker.h"
24#include "GrResourceKey.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050025#include "GrProxyProvider.h"
Brian Salomon2bbdcc42017-09-07 12:36:34 -040026#include "GrSamplerState.h"
Brian Osmandf7e0752017-04-26 16:20:28 -040027#include "GrYUVProvider.h"
28#include "SkGr.h"
29#endif
reed85d91782015-09-10 14:33:38 -070030
Brian Osmandf7e0752017-04-26 16:20:28 -040031// Ref-counted tuple(SkImageGenerator, SkMutex) which allows sharing one generator among N images
32class SharedGenerator final : public SkNVRefCnt<SharedGenerator> {
33public:
34 static sk_sp<SharedGenerator> Make(std::unique_ptr<SkImageGenerator> gen) {
35 return gen ? sk_sp<SharedGenerator>(new SharedGenerator(std::move(gen))) : nullptr;
36 }
37
Matt Sarettb2004f72017-05-18 09:26:50 -040038 // This is thread safe. It is a const field set in the constructor.
39 const SkImageInfo& getInfo() { return fGenerator->getInfo(); }
40
Brian Osmandf7e0752017-04-26 16:20:28 -040041private:
42 explicit SharedGenerator(std::unique_ptr<SkImageGenerator> gen)
43 : fGenerator(std::move(gen)) {
44 SkASSERT(fGenerator);
45 }
46
47 friend class ScopedGenerator;
48 friend class SkImage_Lazy;
49
50 std::unique_ptr<SkImageGenerator> fGenerator;
51 SkMutex fMutex;
52};
53
54class SkImage_Lazy : public SkImage_Base, public SkImageCacherator {
55public:
56 struct Validator {
Christopher Cameron77e96662017-07-08 01:47:47 -070057 Validator(sk_sp<SharedGenerator>, const SkIRect* subset, sk_sp<SkColorSpace> colorSpace);
Brian Osmandf7e0752017-04-26 16:20:28 -040058
59 operator bool() const { return fSharedGenerator.get(); }
60
61 sk_sp<SharedGenerator> fSharedGenerator;
62 SkImageInfo fInfo;
63 SkIPoint fOrigin;
Christopher Cameron77e96662017-07-08 01:47:47 -070064 sk_sp<SkColorSpace> fColorSpace;
Brian Osmandf7e0752017-04-26 16:20:28 -040065 uint32_t fUniqueID;
66 };
67
68 SkImage_Lazy(Validator* validator);
69
70 SkImageInfo onImageInfo() const override {
71 return fInfo;
herba7c9d632016-04-19 12:30:22 -070072 }
Greg Daniel56008aa2018-03-14 15:33:42 -040073 SkColorType onColorType() const override {
74 return kUnknown_SkColorType;
75 }
brianosman69c166d2016-08-17 14:01:05 -070076 SkAlphaType onAlphaType() const override {
Brian Osmandf7e0752017-04-26 16:20:28 -040077 return fInfo.alphaType();
brianosman69c166d2016-08-17 14:01:05 -070078 }
herba7c9d632016-04-19 12:30:22 -070079
Robert Phillipsb726d582017-03-09 16:36:32 -050080 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY,
81 CachingHint) const override;
82#if SK_SUPPORT_GPU
Brian Salomon2bbdcc42017-09-07 12:36:34 -040083 sk_sp<GrTextureProxy> asTextureProxyRef(GrContext*,
84 const GrSamplerState&, SkColorSpace*,
85 sk_sp<SkColorSpace>*,
Robert Phillipsb726d582017-03-09 16:36:32 -050086 SkScalar scaleAdjust[2]) const override;
87#endif
Brian Osman47858972017-04-25 10:02:12 -040088 SkData* onRefEncoded() const override;
reed7fb4f8b2016-03-11 04:33:52 -080089 sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
Brian Osman61624f02016-12-09 14:51:59 -050090 bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
reed85d91782015-09-10 14:33:38 -070091 bool onIsLazyGenerated() const override { return true; }
Mike Reed7f1d0202017-05-08 16:13:39 -040092 bool onCanLazyGenerateOnGPU() const override;
Matt Sarett9f3dcb32017-05-04 08:53:32 -040093 sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType,
94 SkTransferFunctionBehavior) const override;
reed85d91782015-09-10 14:33:38 -070095
Brian Osman5bbd0762017-05-08 11:07:42 -040096 bool onIsValid(GrContext*) const override;
97
Brian Osmandf7e0752017-04-26 16:20:28 -040098 SkImageCacherator* peekCacherator() const override {
99 return const_cast<SkImage_Lazy*>(this);
100 }
101
102 // Only return true if the generate has already been cached.
103 bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*, CachedFormat) const;
104 // Call the underlying generator directly
105 bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
106 int srcX, int srcY, SkTransferFunctionBehavior behavior) const;
107
108 // SkImageCacherator interface
109#if SK_SUPPORT_GPU
110 // Returns the texture proxy. If the cacherator is generating the texture and wants to cache it,
111 // it should use the passed in key (if the key is valid).
112 sk_sp<GrTextureProxy> lockTextureProxy(GrContext*,
113 const GrUniqueKey& key,
114 SkImage::CachingHint,
115 bool willBeMipped,
Stan Ilievba81af22017-06-08 15:16:53 -0400116 SkColorSpace* dstColorSpace,
117 GrTextureMaker::AllowedTexGenType genType) override;
Brian Osmandf7e0752017-04-26 16:20:28 -0400118
119 // Returns the color space of the texture that would be returned if you called lockTexture.
120 // Separate code path to allow querying of the color space for textures that cached (even
121 // externally).
122 sk_sp<SkColorSpace> getColorSpace(GrContext*, SkColorSpace* dstColorSpace) override;
123 void makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, CachedFormat,
124 GrUniqueKey* cacheKey) override;
125#endif
126
127 CachedFormat chooseCacheFormat(SkColorSpace* dstColorSpace,
128 const GrCaps* = nullptr) const override;
129 SkImageInfo buildCacheInfo(CachedFormat) const override;
130
reed85d91782015-09-10 14:33:38 -0700131private:
Brian Osmandf7e0752017-04-26 16:20:28 -0400132 class ScopedGenerator;
133
134 /**
135 * On success (true), bitmap will point to the pixels for this generator. If this returns
136 * false, the bitmap will be reset to empty.
137 */
Christopher Cameron77e96662017-07-08 01:47:47 -0700138 bool lockAsBitmap(SkBitmap*, SkImage::CachingHint, CachedFormat, const SkImageInfo&,
139 SkTransferFunctionBehavior) const;
140
141 /**
142 * Populates parameters to pass to the generator for reading pixels or generating a texture.
143 * For image generators, legacy versus true color blending is indicated using a
144 * SkTransferFunctionBehavior, and the target color space is specified on the SkImageInfo.
145 * If generatorImageInfo has no color space set, set its color space to this SkImage's color
146 * space, and return "ignore" behavior, indicating legacy mode. If generatorImageInfo has a
147 * color space set, return "respect" behavior, indicating linear blending mode.
148 */
149 SkTransferFunctionBehavior getGeneratorBehaviorAndInfo(SkImageInfo* generatorImageInfo) const;
Brian Osmandf7e0752017-04-26 16:20:28 -0400150
151 sk_sp<SharedGenerator> fSharedGenerator;
Christopher Cameron77e96662017-07-08 01:47:47 -0700152 // Note that fInfo is not necessarily the info from the generator. It may be cropped by
153 // onMakeSubset and its color space may be changed by onMakeColorSpace.
Brian Osmandf7e0752017-04-26 16:20:28 -0400154 const SkImageInfo fInfo;
155 const SkIPoint fOrigin;
156
157 struct IDRec {
158 SkOnce fOnce;
159 uint32_t fUniqueID;
160 };
161 mutable IDRec fIDRecs[kNumCachedFormats];
162
163 uint32_t getUniqueID(CachedFormat) const;
reed85d91782015-09-10 14:33:38 -0700164
Christopher Camerond4b67872017-07-13 15:18:08 -0700165 // Repeated calls to onMakeColorSpace will result in a proliferation of unique IDs and
166 // SkImage_Lazy instances. Cache the result of the last successful onMakeColorSpace call.
167 mutable SkMutex fOnMakeColorSpaceMutex;
168 mutable sk_sp<SkColorSpace> fOnMakeColorSpaceTarget;
169 mutable sk_sp<SkImage> fOnMakeColorSpaceResult;
170
reed85d91782015-09-10 14:33:38 -0700171 typedef SkImage_Base INHERITED;
172};
173
174///////////////////////////////////////////////////////////////////////////////
175
Christopher Cameron77e96662017-07-08 01:47:47 -0700176SkImage_Lazy::Validator::Validator(sk_sp<SharedGenerator> gen, const SkIRect* subset,
177 sk_sp<SkColorSpace> colorSpace)
Brian Osmandf7e0752017-04-26 16:20:28 -0400178 : fSharedGenerator(std::move(gen)) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400179 if (!fSharedGenerator) {
180 return;
181 }
182
183 // The following generator accessors are safe without acquiring the mutex (const getters).
184 // TODO: refactor to use a ScopedGenerator instead, for clarity.
185 const SkImageInfo& info = fSharedGenerator->fGenerator->getInfo();
186 if (info.isEmpty()) {
187 fSharedGenerator.reset();
188 return;
189 }
190
191 fUniqueID = fSharedGenerator->fGenerator->uniqueID();
192 const SkIRect bounds = SkIRect::MakeWH(info.width(), info.height());
193 if (subset) {
194 if (!bounds.contains(*subset)) {
195 fSharedGenerator.reset();
196 return;
197 }
198 if (*subset != bounds) {
199 // we need a different uniqueID since we really are a subset of the raw generator
200 fUniqueID = SkNextID::ImageID();
201 }
202 } else {
203 subset = &bounds;
204 }
205
206 fInfo = info.makeWH(subset->width(), subset->height());
207 fOrigin = SkIPoint::Make(subset->x(), subset->y());
Christopher Cameron77e96662017-07-08 01:47:47 -0700208 if (colorSpace) {
209 fInfo = fInfo.makeColorSpace(colorSpace);
210 fUniqueID = SkNextID::ImageID();
211 }
Brian Osmandf7e0752017-04-26 16:20:28 -0400212}
213
214///////////////////////////////////////////////////////////////////////////////
215
216// Helper for exclusive access to a shared generator.
217class SkImage_Lazy::ScopedGenerator {
218public:
219 ScopedGenerator(const sk_sp<SharedGenerator>& gen)
220 : fSharedGenerator(gen)
221 , fAutoAquire(gen->fMutex) {}
222
223 SkImageGenerator* operator->() const {
224 fSharedGenerator->fMutex.assertHeld();
225 return fSharedGenerator->fGenerator.get();
226 }
227
228 operator SkImageGenerator*() const {
229 fSharedGenerator->fMutex.assertHeld();
230 return fSharedGenerator->fGenerator.get();
231 }
232
233private:
234 const sk_sp<SharedGenerator>& fSharedGenerator;
235 SkAutoExclusive fAutoAquire;
236};
237
238///////////////////////////////////////////////////////////////////////////////
239
240SkImage_Lazy::SkImage_Lazy(Validator* validator)
241 : INHERITED(validator->fInfo.width(), validator->fInfo.height(), validator->fUniqueID)
242 , fSharedGenerator(std::move(validator->fSharedGenerator))
243 , fInfo(validator->fInfo)
244 , fOrigin(validator->fOrigin) {
245 SkASSERT(fSharedGenerator);
Brian Osmandf7e0752017-04-26 16:20:28 -0400246 // We explicit set the legacy format slot, but leave the others uninitialized (via SkOnce)
247 // and only resolove them to IDs as needed (by calling getUniqueID()).
248 fIDRecs[kLegacy_CachedFormat].fOnce([this, validator] {
249 fIDRecs[kLegacy_CachedFormat].fUniqueID = validator->fUniqueID;
250 });
251}
252
253uint32_t SkImage_Lazy::getUniqueID(CachedFormat format) const {
254 IDRec* rec = &fIDRecs[format];
255 rec->fOnce([rec] {
256 rec->fUniqueID = SkNextID::ImageID();
257 });
258 return rec->fUniqueID;
259}
260
261//////////////////////////////////////////////////////////////////////////////////////////////////
262
263// Abstraction of GrCaps that handles the cases where we don't have a caps pointer (because
264// we're in raster mode), or where GPU support is entirely missing. In theory, we only need the
265// chosen format to be texturable, but that lets us choose F16 on GLES implemenations where we
266// won't be able to read the texture back. We'd like to ensure that SkImake::makeNonTextureImage
267// works, so we require that the formats we choose are renderable (as a proxy for being readable).
268struct CacheCaps {
269 CacheCaps(const GrCaps* caps) : fCaps(caps) {}
270
271#if SK_SUPPORT_GPU
272 bool supportsHalfFloat() const {
Brian Salomonbdecacf2018-02-02 20:32:49 -0500273 return !fCaps || (fCaps->isConfigTexturable(kRGBA_half_GrPixelConfig) &&
274 fCaps->isConfigRenderable(kRGBA_half_GrPixelConfig));
Brian Osmandf7e0752017-04-26 16:20:28 -0400275 }
276
277 bool supportsSRGB() const {
278 return !fCaps ||
279 (fCaps->srgbSupport() && fCaps->isConfigTexturable(kSRGBA_8888_GrPixelConfig));
280 }
281
282 bool supportsSBGR() const {
283 return !fCaps || fCaps->srgbSupport();
284 }
285#else
286 bool supportsHalfFloat() const { return true; }
287 bool supportsSRGB() const { return true; }
288 bool supportsSBGR() const { return true; }
289#endif
290
291 const GrCaps* fCaps;
292};
293
294SkImageCacherator::CachedFormat SkImage_Lazy::chooseCacheFormat(SkColorSpace* dstColorSpace,
295 const GrCaps* grCaps) const {
296 SkColorSpace* cs = fInfo.colorSpace();
297 if (!cs || !dstColorSpace) {
298 return kLegacy_CachedFormat;
299 }
300
301 CacheCaps caps(grCaps);
302 switch (fInfo.colorType()) {
303 case kUnknown_SkColorType:
304 case kAlpha_8_SkColorType:
305 case kRGB_565_SkColorType:
306 case kARGB_4444_SkColorType:
Brian Salomone41e1762018-01-25 14:07:47 -0500307 case kRGB_888x_SkColorType:
308 case kRGBA_1010102_SkColorType:
309 case kRGB_101010x_SkColorType:
Brian Osmandf7e0752017-04-26 16:20:28 -0400310 // We don't support color space on these formats, so always decode in legacy mode:
311 // TODO: Ask the codec to decode these to something else (at least sRGB 8888)?
312 return kLegacy_CachedFormat;
313
Brian Osmandf7e0752017-04-26 16:20:28 -0400314 case kGray_8_SkColorType:
315 // TODO: What do we do with grayscale sources that have strange color spaces attached?
316 // The codecs and color space xform don't handle this correctly (yet), so drop it on
317 // the floor. (Also, inflating by a factor of 8 is going to be unfortunate).
318 // As it is, we don't directly support sRGB grayscale, so ask the codec to convert
319 // it for us. This bypasses some really sketchy code GrUploadPixmapToTexture.
320 if (cs->gammaCloseToSRGB() && caps.supportsSRGB()) {
321 return kSRGB8888_CachedFormat;
322 } else {
323 return kLegacy_CachedFormat;
324 }
325
326 case kRGBA_8888_SkColorType:
327 if (cs->gammaCloseToSRGB()) {
328 if (caps.supportsSRGB()) {
329 return kSRGB8888_CachedFormat;
330 } else if (caps.supportsHalfFloat()) {
331 return kLinearF16_CachedFormat;
332 } else {
333 return kLegacy_CachedFormat;
334 }
335 } else {
336 if (caps.supportsHalfFloat()) {
337 return kLinearF16_CachedFormat;
338 } else if (caps.supportsSRGB()) {
339 return kSRGB8888_CachedFormat;
340 } else {
341 return kLegacy_CachedFormat;
342 }
343 }
344
345 case kBGRA_8888_SkColorType:
346 // Odd case. sBGRA isn't a real thing, so we may not have this texturable.
347 if (caps.supportsSBGR()) {
348 if (cs->gammaCloseToSRGB()) {
349 return kSBGR8888_CachedFormat;
350 } else if (caps.supportsHalfFloat()) {
351 return kLinearF16_CachedFormat;
352 } else if (caps.supportsSRGB()) {
353 return kSRGB8888_CachedFormat;
354 } else {
355 // sBGRA support without sRGBA is highly unlikely (impossible?) Nevertheless.
356 return kLegacy_CachedFormat;
357 }
358 } else {
359 if (cs->gammaCloseToSRGB()) {
360 if (caps.supportsSRGB()) {
361 return kSRGB8888_CachedFormat;
362 } else if (caps.supportsHalfFloat()) {
363 return kLinearF16_CachedFormat;
364 } else {
365 return kLegacy_CachedFormat;
366 }
367 } else {
368 if (caps.supportsHalfFloat()) {
369 return kLinearF16_CachedFormat;
370 } else if (caps.supportsSRGB()) {
371 return kSRGB8888_CachedFormat;
372 } else {
373 return kLegacy_CachedFormat;
374 }
375 }
376 }
377
378 case kRGBA_F16_SkColorType:
379 if (caps.supportsHalfFloat()) {
380 return kLinearF16_CachedFormat;
381 } else if (caps.supportsSRGB()) {
382 return kSRGB8888_CachedFormat;
383 } else {
384 return kLegacy_CachedFormat;
385 }
386 }
387 SkDEBUGFAIL("Unreachable");
388 return kLegacy_CachedFormat;
389}
390
391SkImageInfo SkImage_Lazy::buildCacheInfo(CachedFormat format) const {
392 switch (format) {
393 case kLegacy_CachedFormat:
394 return fInfo.makeColorSpace(nullptr);
395 case kLinearF16_CachedFormat:
396 return fInfo.makeColorType(kRGBA_F16_SkColorType)
Brian Osman36703d92017-12-12 14:09:31 -0500397 .makeColorSpace(fInfo.colorSpace()->makeLinearGamma());
Brian Osmandf7e0752017-04-26 16:20:28 -0400398 case kSRGB8888_CachedFormat:
399 // If the transfer function is nearly (but not exactly) sRGB, we don't want the codec
400 // to bother trans-coding. It would be slow, and do more harm than good visually,
401 // so we make sure to leave the colorspace as-is.
402 if (fInfo.colorSpace()->gammaCloseToSRGB()) {
403 return fInfo.makeColorType(kRGBA_8888_SkColorType);
404 } else {
405 return fInfo.makeColorType(kRGBA_8888_SkColorType)
Brian Osman36703d92017-12-12 14:09:31 -0500406 .makeColorSpace(fInfo.colorSpace()->makeSRGBGamma());
Brian Osmandf7e0752017-04-26 16:20:28 -0400407 }
408 case kSBGR8888_CachedFormat:
409 // See note above about not-quite-sRGB transfer functions.
410 if (fInfo.colorSpace()->gammaCloseToSRGB()) {
411 return fInfo.makeColorType(kBGRA_8888_SkColorType);
412 } else {
413 return fInfo.makeColorType(kBGRA_8888_SkColorType)
Brian Osman36703d92017-12-12 14:09:31 -0500414 .makeColorSpace(fInfo.colorSpace()->makeSRGBGamma());
Brian Osmandf7e0752017-04-26 16:20:28 -0400415 }
416 default:
417 SkDEBUGFAIL("Invalid cached format");
418 return fInfo;
419 }
420}
421
422//////////////////////////////////////////////////////////////////////////////////////////////////
423
424static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) {
425 SkASSERT(bitmap.getGenerationID() == expectedID);
426 SkASSERT(bitmap.isImmutable());
427 SkASSERT(bitmap.getPixels());
428 return true;
429}
430
431bool SkImage_Lazy::directGeneratePixels(const SkImageInfo& info, void* pixels, size_t rb,
432 int srcX, int srcY,
433 SkTransferFunctionBehavior behavior) const {
434 ScopedGenerator generator(fSharedGenerator);
435 const SkImageInfo& genInfo = generator->getInfo();
436 // Currently generators do not natively handle subsets, so check that first.
437 if (srcX || srcY || genInfo.width() != info.width() || genInfo.height() != info.height()) {
438 return false;
439 }
440
441 SkImageGenerator::Options opts;
Christopher Cameron77e96662017-07-08 01:47:47 -0700442 // TODO: This should respect the behavior argument.
443 opts.fBehavior = SkTransferFunctionBehavior::kIgnore;
Brian Osmandf7e0752017-04-26 16:20:28 -0400444 return generator->getPixels(info, pixels, rb, &opts);
445}
446
447//////////////////////////////////////////////////////////////////////////////////////////////////
448
449bool SkImage_Lazy::lockAsBitmapOnlyIfAlreadyCached(SkBitmap* bitmap, CachedFormat format) const {
450 uint32_t uniqueID = this->getUniqueID(format);
451 return SkBitmapCache::Find(SkBitmapCacheDesc::Make(uniqueID,
452 fInfo.width(), fInfo.height()), bitmap) &&
453 check_output_bitmap(*bitmap, uniqueID);
454}
455
Christopher Cameron77e96662017-07-08 01:47:47 -0700456static bool generate_pixels(SkImageGenerator* gen, const SkPixmap& pmap, int originX, int originY,
457 SkTransferFunctionBehavior behavior) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400458 const int genW = gen->getInfo().width();
459 const int genH = gen->getInfo().height();
460 const SkIRect srcR = SkIRect::MakeWH(genW, genH);
461 const SkIRect dstR = SkIRect::MakeXYWH(originX, originY, pmap.width(), pmap.height());
462 if (!srcR.contains(dstR)) {
463 return false;
464 }
465
466 // If they are requesting a subset, we have to have a temp allocation for full image, and
467 // then copy the subset into their allocation
468 SkBitmap full;
469 SkPixmap fullPM;
470 const SkPixmap* dstPM = &pmap;
471 if (srcR != dstR) {
472 if (!full.tryAllocPixels(pmap.info().makeWH(genW, genH))) {
473 return false;
474 }
475 if (!full.peekPixels(&fullPM)) {
476 return false;
477 }
478 dstPM = &fullPM;
479 }
480
Christopher Cameron77e96662017-07-08 01:47:47 -0700481 SkImageGenerator::Options opts;
482 opts.fBehavior = behavior;
483 if (!gen->getPixels(dstPM->info(), dstPM->writable_addr(), dstPM->rowBytes(), &opts)) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400484 return false;
485 }
486
487 if (srcR != dstR) {
488 if (!full.readPixels(pmap, originX, originY)) {
489 return false;
490 }
491 }
492 return true;
493}
494
Christopher Cameron77e96662017-07-08 01:47:47 -0700495bool SkImage_Lazy::lockAsBitmap(SkBitmap* bitmap, SkImage::CachingHint chint, CachedFormat format,
496 const SkImageInfo& info,
497 SkTransferFunctionBehavior behavior) const {
Brian Osmandf7e0752017-04-26 16:20:28 -0400498 if (this->lockAsBitmapOnlyIfAlreadyCached(bitmap, format)) {
499 return true;
500 }
501
502 uint32_t uniqueID = this->getUniqueID(format);
503
504 SkBitmap tmpBitmap;
505 SkBitmapCache::RecPtr cacheRec;
506 SkPixmap pmap;
507 if (SkImage::kAllow_CachingHint == chint) {
508 auto desc = SkBitmapCacheDesc::Make(uniqueID, info.width(), info.height());
509 cacheRec = SkBitmapCache::Alloc(desc, info, &pmap);
510 if (!cacheRec) {
511 return false;
512 }
513 } else {
514 if (!tmpBitmap.tryAllocPixels(info)) {
515 return false;
516 }
517 if (!tmpBitmap.peekPixels(&pmap)) {
518 return false;
519 }
520 }
521
522 ScopedGenerator generator(fSharedGenerator);
Christopher Cameron77e96662017-07-08 01:47:47 -0700523 if (!generate_pixels(generator, pmap, fOrigin.x(), fOrigin.y(), behavior)) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400524 return false;
525 }
526
527 if (cacheRec) {
528 SkBitmapCache::Add(std::move(cacheRec), bitmap);
529 SkASSERT(bitmap->getPixels()); // we're locked
530 SkASSERT(bitmap->isImmutable());
531 SkASSERT(bitmap->getGenerationID() == uniqueID);
532 this->notifyAddedToCache();
533 } else {
534 *bitmap = tmpBitmap;
535 bitmap->pixelRef()->setImmutableWithID(uniqueID);
536 }
537
538 check_output_bitmap(*bitmap, uniqueID);
539 return true;
540}
541
542//////////////////////////////////////////////////////////////////////////////////////////////////
543
Brian Osmanf1b43822017-04-20 13:43:23 -0400544bool SkImage_Lazy::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
545 int srcX, int srcY, CachingHint chint) const {
Brian Osman61624f02016-12-09 14:51:59 -0500546 SkColorSpace* dstColorSpace = dstInfo.colorSpace();
reed85d91782015-09-10 14:33:38 -0700547 SkBitmap bm;
reed6868c3f2015-11-24 11:44:47 -0800548 if (kDisallow_CachingHint == chint) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400549 CachedFormat cacheFormat = this->chooseCacheFormat(dstColorSpace);
Christopher Cameron77e96662017-07-08 01:47:47 -0700550 SkImageInfo genPixelsInfo = dstInfo;
551 SkTransferFunctionBehavior behavior = getGeneratorBehaviorAndInfo(&genPixelsInfo);
Brian Osmandf7e0752017-04-26 16:20:28 -0400552 if (this->lockAsBitmapOnlyIfAlreadyCached(&bm, cacheFormat)) {
reed6868c3f2015-11-24 11:44:47 -0800553 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
554 } else {
555 // Try passing the caller's buffer directly down to the generator. If this fails we
556 // may still succeed in the general case, as the generator may prefer some other
557 // config, which we could then convert via SkBitmap::readPixels.
Christopher Cameron77e96662017-07-08 01:47:47 -0700558 if (this->directGeneratePixels(genPixelsInfo, dstPixels, dstRB, srcX, srcY, behavior)) {
reed6868c3f2015-11-24 11:44:47 -0800559 return true;
560 }
561 // else fall through
562 }
563 }
564
Brian Osman61624f02016-12-09 14:51:59 -0500565 if (this->getROPixels(&bm, dstColorSpace, chint)) {
reed85d91782015-09-10 14:33:38 -0700566 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
567 }
568 return false;
569}
570
Brian Osman47858972017-04-25 10:02:12 -0400571SkData* SkImage_Lazy::onRefEncoded() const {
Brian Osmandf7e0752017-04-26 16:20:28 -0400572 ScopedGenerator generator(fSharedGenerator);
573 return generator->refEncodedData();
reed85d91782015-09-10 14:33:38 -0700574}
575
Brian Osmanf1b43822017-04-20 13:43:23 -0400576bool SkImage_Lazy::getROPixels(SkBitmap* bitmap, SkColorSpace* dstColorSpace,
577 CachingHint chint) const {
Brian Osmandf7e0752017-04-26 16:20:28 -0400578 CachedFormat cacheFormat = this->chooseCacheFormat(dstColorSpace);
Christopher Cameron77e96662017-07-08 01:47:47 -0700579 const SkImageInfo cacheInfo = this->buildCacheInfo(cacheFormat);
580 SkImageInfo genPixelsInfo = cacheInfo;
581 SkTransferFunctionBehavior behavior = getGeneratorBehaviorAndInfo(&genPixelsInfo);
582 return this->lockAsBitmap(bitmap, chint, cacheFormat, genPixelsInfo, behavior);
reed85d91782015-09-10 14:33:38 -0700583}
584
Brian Osman5bbd0762017-05-08 11:07:42 -0400585bool SkImage_Lazy::onIsValid(GrContext* context) const {
586 ScopedGenerator generator(fSharedGenerator);
587 return generator->isValid(context);
588}
589
Mike Reed7f1d0202017-05-08 16:13:39 -0400590bool SkImage_Lazy::onCanLazyGenerateOnGPU() const {
591#if SK_SUPPORT_GPU
592 ScopedGenerator generator(fSharedGenerator);
Stan Ilievba81af22017-06-08 15:16:53 -0400593 return SkImageGenerator::TexGenType::kNone != generator->onCanGenerateTexture();
Mike Reed7f1d0202017-05-08 16:13:39 -0400594#else
595 return false;
596#endif
597}
598
Christopher Cameron77e96662017-07-08 01:47:47 -0700599SkTransferFunctionBehavior SkImage_Lazy::getGeneratorBehaviorAndInfo(SkImageInfo* generatorImageInfo) const {
600 if (generatorImageInfo->colorSpace()) {
601 return SkTransferFunctionBehavior::kRespect;
602 }
603 // Only specify an output color space if color conversion can be done on the color type.
604 switch (generatorImageInfo->colorType()) {
605 case kRGBA_8888_SkColorType:
606 case kBGRA_8888_SkColorType:
607 case kRGBA_F16_SkColorType:
608 case kRGB_565_SkColorType:
609 *generatorImageInfo = generatorImageInfo->makeColorSpace(fInfo.refColorSpace());
610 break;
611 default:
612 break;
613 }
614 return SkTransferFunctionBehavior::kIgnore;
615}
616
Brian Osmandf7e0752017-04-26 16:20:28 -0400617///////////////////////////////////////////////////////////////////////////////////////////////////
618
Robert Phillipsb726d582017-03-09 16:36:32 -0500619#if SK_SUPPORT_GPU
Brian Osmanf1b43822017-04-20 13:43:23 -0400620sk_sp<GrTextureProxy> SkImage_Lazy::asTextureProxyRef(GrContext* context,
Brian Salomon2bbdcc42017-09-07 12:36:34 -0400621 const GrSamplerState& params,
Brian Osmanf1b43822017-04-20 13:43:23 -0400622 SkColorSpace* dstColorSpace,
623 sk_sp<SkColorSpace>* texColorSpace,
624 SkScalar scaleAdjust[2]) const {
Brian Osmandf7e0752017-04-26 16:20:28 -0400625 if (!context) {
626 return nullptr;
627 }
628
629 GrImageTextureMaker textureMaker(context, this, kAllow_CachingHint);
630 return textureMaker.refTextureProxyForParams(params, dstColorSpace, texColorSpace, scaleAdjust);
Robert Phillipsb726d582017-03-09 16:36:32 -0500631}
632#endif
633
Brian Osmanf1b43822017-04-20 13:43:23 -0400634sk_sp<SkImage> SkImage_Lazy::onMakeSubset(const SkIRect& subset) const {
Brian Osmandf7e0752017-04-26 16:20:28 -0400635 SkASSERT(fInfo.bounds().contains(subset));
636 SkASSERT(fInfo.bounds() != subset);
reed7b6945b2015-09-24 00:50:58 -0700637
Brian Osmandf7e0752017-04-26 16:20:28 -0400638 const SkIRect generatorSubset = subset.makeOffset(fOrigin.x(), fOrigin.y());
Christopher Cameron77e96662017-07-08 01:47:47 -0700639 Validator validator(fSharedGenerator, &generatorSubset, fInfo.refColorSpace());
Brian Osmanf1b43822017-04-20 13:43:23 -0400640 return validator ? sk_sp<SkImage>(new SkImage_Lazy(&validator)) : nullptr;
reed7b6945b2015-09-24 00:50:58 -0700641}
642
Matt Sarett9f3dcb32017-05-04 08:53:32 -0400643sk_sp<SkImage> SkImage_Lazy::onMakeColorSpace(sk_sp<SkColorSpace> target,
644 SkColorType targetColorType,
645 SkTransferFunctionBehavior premulBehavior) const {
Christopher Camerond4b67872017-07-13 15:18:08 -0700646 SkAutoExclusive autoAquire(fOnMakeColorSpaceMutex);
647 if (target && fOnMakeColorSpaceTarget &&
648 SkColorSpace::Equals(target.get(), fOnMakeColorSpaceTarget.get())) {
649 return fOnMakeColorSpaceResult;
650 }
Christopher Cameron77e96662017-07-08 01:47:47 -0700651 const SkIRect generatorSubset =
652 SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
653 Validator validator(fSharedGenerator, &generatorSubset, target);
Christopher Camerond4b67872017-07-13 15:18:08 -0700654 sk_sp<SkImage> result = validator ? sk_sp<SkImage>(new SkImage_Lazy(&validator)) : nullptr;
655 if (result) {
656 fOnMakeColorSpaceTarget = target;
657 fOnMakeColorSpaceResult = result;
658 }
659 return result;
Matt Sarett6de13102017-03-14 14:10:48 -0400660}
661
Mike Reed185130c2017-02-15 15:14:16 -0500662sk_sp<SkImage> SkImage::MakeFromGenerator(std::unique_ptr<SkImageGenerator> generator,
663 const SkIRect* subset) {
Christopher Cameron77e96662017-07-08 01:47:47 -0700664 SkImage_Lazy::Validator validator(SharedGenerator::Make(std::move(generator)), subset, nullptr);
fmalita7929e3a2016-10-27 08:15:44 -0700665
Brian Osmanf1b43822017-04-20 13:43:23 -0400666 return validator ? sk_make_sp<SkImage_Lazy>(&validator) : nullptr;
reed85d91782015-09-10 14:33:38 -0700667}
Brian Osmandf7e0752017-04-26 16:20:28 -0400668
669//////////////////////////////////////////////////////////////////////////////////////////////////
670
671/**
672 * Implementation of SkImageCacherator interface, as needed by GrImageTextureMaker
673 */
674
675#if SK_SUPPORT_GPU
676
677void SkImage_Lazy::makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, CachedFormat format,
678 GrUniqueKey* cacheKey) {
679 SkASSERT(!cacheKey->isValid());
680 if (origKey.isValid()) {
681 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
Derek Sollenbergere1c60d62018-04-04 11:53:35 -0400682 GrUniqueKey::Builder builder(cacheKey, origKey, kDomain, 1, "Image");
Brian Osmandf7e0752017-04-26 16:20:28 -0400683 builder[0] = format;
684 }
685}
686
687class Generator_GrYUVProvider : public GrYUVProvider {
688 SkImageGenerator* fGen;
689
690public:
691 Generator_GrYUVProvider(SkImageGenerator* gen) : fGen(gen) {}
692
693 uint32_t onGetID() override { return fGen->uniqueID(); }
694 bool onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const override {
695 return fGen->queryYUV8(sizeInfo, colorSpace);
696 }
697 bool onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) override {
698 return fGen->getYUV8Planes(sizeInfo, planes);
699 }
700};
701
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500702static void set_key_on_proxy(GrProxyProvider* proxyProvider,
Greg Danielfc5060d2017-10-04 18:36:15 +0000703 GrTextureProxy* proxy, GrTextureProxy* originalProxy,
704 const GrUniqueKey& key) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400705 if (key.isValid()) {
Robert Phillips8a90f502017-07-24 15:09:56 -0400706 SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
Greg Danielf6f7b672018-02-15 13:06:26 -0500707 if (originalProxy && originalProxy->getUniqueKey().isValid()) {
708 SkASSERT(originalProxy->getUniqueKey() == key);
Greg Daniele252f082017-10-23 16:05:23 -0400709 SkASSERT(GrMipMapped::kYes == proxy->mipMapped() &&
710 GrMipMapped::kNo == originalProxy->mipMapped());
Greg Danielf6f7b672018-02-15 13:06:26 -0500711 // If we had an originalProxy with a valid key, that means there already is a proxy in
712 // the cache which matches the key, but it does not have mip levels and we require them.
713 // Thus we must remove the unique key from that proxy.
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500714 proxyProvider->removeUniqueKeyFromProxy(key, originalProxy);
Greg Danielfc5060d2017-10-04 18:36:15 +0000715 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500716 proxyProvider->assignUniqueKeyToProxy(key, proxy);
Brian Osmandf7e0752017-04-26 16:20:28 -0400717 }
718}
719
720sk_sp<SkColorSpace> SkImage_Lazy::getColorSpace(GrContext* ctx, SkColorSpace* dstColorSpace) {
Brian Osmana8ac9242017-09-07 10:19:08 -0400721 if (!dstColorSpace) {
722 // In legacy mode, we do no modification to the image's color space or encoding.
723 // Subsequent legacy drawing is likely to ignore the color space, but some clients
724 // may want to know what space the image data is in, so return it.
725 return fInfo.refColorSpace();
726 } else {
727 CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->caps());
728 SkImageInfo cacheInfo = this->buildCacheInfo(format);
729 return cacheInfo.refColorSpace();
730 }
Brian Osmandf7e0752017-04-26 16:20:28 -0400731}
732
733/*
734 * We have 4 ways to try to return a texture (in sorted order)
735 *
736 * 1. Check the cache for a pre-existing one
737 * 2. Ask the generator to natively create one
738 * 3. Ask the generator to return YUV planes, which the GPU can convert
739 * 4. Ask the generator to return RGB(A) data, which the GPU can convert
740 */
741sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
742 const GrUniqueKey& origKey,
743 SkImage::CachingHint chint,
744 bool willBeMipped,
Stan Ilievba81af22017-06-08 15:16:53 -0400745 SkColorSpace* dstColorSpace,
746 GrTextureMaker::AllowedTexGenType genType) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400747 // Values representing the various texture lock paths we can take. Used for logging the path
748 // taken to a histogram.
749 enum LockTexturePath {
750 kFailure_LockTexturePath,
751 kPreExisting_LockTexturePath,
752 kNative_LockTexturePath,
753 kCompressed_LockTexturePath, // Deprecated
754 kYUV_LockTexturePath,
755 kRGBA_LockTexturePath,
756 };
757
758 enum { kLockTexturePathCount = kRGBA_LockTexturePath + 1 };
759
760 // Determine which cached format we're going to use (which may involve decoding to a different
761 // info than the generator provides).
762 CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->caps());
763
764 // Fold the cache format into our texture key
765 GrUniqueKey key;
766 this->makeCacheKeyFromOrigKey(origKey, format, &key);
767
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500768 GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
Greg Danielfc5060d2017-10-04 18:36:15 +0000769 sk_sp<GrTextureProxy> proxy;
770
Brian Osmandf7e0752017-04-26 16:20:28 -0400771 // 1. Check the cache for a pre-existing one
772 if (key.isValid()) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500773 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
Greg Danielfc5060d2017-10-04 18:36:15 +0000774 if (proxy) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400775 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexturePath,
776 kLockTexturePathCount);
Greg Daniele252f082017-10-23 16:05:23 -0400777 if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
Greg Danielfc5060d2017-10-04 18:36:15 +0000778 return proxy;
779 }
Brian Osmandf7e0752017-04-26 16:20:28 -0400780 }
781 }
782
783 // The CachedFormat is both an index for which cache "slot" we'll use to store this particular
784 // decoded variant of the encoded data, and also a recipe for how to transform the original
785 // info to get the one that we're going to decode to.
Christopher Cameron77e96662017-07-08 01:47:47 -0700786 const SkImageInfo cacheInfo = this->buildCacheInfo(format);
787 SkImageInfo genPixelsInfo = cacheInfo;
788 SkTransferFunctionBehavior behavior = getGeneratorBehaviorAndInfo(&genPixelsInfo);
Brian Osmandf7e0752017-04-26 16:20:28 -0400789
790 // 2. Ask the generator to natively create one
Greg Danielfc5060d2017-10-04 18:36:15 +0000791 if (!proxy) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400792 ScopedGenerator generator(fSharedGenerator);
Stan Ilievba81af22017-06-08 15:16:53 -0400793 if (GrTextureMaker::AllowedTexGenType::kCheap == genType &&
794 SkImageGenerator::TexGenType::kCheap != generator->onCanGenerateTexture()) {
795 return nullptr;
796 }
Greg Danielf88c12e2017-10-09 09:57:35 -0400797 if ((proxy = generator->generateTexture(ctx, genPixelsInfo, fOrigin, behavior,
798 willBeMipped))) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400799 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath,
800 kLockTexturePathCount);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500801 set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
Greg Daniele252f082017-10-23 16:05:23 -0400802 if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
Greg Danielfc5060d2017-10-04 18:36:15 +0000803 return proxy;
804 }
Brian Osmandf7e0752017-04-26 16:20:28 -0400805 }
806 }
807
Greg Daniel3e70fa32017-10-05 16:27:06 -0400808 // 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping
809 // the texture we fall through here and have the CPU generate the mip maps for us.
810 if (!proxy && !willBeMipped && !ctx->contextPriv().disableGpuYUVConversion()) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400811 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(cacheInfo, *ctx->caps());
812 ScopedGenerator generator(fSharedGenerator);
813 Generator_GrYUVProvider provider(generator);
Christopher Cameron77e96662017-07-08 01:47:47 -0700814
815 // The pixels in the texture will be in the generator's color space. If onMakeColorSpace
816 // has been called then this will not match this image's color space. To correct this, apply
817 // a color space conversion from the generator's color space to this image's color space.
818 const SkColorSpace* generatorColorSpace =
819 fSharedGenerator->fGenerator->getInfo().colorSpace();
820 const SkColorSpace* thisColorSpace = fInfo.colorSpace();
821
Greg Danielfc5060d2017-10-04 18:36:15 +0000822 // TODO: Update to create the mipped surface in the YUV generator and draw the base layer
823 // directly into the mipped surface.
Greg Daniel1445da62018-01-04 10:27:29 -0500824 proxy = provider.refAsTextureProxy(ctx, desc, generatorColorSpace, thisColorSpace);
Christopher Cameron77e96662017-07-08 01:47:47 -0700825 if (proxy) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400826 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
827 kLockTexturePathCount);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500828 set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
Greg Daniel3e70fa32017-10-05 16:27:06 -0400829 return proxy;
Brian Osmandf7e0752017-04-26 16:20:28 -0400830 }
831 }
832
833 // 4. Ask the generator to return RGB(A) data, which the GPU can convert
834 SkBitmap bitmap;
Greg Danielfc5060d2017-10-04 18:36:15 +0000835 if (!proxy && this->lockAsBitmap(&bitmap, chint, format, genPixelsInfo, behavior)) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400836 if (willBeMipped) {
Greg Daniela4ead652018-02-07 10:21:48 -0500837 proxy = proxyProvider->createMipMapProxyFromBitmap(bitmap, dstColorSpace);
Brian Osmandf7e0752017-04-26 16:20:28 -0400838 }
839 if (!proxy) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500840 proxy = GrUploadBitmapToTextureProxy(proxyProvider, bitmap, dstColorSpace);
Brian Osmandf7e0752017-04-26 16:20:28 -0400841 }
Greg Daniele252f082017-10-23 16:05:23 -0400842 if (proxy && (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped())) {
Brian Osmandf7e0752017-04-26 16:20:28 -0400843 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath,
844 kLockTexturePathCount);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500845 set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
Brian Osmandf7e0752017-04-26 16:20:28 -0400846 return proxy;
847 }
848 }
Greg Danielfc5060d2017-10-04 18:36:15 +0000849
850 if (proxy) {
851 // We need a mipped proxy, but we either found a proxy earlier that wasn't mipped, generated
852 // a native non mipped proxy, or generated a non-mipped yuv proxy. Thus we generate a new
853 // mipped surface and copy the original proxy into the base layer. We will then let the gpu
854 // generate the rest of the mips.
855 SkASSERT(willBeMipped);
Greg Daniele252f082017-10-23 16:05:23 -0400856 SkASSERT(GrMipMapped::kNo == proxy->mipMapped());
Greg Daniele1da1d92017-10-06 15:59:27 -0400857 if (auto mippedProxy = GrCopyBaseMipMapToTextureProxy(ctx, proxy.get())) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500858 set_key_on_proxy(proxyProvider, mippedProxy.get(), proxy.get(), key);
Greg Danielfc5060d2017-10-04 18:36:15 +0000859 return mippedProxy;
860 }
861 // We failed to make a mipped proxy with the base copied into it. This could have
862 // been from failure to make the proxy or failure to do the copy. Thus we will fall
863 // back to just using the non mipped proxy; See skbug.com/7094.
864 return proxy;
865 }
866
Brian Osmandf7e0752017-04-26 16:20:28 -0400867 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
868 kLockTexturePathCount);
869 return nullptr;
870}
871
872///////////////////////////////////////////////////////////////////////////////////////////////////
873
874#endif