blob: fe4ab232a636054a4873d7f16c7375fea44e2c77 [file] [log] [blame]
* Copyright 2015 Google Inc.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#ifndef SkImageShader_DEFINED
#define SkImageShader_DEFINED
#include "include/core/SkImage.h"
#include "src/shaders/SkBitmapProcShader.h"
#include "src/shaders/SkShaderBase.h"
// private subclass of SkStageUpdater
class SkImageStageUpdater;
class SkImageShader : public SkShaderBase {
static sk_sp<SkShader> Make(sk_sp<SkImage>,
SkTileMode tmx,
SkTileMode tmy,
const SkSamplingOptions*, // null means inherit-from-paint-fq
const SkMatrix* localMatrix,
bool clampAsIfUnpremul = false);
bool isOpaque() const override;
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
static SkM44 CubicResamplerMatrix(float B, float C);
SkTileMode tmx,
SkTileMode tmy,
const SkSamplingOptions*,
const SkMatrix* localMatrix,
bool clampAsIfUnpremul = false);
void flatten(SkWriteBuffer&) const override;
Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override;
SkImage* onIsAImage(SkMatrix*, SkTileMode*) const override;
bool onAppendStages(const SkStageRec&) const override;
SkStageUpdater* onAppendUpdatableStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Coord device, skvm::Coord local, skvm::Color paint,
const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
bool doStages(const SkStageRec&, SkImageStageUpdater* = nullptr) const;
sk_sp<SkImage> fImage;
const SkSamplingOptions fSampling;
const SkTileMode fTileModeX;
const SkTileMode fTileModeY;
const bool fClampAsIfUnpremul;
const bool fUseSamplingOptions; // else inherit filterquality from paint
friend class SkShaderBase;
using INHERITED = SkShaderBase;
// for legacy unflattening
static sk_sp<SkFlattenable> PreSamplingCreate(SkReadBuffer&);