diff options
author | Brian Osman <brianosman@google.com> | 2016-11-28 09:26:31 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-28 14:58:41 +0000 |
commit | 3b66ab6f9fdc6eacdf0ee1921da28751de30c018 (patch) | |
tree | e81d2a52f48030084c53260a0d3b1bcf0463c96c /src/gpu/GrImageTextureMaker.cpp | |
parent | 781c3c14629342ed3eb00d153822c751406ad80b (diff) |
GrTextureProducer cleanup, phase one: Bitmap and Image makers
Split these into their own files, and actually name the files after the
classes they contain. The top three classes in the hierarchy still need
attention, but those are going to be trickier.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5195
Change-Id: I295f4d50e35748eac38a31f302e14b5b62653c55
Reviewed-on: https://skia-review.googlesource.com/5195
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrImageTextureMaker.cpp')
-rw-r--r-- | src/gpu/GrImageTextureMaker.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp new file mode 100644 index 0000000000..f4a311955d --- /dev/null +++ b/src/gpu/GrImageTextureMaker.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrImageTextureMaker.h" + +#include "GrContext.h" +#include "GrGpuResourcePriv.h" +#include "SkGrPriv.h" +#include "SkImage_Base.h" +#include "SkImageCacherator.h" +#include "SkPixelRef.h" + +static bool cacher_is_alpha_only(const SkImageCacherator& cacher) { + return kAlpha_8_SkColorType == cacher.info().colorType(); +} + +GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, + const SkImage* client, SkImage::CachingHint chint) + : INHERITED(context, cacher->info().width(), cacher->info().height(), + cacher_is_alpha_only(*cacher)) + , fCacher(cacher) + , fClient(client) + , fCachingHint(chint) { + if (client) { + GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), + SkIRect::MakeWH(this->width(), this->height())); + } +} + +GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped, + SkDestinationSurfaceColorMode colorMode) { + return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCachingHint, willBeMipped, + colorMode); +} + +void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey, + SkDestinationSurfaceColorMode colorMode) { + if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { + SkImageCacherator::CachedFormat cacheFormat = + fCacher->chooseCacheFormat(colorMode, this->context()->caps()); + GrUniqueKey cacheKey; + fCacher->makeCacheKeyFromOrigKey(fOriginalKey, cacheFormat, &cacheKey); + MakeCopyKeyFromOrigKey(cacheKey, stretch, paramsCopyKey); + } +} + +void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { + if (fClient) { + as_IB(fClient)->notifyAddedToCache(); + } +} + +SkAlphaType GrImageTextureMaker::alphaType() const { + return fCacher->info().alphaType(); +} +sk_sp<SkColorSpace> GrImageTextureMaker::getColorSpace(SkDestinationSurfaceColorMode colorMode) { + return fCacher->getColorSpace(this->context(), colorMode); +} |