Remove backend factories
BUG=skia: Review URL: https://codereview.chromium.org/778453002
This commit is contained in:
parent
e109145bf3
commit
eb2a676165
@ -8,7 +8,6 @@
|
||||
{
|
||||
'variables': {
|
||||
'skgpu_sources': [
|
||||
'<(skia_include_path)/gpu/GrBackendProcessorFactory.h',
|
||||
'<(skia_include_path)/gpu/GrBinHashKey.h',
|
||||
'<(skia_include_path)/gpu/GrClipData.h',
|
||||
'<(skia_include_path)/gpu/GrColor.h',
|
||||
@ -30,7 +29,6 @@
|
||||
'<(skia_include_path)/gpu/GrResourceKey.h',
|
||||
'<(skia_include_path)/gpu/GrSurface.h',
|
||||
'<(skia_include_path)/gpu/GrShaderVar.h',
|
||||
'<(skia_include_path)/gpu/GrTBackendProcessorFactory.h',
|
||||
'<(skia_include_path)/gpu/GrTexture.h',
|
||||
'<(skia_include_path)/gpu/GrTextureAccess.h',
|
||||
'<(skia_include_path)/gpu/GrTypes.h',
|
||||
|
@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrBackendProcessorFactory_DEFINED
|
||||
#define GrBackendProcessorFactory_DEFINED
|
||||
|
||||
#include "GrTypes.h"
|
||||
#include "SkTemplates.h"
|
||||
#include "SkThread.h"
|
||||
#include "SkTypes.h"
|
||||
#include "SkTArray.h"
|
||||
|
||||
class GrGLProcessor;
|
||||
class GrGLCaps;
|
||||
class GrProcessor;
|
||||
|
||||
/**
|
||||
* Used by processors to build their keys. It incorporates each per-processor key into a larger shader
|
||||
* key.
|
||||
*/
|
||||
class GrProcessorKeyBuilder {
|
||||
public:
|
||||
GrProcessorKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCount(0) {
|
||||
SkASSERT(0 == fData->count() % sizeof(uint32_t));
|
||||
}
|
||||
|
||||
void add32(uint32_t v) {
|
||||
++fCount;
|
||||
fData->push_back_n(4, reinterpret_cast<uint8_t*>(&v));
|
||||
}
|
||||
|
||||
/** Inserts count uint32_ts into the key. The returned pointer is only valid until the next
|
||||
add*() call. */
|
||||
uint32_t* SK_WARN_UNUSED_RESULT add32n(int count) {
|
||||
SkASSERT(count > 0);
|
||||
fCount += count;
|
||||
return reinterpret_cast<uint32_t*>(fData->push_back_n(4 * count));
|
||||
}
|
||||
|
||||
size_t size() const { return sizeof(uint32_t) * fCount; }
|
||||
|
||||
private:
|
||||
SkTArray<uint8_t, true>* fData; // unowned ptr to the larger key.
|
||||
int fCount; // number of uint32_ts added to fData by the processor.
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a GrProcessor of a particular type, creates the corresponding graphics-backend-specific
|
||||
* processor object. It also tracks equivalence of shaders generated via a key. The factory for an
|
||||
* processor is accessed via GrProcessor::getFactory(). Each factory instance is assigned an ID at
|
||||
* construction. The ID of GrProcessor::getFactory() is used as a type identifier. Thus, a
|
||||
* GrProcessor subclass must always return the same object from getFactory() and that factory object
|
||||
* must be unique to the GrProcessor subclass (and unique from any further derived subclasses).
|
||||
*
|
||||
* Rather than subclassing this class themselves, it is recommended that GrProcessor authors use
|
||||
* the templated subclass GrTBackendProcessorFactory by writing their getFactory() method as:
|
||||
*
|
||||
* const GrBackendProcessorFactory& MyProcessor::getFactory() const {
|
||||
* return GrTBackendProcessorFactory<MyProcessor>::getInstance();
|
||||
* }
|
||||
*
|
||||
* Using GrTBackendProcessorFactory places a few constraints on the processor. See that class's
|
||||
* comments.
|
||||
*/
|
||||
class GrBackendProcessorFactory : SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* Produces a human-reable name for the v.
|
||||
*/
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
/**
|
||||
* A unique value for every instance of this factory. It is automatically incorporated into the
|
||||
* processor's key. This allows keys generated by getGLProcessorKey() to only be unique within a
|
||||
* GrProcessor subclass and not necessarily across subclasses.
|
||||
*/
|
||||
uint32_t classID() const { return fProcessorClassID; }
|
||||
|
||||
protected:
|
||||
GrBackendProcessorFactory() : fProcessorClassID(GenClassID()) {}
|
||||
virtual ~GrBackendProcessorFactory() {}
|
||||
|
||||
private:
|
||||
enum {
|
||||
kIllegalProcessorClassID = 0,
|
||||
};
|
||||
|
||||
static uint32_t GenClassID() {
|
||||
// fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
|
||||
// atomic inc returns the old value not the incremented value. So we add
|
||||
// 1 to the returned value.
|
||||
uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&fCurrProcessorClassID)) + 1;
|
||||
if (!id) {
|
||||
SkFAIL("This should never wrap as it should only be called once for each GrProcessor "
|
||||
"subclass.");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
const uint32_t fProcessorClassID;
|
||||
static int32_t fCurrProcessorClassID;
|
||||
};
|
||||
|
||||
class GrFragmentProcessor;
|
||||
class GrGeometryProcessor;
|
||||
class GrXferProcessor;
|
||||
class GrGLFragmentProcessor;
|
||||
class GrGLGeometryProcessor;
|
||||
class GrGLXferProcessor;
|
||||
|
||||
/**
|
||||
* Backend processor factory cannot actually create anything, it is up to subclasses to implement
|
||||
* a create binding which matches Gr to GL in a type safe way
|
||||
*/
|
||||
|
||||
class GrBackendFragmentProcessorFactory : public GrBackendProcessorFactory {
|
||||
public:
|
||||
/**
|
||||
* Generates an processor's key. The key is based on the aspects of the GrProcessor object's
|
||||
* configuration that affect GLSL code generation. Two GrProcessor instances that would cause
|
||||
* this->createGLInstance()->emitCode() to produce different code must produce different keys.
|
||||
*/
|
||||
virtual void getGLProcessorKey(const GrFragmentProcessor&,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder*) const = 0;
|
||||
|
||||
/**
|
||||
* Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a
|
||||
* GLSL program and to manage updating uniforms for the program when it is used.
|
||||
*/
|
||||
virtual GrGLFragmentProcessor* createGLInstance(const GrFragmentProcessor&) const = 0;
|
||||
};
|
||||
|
||||
class GrBackendXferProcessorFactory : public GrBackendProcessorFactory {
|
||||
public:
|
||||
/**
|
||||
* Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a
|
||||
* GLSL program and to manage updating uniforms for the program when it is used.
|
||||
*/
|
||||
virtual GrGLXferProcessor* createGLInstance(const GrXferProcessor&) const = 0;
|
||||
};
|
||||
|
||||
class GrBatchTracker;
|
||||
|
||||
class GrBackendGeometryProcessorFactory : public GrBackendProcessorFactory {
|
||||
public:
|
||||
/**
|
||||
* Generates an processor's key. The key is based on the aspects of the GrProcessor object's
|
||||
* configuration that affect GLSL code generation. Two GrProcessor instances that would cause
|
||||
* this->createGLInstance()->emitCode() to produce different code must produce different keys.
|
||||
*/
|
||||
virtual void getGLProcessorKey(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder*) const = 0;
|
||||
|
||||
/**
|
||||
* Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a
|
||||
* GLSL program and to manage updating uniforms for the program when it is used.
|
||||
*/
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) const = 0;
|
||||
};
|
||||
|
||||
#endif
|
@ -11,6 +11,9 @@
|
||||
#include "GrProcessor.h"
|
||||
|
||||
class GrCoordTransform;
|
||||
class GrGLCaps;
|
||||
class GrGLFragmentProcessor;
|
||||
class GrProcessorKeyBuilder;
|
||||
|
||||
/** Provides custom fragment shader code. Fragment processors receive an input color (vec4f) and
|
||||
produce an output color. They may reference textures and uniforms. They may use
|
||||
@ -24,7 +27,18 @@ public:
|
||||
, fWillReadDstColor(false)
|
||||
, fWillUseInputColor(true) {}
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const = 0;
|
||||
/** Implemented using GLFragmentProcessor::GenKey as described in this class's comment. */
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const = 0;
|
||||
|
||||
/** Returns a new instance of the appropriate *GL* implementation class
|
||||
for the given GrFragmentProcessor; caller is responsible for deleting
|
||||
the object. */
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const = 0;
|
||||
|
||||
/** Human-meaningful string to identify this GrFragmentProcessor; may be embedded
|
||||
in generated shader code. */
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
int numTransforms() const { return fCoordTransforms.count(); }
|
||||
|
||||
@ -38,15 +52,14 @@ public:
|
||||
/** Will this prceossor read the source color value? */
|
||||
bool willUseInputColor() const { return fWillUseInputColor; }
|
||||
|
||||
/** Returns true if this and other prceossor conservatively draw identically. It can only return
|
||||
true when the two prceossor are of the same subclass (i.e. they return the same object from
|
||||
/** Returns true if this and other processor conservatively draw identically. It can only return
|
||||
true when the two processor are of the same subclass (i.e. they return the same object from
|
||||
from getFactory()).
|
||||
|
||||
A return value of true from isEqual() should not be used to test whether the prceossor would
|
||||
generate the same shader code. To test for identical code generation use the prceossor' keys
|
||||
computed by the GrBackendProcessorFactory. */
|
||||
A return value of true from isEqual() should not be used to test whether the processor would
|
||||
generate the same shader code. To test for identical code generation use getGLProcessorKey*/
|
||||
bool isEqual(const GrFragmentProcessor& that) const {
|
||||
if (&this->getFactory() != &that.getFactory() ||
|
||||
if (this->classID() != that.classID() ||
|
||||
!this->hasSameTransforms(that) ||
|
||||
!this->hasSameTextureAccesses(that)) {
|
||||
return false;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#ifndef GrProcessor_DEFINED
|
||||
#define GrProcessor_DEFINED
|
||||
|
||||
#include "GrBackendProcessorFactory.h"
|
||||
#include "GrColor.h"
|
||||
#include "GrProcessorUnitTest.h"
|
||||
#include "GrProgramElement.h"
|
||||
@ -19,6 +18,36 @@ class GrContext;
|
||||
class GrCoordTransform;
|
||||
class GrInvariantOutput;
|
||||
|
||||
/**
|
||||
* Used by processors to build their keys. It incorporates each per-processor key into a larger
|
||||
* shader key.
|
||||
*/
|
||||
class GrProcessorKeyBuilder {
|
||||
public:
|
||||
GrProcessorKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCount(0) {
|
||||
SkASSERT(0 == fData->count() % sizeof(uint32_t));
|
||||
}
|
||||
|
||||
void add32(uint32_t v) {
|
||||
++fCount;
|
||||
fData->push_back_n(4, reinterpret_cast<uint8_t*>(&v));
|
||||
}
|
||||
|
||||
/** Inserts count uint32_ts into the key. The returned pointer is only valid until the next
|
||||
add*() call. */
|
||||
uint32_t* SK_WARN_UNUSED_RESULT add32n(int count) {
|
||||
SkASSERT(count > 0);
|
||||
fCount += count;
|
||||
return reinterpret_cast<uint32_t*>(fData->push_back_n(4 * count));
|
||||
}
|
||||
|
||||
size_t size() const { return sizeof(uint32_t) * fCount; }
|
||||
|
||||
private:
|
||||
SkTArray<uint8_t, true>* fData; // unowned ptr to the larger key.
|
||||
int fCount; // number of uint32_ts added to fData by the processor.
|
||||
};
|
||||
|
||||
/** Provides custom shader code to the Ganesh shading pipeline. GrProcessor objects *must* be
|
||||
immutable: after being constructed, their fields may not change.
|
||||
|
||||
@ -42,26 +71,9 @@ public:
|
||||
*/
|
||||
void computeInvariantOutput(GrInvariantOutput* inout) const;
|
||||
|
||||
/** This object, besides creating back-end-specific helper objects, is used for run-time-type-
|
||||
identification. The factory should be an instance of templated class,
|
||||
GrTBackendProcessorFactory. It is templated on the subclass of GrProcessor. The subclass
|
||||
must have a nested type (or typedef) named GLProcessor which will be the subclass of
|
||||
GrGLProcessor created by the factory.
|
||||
|
||||
Example:
|
||||
class MyCustomProcessor : public GrProcessor {
|
||||
...
|
||||
virtual const GrBackendProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendProcessorFactory<MyCustomProcessor>::getInstance();
|
||||
}
|
||||
...
|
||||
};
|
||||
*/
|
||||
virtual const GrBackendProcessorFactory& getFactory() const = 0;
|
||||
|
||||
/** Human-meaningful string to identify this prcoessor; may be embedded
|
||||
in generated shader code. */
|
||||
const char* name() const;
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
int numTextures() const { return fTextureAccesses.count(); }
|
||||
|
||||
@ -90,8 +102,10 @@ public:
|
||||
*/
|
||||
template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
|
||||
|
||||
uint32_t classID() const { SkASSERT(kIllegalProcessorClassID != fClassID); return fClassID; }
|
||||
|
||||
protected:
|
||||
GrProcessor() : fWillReadFragmentPosition(false) {}
|
||||
GrProcessor() : fClassID(kIllegalProcessorClassID), fWillReadFragmentPosition(false) {}
|
||||
|
||||
/**
|
||||
* Subclasses call this from their constructor to register GrTextureAccesses. The processor
|
||||
@ -110,11 +124,35 @@ protected:
|
||||
*/
|
||||
void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
|
||||
|
||||
template <typename PROC_SUBCLASS> void initClassID() {
|
||||
static uint32_t kClassID = GenClassID();
|
||||
fClassID = kClassID;
|
||||
}
|
||||
|
||||
uint32_t fClassID;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Subclass implements this to support getConstantColorComponents(...).
|
||||
*/
|
||||
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
|
||||
|
||||
static uint32_t GenClassID() {
|
||||
// fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
|
||||
// atomic inc returns the old value not the incremented value. So we add
|
||||
// 1 to the returned value.
|
||||
uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrProcessorClassID)) + 1;
|
||||
if (!id) {
|
||||
SkFAIL("This should never wrap as it should only be called once for each GrProcessor "
|
||||
"subclass.");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
enum {
|
||||
kIllegalProcessorClassID = 0,
|
||||
};
|
||||
static int32_t gCurrProcessorClassID;
|
||||
|
||||
SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
|
||||
bool fWillReadFragmentPosition;
|
||||
@ -122,7 +160,6 @@ private:
|
||||
typedef GrProgramElement INHERITED;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This creates a processor outside of the memory pool. The processor's destructor will be called
|
||||
* at global destruction time. NAME will be the name of the created instance.
|
||||
|
@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrTBackendProcessorFactory_DEFINED
|
||||
#define GrTBackendProcessorFactory_DEFINED
|
||||
|
||||
#include "GrBackendProcessorFactory.h"
|
||||
|
||||
/**
|
||||
* Implements GrBackendProcessorFactory for a GrProcessor subclass as a singleton. This can be used
|
||||
* by most GrProcessor subclasses to implement the GrProcessor::getFactory() method:
|
||||
*
|
||||
* const GrBackendProcessorFactory& MyProcessor::getFactory() const {
|
||||
* return GrTBackendProcessorFactory<MyProcessor>::getInstance();
|
||||
* }
|
||||
*
|
||||
* Using this class requires that the GrProcessor subclass always produces the same GrGLProcessor
|
||||
* subclass. Additionally, it adds the following requirements to the GrProcessor and GrGLProcessor
|
||||
* subclasses:
|
||||
*
|
||||
* 1. The GrGLProcessor used by GrProcessor subclass MyProcessor must be named or typedef'ed to
|
||||
* MyProcessor::GLProcessor.
|
||||
* 2. MyProcessor::GLProcessor must have a static function:
|
||||
void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b)
|
||||
* which generates a key that maps 1 to 1 with code variations emitted by
|
||||
* MyProcessor::GLProcessor::emitCode().
|
||||
* 3. MyProcessor must have a static function:
|
||||
* const char* Name()
|
||||
* which returns a human-readable name for the processor.
|
||||
*/
|
||||
template <class ProcessorClass, class BackEnd, class ProcessorBase, class GLProcessorBase>
|
||||
class GrTBackendProcessorFactory : public BackEnd {
|
||||
public:
|
||||
typedef typename ProcessorClass::GLProcessor GLProcessor;
|
||||
|
||||
/** Returns a human-readable name for the processor. Implemented using GLProcessor::Name as
|
||||
* described in this class's comment. */
|
||||
virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); }
|
||||
|
||||
/** Returns a new instance of the appropriate *GL* implementation class
|
||||
for the given GrProcessor; caller is responsible for deleting
|
||||
the object. */
|
||||
virtual GLProcessorBase* createGLInstance(const ProcessorBase& processor) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, processor));
|
||||
}
|
||||
|
||||
/** This class is a singleton. This function returns the single instance. */
|
||||
static const BackEnd& getInstance() {
|
||||
static SkAlignedSTStorage<1, GrTBackendProcessorFactory> gInstanceMem;
|
||||
static const GrTBackendProcessorFactory* gInstance;
|
||||
if (!gInstance) {
|
||||
gInstance = SkNEW_PLACEMENT(gInstanceMem.get(),
|
||||
GrTBackendProcessorFactory);
|
||||
}
|
||||
return *gInstance;
|
||||
}
|
||||
|
||||
protected:
|
||||
GrTBackendProcessorFactory() {}
|
||||
};
|
||||
|
||||
/*
|
||||
* Every processor so far derives from one of the following subclasses of
|
||||
* GrTBackendProcessorFactory. All of this machinery is necessary to ensure that creatGLInstace is
|
||||
* typesafe and does not require any casting.
|
||||
*/
|
||||
template <class ProcessorClass>
|
||||
class GrTBackendGeometryProcessorFactory : public GrBackendGeometryProcessorFactory {
|
||||
public:
|
||||
typedef typename ProcessorClass::GLProcessor GLProcessor;
|
||||
|
||||
/** Returns a human-readable name for the processor. Implemented using GLProcessor::Name as
|
||||
* described in this class's comment. */
|
||||
virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); }
|
||||
|
||||
/** Implemented using GLProcessor::GenKey as described in this class's comment. */
|
||||
virtual void getGLProcessorKey(const GrGeometryProcessor& processor,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(processor, bt, caps, b);
|
||||
}
|
||||
|
||||
|
||||
/** Returns a new instance of the appropriate *GL* implementation class
|
||||
for the given GrProcessor; caller is responsible for deleting
|
||||
the object. */
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, gp, bt));
|
||||
}
|
||||
|
||||
/** This class is a singleton. This function returns the single instance. */
|
||||
static const GrBackendGeometryProcessorFactory& getInstance() {
|
||||
static SkAlignedSTStorage<1, GrTBackendGeometryProcessorFactory> gInstanceMem;
|
||||
static const GrTBackendGeometryProcessorFactory* gInstance;
|
||||
if (!gInstance) {
|
||||
gInstance = SkNEW_PLACEMENT(gInstanceMem.get(),
|
||||
GrTBackendGeometryProcessorFactory);
|
||||
}
|
||||
return *gInstance;
|
||||
}
|
||||
protected:
|
||||
GrTBackendGeometryProcessorFactory() {}
|
||||
};
|
||||
|
||||
template <class ProcessorClass>
|
||||
class GrTBackendFragmentProcessorFactory : public GrBackendFragmentProcessorFactory {
|
||||
public:
|
||||
typedef typename ProcessorClass::GLProcessor GLProcessor;
|
||||
|
||||
/** Returns a human-readable name for the processor. Implemented using GLProcessor::Name as
|
||||
* described in this class's comment. */
|
||||
virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); }
|
||||
|
||||
/** Implemented using GLProcessor::GenKey as described in this class's comment. */
|
||||
virtual void getGLProcessorKey(const GrFragmentProcessor& processor,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(processor, caps, b);
|
||||
}
|
||||
|
||||
/** Returns a new instance of the appropriate *GL* implementation class
|
||||
for the given GrProcessor; caller is responsible for deleting
|
||||
the object. */
|
||||
virtual GrGLFragmentProcessor* createGLInstance(const GrFragmentProcessor& gp) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, gp));
|
||||
}
|
||||
|
||||
/** This class is a singleton. This function returns the single instance. */
|
||||
static const GrBackendFragmentProcessorFactory& getInstance() {
|
||||
static SkAlignedSTStorage<1, GrTBackendFragmentProcessorFactory> gInstanceMem;
|
||||
static const GrTBackendFragmentProcessorFactory* gInstance;
|
||||
if (!gInstance) {
|
||||
gInstance = SkNEW_PLACEMENT(gInstanceMem.get(),
|
||||
GrTBackendFragmentProcessorFactory);
|
||||
}
|
||||
return *gInstance;
|
||||
}
|
||||
protected:
|
||||
GrTBackendFragmentProcessorFactory() {}
|
||||
};
|
||||
|
||||
#endif
|
@ -810,7 +810,6 @@ void SkXfermode::xferA8(SkAlpha* SK_RESTRICT dst,
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcessorUnitTest.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
@ -831,20 +830,24 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<XferEffect>::getInstance();
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
static const char* Name() { return "XferEffect"; }
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this));
|
||||
}
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "XferEffect"; }
|
||||
|
||||
SkXfermode::Mode mode() const { return fMode; }
|
||||
const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess; }
|
||||
|
||||
class GLProcessor : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
GLProcessor(const GrFragmentProcessor&) {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
const char* outputColor,
|
||||
@ -1228,6 +1231,7 @@ public:
|
||||
private:
|
||||
XferEffect(SkXfermode::Mode mode, GrTexture* background)
|
||||
: fMode(mode) {
|
||||
this->initClassID<XferEffect>();
|
||||
if (background) {
|
||||
fBackgroundTransform.reset(kLocal_GrCoordSet, background);
|
||||
this->addCoordTransform(&fBackgroundTransform);
|
||||
|
@ -47,14 +47,12 @@ SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrTextureAccess.h"
|
||||
|
||||
#include "SkGr.h"
|
||||
|
||||
class GrGLAlphaThresholdEffect;
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class AlphaThresholdEffect : public GrFragmentProcessor {
|
||||
|
||||
@ -71,13 +69,14 @@ public:
|
||||
|
||||
virtual ~AlphaThresholdEffect() {};
|
||||
|
||||
static const char* Name() { return "Alpha Threshold"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Alpha Threshold"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
float innerThreshold() const { return fInnerThreshold; }
|
||||
float outerThreshold() const { return fOuterThreshold; }
|
||||
|
||||
typedef GrGLAlphaThresholdEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
AlphaThresholdEffect(GrTexture* texture,
|
||||
@ -92,6 +91,7 @@ private:
|
||||
, fMaskCoordTransform(kLocal_GrCoordSet,
|
||||
GrCoordTransform::MakeDivByTextureWHMatrix(maskTexture), maskTexture)
|
||||
, fMaskTextureAccess(maskTexture) {
|
||||
this->initClassID<AlphaThresholdEffect>();
|
||||
this->addCoordTransform(&fImageCoordTransform);
|
||||
this->addTextureAccess(&fImageTextureAccess);
|
||||
this->addCoordTransform(&fMaskCoordTransform);
|
||||
@ -116,7 +116,7 @@ private:
|
||||
|
||||
class GrGLAlphaThresholdEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLAlphaThresholdEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLAlphaThresholdEffect(const GrFragmentProcessor&) {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -135,11 +135,6 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void GrGLAlphaThresholdEffect::emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor&,
|
||||
const char* outputColor,
|
||||
@ -213,8 +208,13 @@ GrFragmentProcessor* AlphaThresholdEffect::TestCreate(SkRandom* random,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrBackendFragmentProcessorFactory& AlphaThresholdEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<AlphaThresholdEffect>::getInstance();
|
||||
void AlphaThresholdEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLAlphaThresholdEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* AlphaThresholdEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLAlphaThresholdEffect, (*this));
|
||||
}
|
||||
|
||||
bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#endif
|
||||
|
||||
static const bool gUseUnpremul = false;
|
||||
@ -241,7 +240,7 @@ SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2,
|
||||
|
||||
class GrGLArithmeticEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLArithmeticEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLArithmeticEffect(const GrProcessor&);
|
||||
virtual ~GrGLArithmeticEffect();
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -273,10 +272,17 @@ public:
|
||||
|
||||
virtual ~GrArithmeticEffect();
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE { return "Arithmetic"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GrGLArithmeticEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GrGLArithmeticEffect, (*this));
|
||||
}
|
||||
|
||||
typedef GrGLArithmeticEffect GLProcessor;
|
||||
static const char* Name() { return "Arithmetic"; }
|
||||
GrTexture* backgroundTexture() const { return fBackgroundAccess.getTexture(); }
|
||||
|
||||
float k1() const { return fK1; }
|
||||
@ -307,6 +313,7 @@ private:
|
||||
GrArithmeticEffect::GrArithmeticEffect(float k1, float k2, float k3, float k4,
|
||||
bool enforcePMColor, GrTexture* background)
|
||||
: fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) {
|
||||
this->initClassID<GrArithmeticEffect>();
|
||||
if (background) {
|
||||
fBackgroundTransform.reset(kLocal_GrCoordSet, background);
|
||||
this->addCoordTransform(&fBackgroundTransform);
|
||||
@ -329,10 +336,6 @@ bool GrArithmeticEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
fEnforcePMColor == s.fEnforcePMColor;
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrArithmeticEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrArithmeticEffect>::getInstance();
|
||||
}
|
||||
|
||||
void GrArithmeticEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||
// TODO: optimize this
|
||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
||||
@ -340,10 +343,8 @@ void GrArithmeticEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLArithmeticEffect::GrGLArithmeticEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory),
|
||||
fEnforcePMColor(true) {
|
||||
GrGLArithmeticEffect::GrGLArithmeticEffect(const GrProcessor&)
|
||||
: fEnforcePMColor(true) {
|
||||
}
|
||||
|
||||
GrGLArithmeticEffect::~GrGLArithmeticEffect() {
|
||||
|
@ -22,12 +22,11 @@
|
||||
#include "GrTexture.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "effects/GrSimpleTextureEffect.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkGrPixelRef.h"
|
||||
#include "SkDraw.h"
|
||||
#include "effects/GrSimpleTextureEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#endif
|
||||
|
||||
SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
|
||||
@ -609,11 +608,13 @@ class GrRectBlurEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
virtual ~GrRectBlurEffect();
|
||||
|
||||
static const char* Name() { return "RectBlur"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "RectBlur"; }
|
||||
|
||||
typedef GrGLRectBlurEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
/**
|
||||
* Create a simple filter effect with custom bicubic coefficients.
|
||||
*/
|
||||
@ -659,8 +660,7 @@ private:
|
||||
|
||||
class GrGLRectBlurEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLRectBlurEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&);
|
||||
GrGLRectBlurEffect(const GrProcessor&) {}
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
const char* outputColor,
|
||||
@ -679,12 +679,6 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
|
||||
|
||||
GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void OutputRectBlurProfileLookup(GrGLFPFragmentBuilder* fsBuilder,
|
||||
const GrGLShaderBuilder::TextureSampler& sampler,
|
||||
const char *output,
|
||||
@ -794,10 +788,10 @@ bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma,
|
||||
|
||||
GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma,
|
||||
GrTexture *blur_profile)
|
||||
: INHERITED(),
|
||||
fRect(rect),
|
||||
: fRect(rect),
|
||||
fSigma(sigma),
|
||||
fBlurProfileAccess(blur_profile) {
|
||||
this->initClassID<GrRectBlurEffect>();
|
||||
this->addTextureAccess(&fBlurProfileAccess);
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
@ -805,8 +799,13 @@ GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma,
|
||||
GrRectBlurEffect::~GrRectBlurEffect() {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrRectBlurEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrRectBlurEffect>::getInstance();
|
||||
void GrRectBlurEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLRectBlurEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrRectBlurEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLRectBlurEffect, (*this));
|
||||
}
|
||||
|
||||
bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
@ -870,22 +869,21 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
|
||||
return true;
|
||||
}
|
||||
|
||||
class GrGLRRectBlurEffect;
|
||||
|
||||
class GrRRectBlurEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
|
||||
static GrFragmentProcessor* Create(GrContext* context, float sigma, const SkRRect&);
|
||||
|
||||
virtual ~GrRRectBlurEffect() {};
|
||||
static const char* Name() { return "GrRRectBlur"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "GrRRectBlur"; }
|
||||
|
||||
const SkRRect& getRRect() const { return fRRect; }
|
||||
float getSigma() const { return fSigma; }
|
||||
|
||||
typedef GrGLRRectBlurEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture);
|
||||
@ -981,14 +979,11 @@ void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance();
|
||||
}
|
||||
|
||||
GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTexture *ninePatchTexture)
|
||||
: fRRect(rrect),
|
||||
fSigma(sigma),
|
||||
fNinePatchAccess(ninePatchTexture) {
|
||||
this->initClassID<GrRRectBlurEffect>();
|
||||
this->addTextureAccess(&fNinePatchAccess);
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
@ -1019,7 +1014,7 @@ GrFragmentProcessor* GrRRectBlurEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GrGLRRectBlurEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLRRectBlurEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLRRectBlurEffect(const GrProcessor&) {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -1037,11 +1032,6 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLRRectBlurEffect::GrGLRRectBlurEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED (factory) {
|
||||
}
|
||||
|
||||
void GrGLRRectBlurEffect::emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor&,
|
||||
const char* outputColor,
|
||||
@ -1116,6 +1106,13 @@ void GrGLRRectBlurEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
pdman.set1f(fCornerRadiusUniform, radius);
|
||||
}
|
||||
|
||||
void GrRRectBlurEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
|
||||
GrGLRRectBlurEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLRRectBlurEffect, (*this));
|
||||
}
|
||||
|
||||
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
|
||||
GrPaint* grp,
|
||||
|
@ -15,11 +15,10 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrTexturePriv.h"
|
||||
#include "SkGr.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -193,16 +192,20 @@ public:
|
||||
|
||||
virtual ~GrColorCubeEffect();
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE { return "ColorCube"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); }
|
||||
|
||||
static const char* Name() { return "ColorCube"; }
|
||||
|
||||
virtual void onComputeInvariantOutput(GrInvariantOutput*) const SK_OVERRIDE;
|
||||
|
||||
class GLProcessor : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&);
|
||||
GLProcessor(const GrProcessor&);
|
||||
virtual ~GLProcessor();
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -239,6 +242,7 @@ private:
|
||||
GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube)
|
||||
: fColorCubeTransform(kLocal_GrCoordSet, colorCube)
|
||||
, fColorCubeAccess(colorCube, "bgra", GrTextureParams::kBilerp_FilterMode) {
|
||||
this->initClassID<GrColorCubeEffect>();
|
||||
this->addCoordTransform(&fColorCubeTransform);
|
||||
this->addTextureAccess(&fColorCubeAccess);
|
||||
}
|
||||
@ -246,8 +250,12 @@ GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube)
|
||||
GrColorCubeEffect::~GrColorCubeEffect() {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrColorCubeEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrColorCubeEffect>::getInstance();
|
||||
void GrColorCubeEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
|
||||
GLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrColorCubeEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLProcessor, (*this));
|
||||
}
|
||||
|
||||
void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||
@ -256,9 +264,7 @@ void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrColorCubeEffect::GLProcessor::GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
GrColorCubeEffect::GLProcessor::GLProcessor(const GrProcessor&) {
|
||||
}
|
||||
|
||||
GrColorCubeEffect::GLProcessor::~GLProcessor() {
|
||||
|
@ -115,10 +115,9 @@ SkFlattenable* SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcessorUnitTest.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkGr.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkGr.h"
|
||||
|
||||
namespace {
|
||||
/**
|
||||
@ -195,19 +194,23 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<ModeColorFilterEffect>::getInstance();
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
static const char* Name() { return "ModeColorFilterEffect"; }
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this));
|
||||
}
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "ModeColorFilterEffect"; }
|
||||
|
||||
SkXfermode::Mode mode() const { return fMode; }
|
||||
GrColor color() const { return fColor; }
|
||||
|
||||
class GLProcessor : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
GLProcessor(const GrProcessor&) {
|
||||
}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
@ -263,7 +266,9 @@ public:
|
||||
private:
|
||||
ModeColorFilterEffect(GrColor color, SkXfermode::Mode mode)
|
||||
: fMode(mode),
|
||||
fColor(color) {}
|
||||
fColor(color) {
|
||||
this->initClassID<ModeColorFilterEffect>();
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE {
|
||||
const ModeColorFilterEffect& s = other.cast<ModeColorFilterEffect>();
|
||||
|
@ -325,7 +325,6 @@ bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const {
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
@ -335,12 +334,18 @@ public:
|
||||
return SkNEW_ARGS(ColorMatrixEffect, (matrix));
|
||||
}
|
||||
|
||||
static const char* Name() { return "Color Matrix"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Color Matrix"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<ColorMatrixEffect>::getInstance();
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this));
|
||||
}
|
||||
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
class GLProcessor : public GrGLFragmentProcessor {
|
||||
@ -348,10 +353,7 @@ public:
|
||||
// this class always generates the same code.
|
||||
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b) {}
|
||||
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
GLProcessor(const GrProcessor&) {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor&,
|
||||
@ -410,7 +412,9 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) {}
|
||||
ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) {
|
||||
this->initClassID<ColorMatrixEffect>();
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& s) const {
|
||||
const ColorMatrixEffect& cme = s.cast<ColorMatrixEffect>();
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -287,8 +286,7 @@ bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix&
|
||||
#if SK_SUPPORT_GPU
|
||||
class GrGLDisplacementMapEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLDisplacementMapEffect(const GrBackendProcessorFactory&,
|
||||
const GrProcessor&);
|
||||
GrGLDisplacementMapEffect(const GrProcessor&);
|
||||
virtual ~GrGLDisplacementMapEffect();
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -328,15 +326,22 @@ public:
|
||||
|
||||
virtual ~GrDisplacementMapEffect();
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GrGLDisplacementMapEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this));
|
||||
}
|
||||
|
||||
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const
|
||||
{ return fXChannelSelector; }
|
||||
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const
|
||||
{ return fYChannelSelector; }
|
||||
const SkVector& scale() const { return fScale; }
|
||||
|
||||
typedef GrGLDisplacementMapEffect GLProcessor;
|
||||
static const char* Name() { return "DisplacementMap"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DisplacementMap"; }
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
|
||||
@ -456,6 +461,7 @@ GrDisplacementMapEffect::GrDisplacementMapEffect(
|
||||
, fXChannelSelector(xChannelSelector)
|
||||
, fYChannelSelector(yChannelSelector)
|
||||
, fScale(scale) {
|
||||
this->initClassID<GrDisplacementMapEffect>();
|
||||
this->addCoordTransform(&fDisplacementTransform);
|
||||
this->addTextureAccess(&fDisplacementAccess);
|
||||
this->addCoordTransform(&fColorTransform);
|
||||
@ -472,10 +478,6 @@ bool GrDisplacementMapEffect::onIsEqual(const GrFragmentProcessor& sBase) const
|
||||
fScale == s.fScale;
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInstance();
|
||||
}
|
||||
|
||||
void GrDisplacementMapEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||
// Any displacement offset bringing a pixel out of bounds will output a color of (0,0,0,0),
|
||||
// so the only way we'd get a constant alpha is if the input color image has a constant alpha
|
||||
@ -514,10 +516,8 @@ GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& proc)
|
||||
: INHERITED(factory)
|
||||
, fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
|
||||
GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc)
|
||||
: fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
|
||||
, fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) {
|
||||
}
|
||||
|
||||
|
@ -15,12 +15,11 @@
|
||||
#include "SkTypes.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
class GrGLDiffuseLightingEffect;
|
||||
class GrGLSpecularLightingEffect;
|
||||
@ -374,11 +373,12 @@ public:
|
||||
kd));
|
||||
}
|
||||
|
||||
static const char* Name() { return "DiffuseLighting"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DiffuseLighting"; }
|
||||
|
||||
typedef GrGLDiffuseLightingEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
SkScalar kd() const { return fKD; }
|
||||
|
||||
private:
|
||||
@ -410,11 +410,13 @@ public:
|
||||
ks,
|
||||
shininess));
|
||||
}
|
||||
static const char* Name() { return "SpecularLighting"; }
|
||||
|
||||
typedef GrGLSpecularLightingEffect GLProcessor;
|
||||
virtual const char* name() const SK_OVERRIDE { return "SpecularLighting"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
SkScalar ks() const { return fKS; }
|
||||
SkScalar shininess() const { return fShininess; }
|
||||
|
||||
@ -1190,7 +1192,7 @@ SkLight* create_random_light(SkRandom* random) {
|
||||
|
||||
class GrGLLightingEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLLightingEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLLightingEffect(const GrProcessor&);
|
||||
virtual ~GrGLLightingEffect();
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -1222,7 +1224,7 @@ private:
|
||||
|
||||
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLDiffuseLightingEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLDiffuseLightingEffect(const GrProcessor&);
|
||||
virtual void emitLightFunc(GrGLFPBuilder*, SkString* funcName) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
|
||||
|
||||
@ -1236,7 +1238,7 @@ private:
|
||||
|
||||
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLSpecularLightingEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLSpecularLightingEffect(const GrProcessor&);
|
||||
virtual void emitLightFunc(GrGLFPBuilder*, SkString* funcName) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
|
||||
|
||||
@ -1281,10 +1283,7 @@ GrDiffuseLightingEffect::GrDiffuseLightingEffect(GrTexture* texture,
|
||||
const SkMatrix& matrix,
|
||||
SkScalar kd)
|
||||
: INHERITED(texture, light, surfaceScale, matrix), fKD(kd) {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrDiffuseLightingEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrDiffuseLightingEffect>::getInstance();
|
||||
this->initClassID<GrDiffuseLightingEffect>();
|
||||
}
|
||||
|
||||
bool GrDiffuseLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
@ -1293,6 +1292,15 @@ bool GrDiffuseLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const
|
||||
this->kd() == s.kd();
|
||||
}
|
||||
|
||||
void GrDiffuseLightingEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLDiffuseLightingEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrDiffuseLightingEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLDiffuseLightingEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
|
||||
|
||||
GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
|
||||
@ -1313,9 +1321,7 @@ GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLLightingEffect::GrGLLightingEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& fp)
|
||||
: INHERITED(factory) {
|
||||
GrGLLightingEffect::GrGLLightingEffect(const GrProcessor& fp) {
|
||||
const GrLightingEffect& m = fp.cast<GrLightingEffect>();
|
||||
fLight = m.light()->createGLLight();
|
||||
}
|
||||
@ -1440,9 +1446,8 @@ void GrGLLightingEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& proc)
|
||||
: INHERITED(factory, proc) {
|
||||
GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProcessor& proc)
|
||||
: INHERITED(proc) {
|
||||
}
|
||||
|
||||
void GrGLDiffuseLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString* funcName) {
|
||||
@ -1486,10 +1491,7 @@ GrSpecularLightingEffect::GrSpecularLightingEffect(GrTexture* texture,
|
||||
: INHERITED(texture, light, surfaceScale, matrix),
|
||||
fKS(ks),
|
||||
fShininess(shininess) {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrSpecularLightingEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrSpecularLightingEffect>::getInstance();
|
||||
this->initClassID<GrSpecularLightingEffect>();
|
||||
}
|
||||
|
||||
bool GrSpecularLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
@ -1499,6 +1501,15 @@ bool GrSpecularLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const
|
||||
this->shininess() == s.shininess();
|
||||
}
|
||||
|
||||
void GrSpecularLightingEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLSpecularLightingEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrSpecularLightingEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLSpecularLightingEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
|
||||
|
||||
GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(SkRandom* random,
|
||||
@ -1519,9 +1530,8 @@ GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(SkRandom* random,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& proc)
|
||||
: INHERITED(factory, proc) {
|
||||
GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrProcessor& proc)
|
||||
: INHERITED(proc) {
|
||||
}
|
||||
|
||||
void GrGLSpecularLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString* funcName) {
|
||||
|
@ -11,11 +11,10 @@
|
||||
#include "SkString.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#endif
|
||||
|
||||
void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count,
|
||||
@ -64,18 +63,20 @@ public:
|
||||
return SkRef(gLumaEffect);
|
||||
}
|
||||
|
||||
static const char* Name() { return "Luminance-to-Alpha"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Luminance-to-Alpha"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<LumaColorFilterEffect>::getInstance();
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this));
|
||||
}
|
||||
|
||||
class GLProcessor : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
GLProcessor(const GrProcessor&) {}
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b) {}
|
||||
|
||||
@ -105,6 +106,10 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
LumaColorFilterEffect() {
|
||||
this->initClassID<LumaColorFilterEffect>();
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
|
||||
|
||||
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
|
||||
|
@ -14,15 +14,12 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLTexture.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
class GrGLMagnifierEffect;
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrMagnifierEffect : public GrSingleTextureEffect {
|
||||
|
||||
@ -45,9 +42,12 @@ public:
|
||||
|
||||
virtual ~GrMagnifierEffect() {};
|
||||
|
||||
static const char* Name() { return "Magnifier"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Magnifier"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
float x_offset() const { return fXOffset; }
|
||||
float y_offset() const { return fYOffset; }
|
||||
float x_inv_zoom() const { return fXInvZoom; }
|
||||
@ -55,8 +55,6 @@ public:
|
||||
float x_inv_inset() const { return fXInvInset; }
|
||||
float y_inv_inset() const { return fYInvInset; }
|
||||
|
||||
typedef GrGLMagnifierEffect GLProcessor;
|
||||
|
||||
private:
|
||||
GrMagnifierEffect(GrTexture* texture,
|
||||
float xOffset,
|
||||
@ -71,7 +69,9 @@ private:
|
||||
, fXInvZoom(xInvZoom)
|
||||
, fYInvZoom(yInvZoom)
|
||||
, fXInvInset(xInvInset)
|
||||
, fYInvInset(yInvInset) {}
|
||||
, fYInvInset(yInvInset) {
|
||||
this->initClassID<GrMagnifierEffect>();
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
|
||||
|
||||
@ -94,7 +94,7 @@ typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
class GrGLMagnifierEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLMagnifierEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLMagnifierEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -113,9 +113,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProcessor&) {
|
||||
}
|
||||
|
||||
void GrGLMagnifierEffect::emitCode(GrGLFPBuilder* builder,
|
||||
@ -181,6 +179,15 @@ void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrMagnifierEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLMagnifierEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrMagnifierEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLMagnifierEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
|
||||
|
||||
GrFragmentProcessor* GrMagnifierEffect::TestCreate(SkRandom* random,
|
||||
@ -211,10 +218,6 @@ GrFragmentProcessor* GrMagnifierEffect::TestCreate(SkRandom* random,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrMagnifierEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrMagnifierEffect>::getInstance();
|
||||
}
|
||||
|
||||
bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>();
|
||||
return (this->fXOffset == s.fXOffset &&
|
||||
|
@ -16,10 +16,9 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTexture.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "effects/Gr1DKernelEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "effects/Gr1DKernelEffect.h"
|
||||
#endif
|
||||
|
||||
SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
|
||||
@ -268,9 +267,6 @@ SkFlattenable* SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GrGLMorphologyEffect;
|
||||
|
||||
/**
|
||||
* Morphology effects. Depending upon the type of morphology, either the
|
||||
* component-wise min (Erode_Type) or max (Dilate_Type) of all pixels in the
|
||||
@ -295,11 +291,11 @@ public:
|
||||
|
||||
MorphologyType type() const { return fType; }
|
||||
|
||||
static const char* Name() { return "Morphology"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Morphology"; }
|
||||
|
||||
typedef GrGLMorphologyEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
@ -321,7 +317,7 @@ private:
|
||||
|
||||
class GrGLMorphologyEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLMorphologyEffect (const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLMorphologyEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -344,9 +340,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& proc)
|
||||
: INHERITED(factory) {
|
||||
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) {
|
||||
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
|
||||
fRadius = m.radius();
|
||||
fType = m.type();
|
||||
@ -428,15 +422,19 @@ GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture,
|
||||
MorphologyType type)
|
||||
: Gr1DKernelEffect(texture, direction, radius)
|
||||
, fType(type) {
|
||||
this->initClassID<GrMorphologyEffect>();
|
||||
}
|
||||
|
||||
GrMorphologyEffect::~GrMorphologyEffect() {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrMorphologyEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrMorphologyEffect>::getInstance();
|
||||
void GrMorphologyEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
|
||||
GrGLMorphologyEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrMorphologyEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLMorphologyEffect, (*this));
|
||||
}
|
||||
bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>();
|
||||
return (this->radius() == s.radius() &&
|
||||
|
@ -18,10 +18,9 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkGr.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkGr.h"
|
||||
#endif
|
||||
|
||||
static const int kBlockSize = 256;
|
||||
@ -487,12 +486,9 @@ void SkPerlinNoiseShader::PerlinNoiseShaderContext::shadeSpan16(
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
class GrGLPerlinNoise : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLPerlinNoise(const GrBackendProcessorFactory&,
|
||||
const GrProcessor&);
|
||||
GrGLPerlinNoise(const GrProcessor&);
|
||||
virtual ~GrGLPerlinNoise() {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -536,10 +532,17 @@ public:
|
||||
SkDELETE(fPaintingData);
|
||||
}
|
||||
|
||||
static const char* Name() { return "PerlinNoise"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<GrPerlinNoiseEffect>::getInstance();
|
||||
virtual const char* name() const SK_OVERRIDE { return "PerlinNoise"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GrGLPerlinNoise::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GrGLPerlinNoise, (*this));
|
||||
}
|
||||
|
||||
const SkPerlinNoiseShader::StitchData& stitchData() const { return fPaintingData->fStitchDataInit; }
|
||||
|
||||
SkPerlinNoiseShader::Type type() const { return fType; }
|
||||
@ -549,8 +552,6 @@ public:
|
||||
const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); }
|
||||
uint8_t alpha() const { return fAlpha; }
|
||||
|
||||
typedef GrGLPerlinNoise GLProcessor;
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE {
|
||||
const GrPerlinNoiseEffect& s = sBase.cast<GrPerlinNoiseEffect>();
|
||||
@ -578,6 +579,7 @@ private:
|
||||
, fPermutationsAccess(permutationsTexture)
|
||||
, fNoiseAccess(noiseTexture)
|
||||
, fPaintingData(paintingData) {
|
||||
this->initClassID<GrPerlinNoiseEffect>();
|
||||
this->addTextureAccess(&fPermutationsAccess);
|
||||
this->addTextureAccess(&fNoiseAccess);
|
||||
fCoordTransform.reset(kLocal_GrCoordSet, matrix);
|
||||
@ -631,10 +633,8 @@ GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
|
||||
return effect;
|
||||
}
|
||||
|
||||
GrGLPerlinNoise::GrGLPerlinNoise(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED (factory)
|
||||
, fType(processor.cast<GrPerlinNoiseEffect>().type())
|
||||
GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
|
||||
: fType(processor.cast<GrPerlinNoiseEffect>().type())
|
||||
, fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles())
|
||||
, fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) {
|
||||
}
|
||||
|
@ -253,25 +253,22 @@ bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
|
||||
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkGr.h"
|
||||
#include "effects/GrTextureStripAtlas.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
|
||||
class GLColorTableEffect;
|
||||
|
||||
class ColorTableEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsigned flags);
|
||||
|
||||
virtual ~ColorTableEffect();
|
||||
|
||||
static const char* Name() { return "ColorTable"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE { return "ColorTable"; }
|
||||
|
||||
typedef GLColorTableEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
const GrTextureStripAtlas* atlas() const { return fAtlas; }
|
||||
int atlasRow() const { return fRow; }
|
||||
@ -298,7 +295,7 @@ private:
|
||||
|
||||
class GLColorTableEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLColorTableEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLColorTableEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -316,9 +313,8 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLColorTableEffect::GLColorTableEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
GLColorTableEffect::GLColorTableEffect(const GrProcessor&) {
|
||||
}
|
||||
|
||||
void GLColorTableEffect::setData(const GrGLProgramDataManager& pdm, const GrProcessor& proc) {
|
||||
// The textures are organized in a strip where the rows are ordered a, r, g, b.
|
||||
@ -420,7 +416,7 @@ ColorTableEffect::ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atla
|
||||
, fFlags(flags)
|
||||
, fAtlas(atlas)
|
||||
, fRow(row) {
|
||||
|
||||
this->initClassID<ColorTableEffect>();
|
||||
this->addTextureAccess(&fTextureAccess);
|
||||
}
|
||||
|
||||
@ -430,8 +426,13 @@ ColorTableEffect::~ColorTableEffect() {
|
||||
}
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& ColorTableEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<ColorTableEffect>::getInstance();
|
||||
void ColorTableEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLColorTableEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* ColorTableEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLColorTableEffect, (*this));
|
||||
}
|
||||
|
||||
bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
|
@ -887,13 +887,11 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
||||
#include "effects/GrTextureStripAtlas.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkGr.h"
|
||||
|
||||
GrGLGradientEffect::GrGLGradientEffect(const GrBackendProcessorFactory& factory)
|
||||
: INHERITED(factory)
|
||||
, fCachedYCoord(SK_ScalarMax) {
|
||||
GrGLGradientEffect::GrGLGradientEffect()
|
||||
: fCachedYCoord(SK_ScalarMax) {
|
||||
}
|
||||
|
||||
GrGLGradientEffect::~GrGLGradientEffect() { }
|
||||
|
@ -297,7 +297,6 @@ static inline int next_dither_toggle16(int toggle) {
|
||||
#include "gl/GrGLProcessor.h"
|
||||
|
||||
class GrFragmentStage;
|
||||
class GrBackendProcessorFactory;
|
||||
class GrInvariantOutput;
|
||||
|
||||
/*
|
||||
@ -397,7 +396,7 @@ private:
|
||||
// Base class for GL gradient effects
|
||||
class GrGLGradientEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLGradientEffect(const GrBackendProcessorFactory& factory);
|
||||
GrGLGradientEffect();
|
||||
virtual ~GrGLGradientEffect();
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
|
||||
|
@ -451,7 +451,6 @@ void SkLinearGradient::LinearGradientContext::shadeSpan16(int x, int y,
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkGr.h"
|
||||
|
||||
@ -460,8 +459,7 @@ void SkLinearGradient::LinearGradientContext::shadeSpan16(int x, int y,
|
||||
class GrGLLinearGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
|
||||
GrGLLinearGradient(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED (factory) { }
|
||||
GrGLLinearGradient(const GrProcessor&) {}
|
||||
|
||||
virtual ~GrGLLinearGradient() { }
|
||||
|
||||
@ -495,19 +493,25 @@ public:
|
||||
|
||||
virtual ~GrLinearGradient() { }
|
||||
|
||||
static const char* Name() { return "Linear Gradient"; }
|
||||
const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<GrLinearGradient>::getInstance();
|
||||
virtual const char* name() const { return "Linear Gradient"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GrGLLinearGradient::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
typedef GrGLLinearGradient GLProcessor;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GrGLLinearGradient, (*this));
|
||||
}
|
||||
|
||||
private:
|
||||
GrLinearGradient(GrContext* ctx,
|
||||
const SkLinearGradient& shader,
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm)
|
||||
: INHERITED(ctx, shader, matrix, tm) { }
|
||||
: INHERITED(ctx, shader, matrix, tm) {
|
||||
this->initClassID<GrLinearGradient>();
|
||||
}
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
typedef GrGradientEffect INHERITED;
|
||||
@ -547,7 +551,7 @@ void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const GrLinearGradient& ge = fp.cast<GrLinearGradient>();
|
||||
this->emitUniforms(builder, ge);
|
||||
SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0);
|
||||
t.append(".x");
|
||||
|
@ -461,15 +461,13 @@ void SkRadialGradient::RadialGradientContext::shadeSpan(int x, int y,
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkGr.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrGLRadialGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
|
||||
GrGLRadialGradient(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&) : INHERITED (factory) { }
|
||||
GrGLRadialGradient(const GrProcessor&) {}
|
||||
virtual ~GrGLRadialGradient() { }
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -502,12 +500,16 @@ public:
|
||||
|
||||
virtual ~GrRadialGradient() { }
|
||||
|
||||
static const char* Name() { return "Radial Gradient"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<GrRadialGradient>::getInstance();
|
||||
virtual const char* name() const SK_OVERRIDE { return "Radial Gradient"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GrGLRadialGradient::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
typedef GrGLRadialGradient GLProcessor;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GrGLRadialGradient, (*this));
|
||||
}
|
||||
|
||||
private:
|
||||
GrRadialGradient(GrContext* ctx,
|
||||
@ -515,6 +517,7 @@ private:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm)
|
||||
: INHERITED(ctx, shader, matrix, tm) {
|
||||
this->initClassID<GrRadialGradient>();
|
||||
}
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
@ -556,7 +559,7 @@ void GrGLRadialGradient::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const GrRadialGradient& ge = fp.cast<GrRadialGradient>();
|
||||
this->emitUniforms(builder, ge);
|
||||
SkString t("length(");
|
||||
t.append(builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0));
|
||||
|
@ -177,15 +177,13 @@ void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t*
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkGr.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrGLSweepGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
|
||||
GrGLSweepGradient(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&) : INHERITED (factory) { }
|
||||
GrGLSweepGradient(const GrProcessor&) {}
|
||||
virtual ~GrGLSweepGradient() { }
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -215,18 +213,24 @@ public:
|
||||
}
|
||||
virtual ~GrSweepGradient() { }
|
||||
|
||||
static const char* Name() { return "Sweep Gradient"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<GrSweepGradient>::getInstance();
|
||||
virtual const char* name() const SK_OVERRIDE { return "Sweep Gradient"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GrGLSweepGradient::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
typedef GrGLSweepGradient GLProcessor;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GrGLSweepGradient, (*this));
|
||||
}
|
||||
|
||||
private:
|
||||
GrSweepGradient(GrContext* ctx,
|
||||
const SkSweepGradient& shader,
|
||||
const SkMatrix& matrix)
|
||||
: INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) { }
|
||||
: INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) {
|
||||
this->initClassID<GrSweepGradient>();
|
||||
}
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
typedef GrGradientEffect INHERITED;
|
||||
@ -264,7 +268,7 @@ void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const GrSweepGradient& ge = fp.cast<GrSweepGradient>();
|
||||
this->emitUniforms(builder, ge);
|
||||
SkString coords2D = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0);
|
||||
const GrGLContextInfo ctxInfo = builder->ctxInfo();
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "SkTwoPointConicalGradient.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
// For brevity
|
||||
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -55,8 +54,6 @@ static void set_matrix_edge_conical(const SkTwoPointConicalGradient& shader,
|
||||
}
|
||||
}
|
||||
|
||||
class GLEdge2PtConicalEffect;
|
||||
|
||||
class Edge2PtConicalEffect : public GrGradientEffect {
|
||||
public:
|
||||
|
||||
@ -69,16 +66,19 @@ public:
|
||||
|
||||
virtual ~Edge2PtConicalEffect() {}
|
||||
|
||||
static const char* Name() { return "Two-Point Conical Gradient Edge Touching"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE {
|
||||
return "Two-Point Conical Gradient Edge Touching";
|
||||
}
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
// The radial gradient parameters can collapse to a linear (instead of quadratic) equation.
|
||||
SkScalar center() const { return fCenterX1; }
|
||||
SkScalar diffRadius() const { return fDiffRadius; }
|
||||
SkScalar radius() const { return fRadius0; }
|
||||
|
||||
typedef GLEdge2PtConicalEffect GLProcessor;
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE {
|
||||
const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
|
||||
@ -96,6 +96,7 @@ private:
|
||||
fCenterX1(shader.getCenterX1()),
|
||||
fRadius0(shader.getStartRadius()),
|
||||
fDiffRadius(shader.getDiffRadius()){
|
||||
this->initClassID<Edge2PtConicalEffect>();
|
||||
// We should only be calling this shader if we are degenerate case with touching circles
|
||||
// When deciding if we are in edge case, we scaled by the end radius for cases when the
|
||||
// start radius was close to zero, otherwise we scaled by the start radius. In addition
|
||||
@ -137,7 +138,7 @@ private:
|
||||
|
||||
class GLEdge2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLEdge2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
|
||||
GLEdge2PtConicalEffect(const GrProcessor&);
|
||||
virtual ~GLEdge2PtConicalEffect() { }
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -169,8 +170,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
const GrBackendFragmentProcessorFactory& Edge2PtConicalEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<Edge2PtConicalEffect>::getInstance();
|
||||
void Edge2PtConicalEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLEdge2PtConicalEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* Edge2PtConicalEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLEdge2PtConicalEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect);
|
||||
@ -214,10 +220,8 @@ GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
return fp;
|
||||
}
|
||||
|
||||
GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
|
||||
: fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedRadius(-SK_ScalarMax)
|
||||
, fCachedDiffRadius(-SK_ScalarMax) {}
|
||||
@ -228,7 +232,7 @@ void GLEdge2PtConicalEffect::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const Edge2PtConicalEffect& ge = fp.cast<Edge2PtConicalEffect>();
|
||||
this->emitUniforms(builder, ge);
|
||||
fParamUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType, "Conical2FSParams", 3);
|
||||
@ -368,8 +372,6 @@ static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLFocalOutside2PtConicalEffect;
|
||||
|
||||
class FocalOutside2PtConicalEffect : public GrGradientEffect {
|
||||
public:
|
||||
|
||||
@ -383,14 +385,17 @@ public:
|
||||
|
||||
virtual ~FocalOutside2PtConicalEffect() { }
|
||||
|
||||
static const char* Name() { return "Two-Point Conical Gradient Focal Outside"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE {
|
||||
return "Two-Point Conical Gradient Focal Outside";
|
||||
}
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
bool isFlipped() const { return fIsFlipped; }
|
||||
SkScalar focal() const { return fFocalX; }
|
||||
|
||||
typedef GLFocalOutside2PtConicalEffect GLProcessor;
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE {
|
||||
const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConicalEffect>();
|
||||
@ -404,7 +409,9 @@ private:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm,
|
||||
SkScalar focalX)
|
||||
: INHERITED(ctx, shader, matrix, tm), fFocalX(focalX), fIsFlipped(shader.isFlippedGrad()) {}
|
||||
: INHERITED(ctx, shader, matrix, tm), fFocalX(focalX), fIsFlipped(shader.isFlippedGrad()) {
|
||||
this->initClassID<FocalOutside2PtConicalEffect>();
|
||||
}
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
@ -416,7 +423,7 @@ private:
|
||||
|
||||
class GLFocalOutside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLFocalOutside2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
|
||||
GLFocalOutside2PtConicalEffect(const GrProcessor&);
|
||||
virtual ~GLFocalOutside2PtConicalEffect() { }
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -449,8 +456,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
const GrBackendFragmentProcessorFactory& FocalOutside2PtConicalEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<FocalOutside2PtConicalEffect>::getInstance();
|
||||
void FocalOutside2PtConicalEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLFocalOutside2PtConicalEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* FocalOutside2PtConicalEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLFocalOutside2PtConicalEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect);
|
||||
@ -491,10 +503,8 @@ GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
return effect;
|
||||
}
|
||||
|
||||
GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor& processor)
|
||||
: fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedFocal(SK_ScalarMax) {
|
||||
const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtConicalEffect>();
|
||||
@ -507,7 +517,7 @@ void GLFocalOutside2PtConicalEffect::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const FocalOutside2PtConicalEffect& ge = fp.cast<FocalOutside2PtConicalEffect>();
|
||||
this->emitUniforms(builder, ge);
|
||||
fParamUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType, "Conical2FSParams", 2);
|
||||
@ -593,8 +603,13 @@ public:
|
||||
|
||||
virtual ~FocalInside2PtConicalEffect() {}
|
||||
|
||||
static const char* Name() { return "Two-Point Conical Gradient Focal Inside"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE {
|
||||
return "Two-Point Conical Gradient Focal Inside";
|
||||
}
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
SkScalar focal() const { return fFocalX; }
|
||||
|
||||
@ -612,7 +627,9 @@ private:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm,
|
||||
SkScalar focalX)
|
||||
: INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) {}
|
||||
: INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) {
|
||||
this->initClassID<FocalInside2PtConicalEffect>();
|
||||
}
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
@ -623,7 +640,7 @@ private:
|
||||
|
||||
class GLFocalInside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLFocalInside2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
|
||||
GLFocalInside2PtConicalEffect(const GrProcessor&);
|
||||
virtual ~GLFocalInside2PtConicalEffect() {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -654,8 +671,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
const GrBackendFragmentProcessorFactory& FocalInside2PtConicalEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<FocalInside2PtConicalEffect>::getInstance();
|
||||
void FocalInside2PtConicalEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLFocalInside2PtConicalEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* FocalInside2PtConicalEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLFocalInside2PtConicalEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect);
|
||||
@ -698,10 +720,8 @@ GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
return fp;
|
||||
}
|
||||
|
||||
GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
|
||||
: fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedFocal(SK_ScalarMax) {}
|
||||
|
||||
@ -711,7 +731,7 @@ void GLFocalInside2PtConicalEffect::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const FocalInside2PtConicalEffect& ge = fp.cast<FocalInside2PtConicalEffect>();
|
||||
this->emitUniforms(builder, ge);
|
||||
fFocalUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType, "Conical2FSParams");
|
||||
@ -814,8 +834,6 @@ static ConicalType set_matrix_circle_conical(const SkTwoPointConicalGradient& sh
|
||||
return kOutside_ConicalType;
|
||||
}
|
||||
|
||||
class GLCircleInside2PtConicalEffect;
|
||||
|
||||
class CircleInside2PtConicalEffect : public GrGradientEffect {
|
||||
public:
|
||||
|
||||
@ -829,8 +847,12 @@ public:
|
||||
|
||||
virtual ~CircleInside2PtConicalEffect() {}
|
||||
|
||||
static const char* Name() { return "Two-Point Conical Gradient Inside"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE { return "Two-Point Conical Gradient Inside"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
|
||||
SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
|
||||
@ -838,8 +860,6 @@ public:
|
||||
SkScalar B() const { return fInfo.fB; }
|
||||
SkScalar C() const { return fInfo.fC; }
|
||||
|
||||
typedef GLCircleInside2PtConicalEffect GLProcessor;
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE {
|
||||
const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConicalEffect>();
|
||||
@ -855,7 +875,9 @@ private:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm,
|
||||
const CircleConicalInfo& info)
|
||||
: INHERITED(ctx, shader, matrix, tm), fInfo(info) {}
|
||||
: INHERITED(ctx, shader, matrix, tm), fInfo(info) {
|
||||
this->initClassID<CircleInside2PtConicalEffect>();
|
||||
}
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
@ -866,7 +888,7 @@ private:
|
||||
|
||||
class GLCircleInside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLCircleInside2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
|
||||
GLCircleInside2PtConicalEffect(const GrProcessor&);
|
||||
virtual ~GLCircleInside2PtConicalEffect() {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -902,8 +924,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
const GrBackendFragmentProcessorFactory& CircleInside2PtConicalEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<CircleInside2PtConicalEffect>::getInstance();
|
||||
void CircleInside2PtConicalEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLCircleInside2PtConicalEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* CircleInside2PtConicalEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLCircleInside2PtConicalEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect);
|
||||
@ -945,10 +972,8 @@ GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
return processor;
|
||||
}
|
||||
|
||||
GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor& processor)
|
||||
: fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedCenterX(SK_ScalarMax)
|
||||
, fCachedCenterY(SK_ScalarMax)
|
||||
@ -962,7 +987,7 @@ void GLCircleInside2PtConicalEffect::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const CircleInside2PtConicalEffect& ge = fp.cast<CircleInside2PtConicalEffect>();
|
||||
this->emitUniforms(builder, ge);
|
||||
fCenterUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, "Conical2FSCenter");
|
||||
@ -1029,8 +1054,6 @@ void GLCircleInside2PtConicalEffect::GenKey(const GrProcessor& processor,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLCircleOutside2PtConicalEffect;
|
||||
|
||||
class CircleOutside2PtConicalEffect : public GrGradientEffect {
|
||||
public:
|
||||
|
||||
@ -1044,8 +1067,11 @@ public:
|
||||
|
||||
virtual ~CircleOutside2PtConicalEffect() {}
|
||||
|
||||
static const char* Name() { return "Two-Point Conical Gradient Outside"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE { return "Two-Point Conical Gradient Outside"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
|
||||
SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
|
||||
@ -1055,8 +1081,6 @@ public:
|
||||
SkScalar tLimit() const { return fTLimit; }
|
||||
bool isFlipped() const { return fIsFlipped; }
|
||||
|
||||
typedef GLCircleOutside2PtConicalEffect GLProcessor;
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE {
|
||||
const CircleOutside2PtConicalEffect& s = sBase.cast<CircleOutside2PtConicalEffect>();
|
||||
@ -1075,6 +1099,7 @@ private:
|
||||
SkShader::TileMode tm,
|
||||
const CircleConicalInfo& info)
|
||||
: INHERITED(ctx, shader, matrix, tm), fInfo(info) {
|
||||
this->initClassID<CircleOutside2PtConicalEffect>();
|
||||
if (shader.getStartRadius() != shader.getEndRadius()) {
|
||||
fTLimit = SkScalarDiv(shader.getStartRadius(),
|
||||
(shader.getStartRadius() - shader.getEndRadius()));
|
||||
@ -1096,7 +1121,7 @@ private:
|
||||
|
||||
class GLCircleOutside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLCircleOutside2PtConicalEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLCircleOutside2PtConicalEffect(const GrProcessor&);
|
||||
virtual ~GLCircleOutside2PtConicalEffect() {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -1135,8 +1160,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
const GrBackendFragmentProcessorFactory& CircleOutside2PtConicalEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<CircleOutside2PtConicalEffect>::getInstance();
|
||||
void CircleOutside2PtConicalEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLCircleOutside2PtConicalEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* CircleOutside2PtConicalEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLCircleOutside2PtConicalEffect, (*this));
|
||||
}
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect);
|
||||
@ -1179,10 +1209,8 @@ GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
return processor;
|
||||
}
|
||||
|
||||
GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcessor& processor)
|
||||
: fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedCenterX(SK_ScalarMax)
|
||||
, fCachedCenterY(SK_ScalarMax)
|
||||
@ -1200,7 +1228,7 @@ void GLCircleOutside2PtConicalEffect::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const CircleOutside2PtConicalEffect& ge = fp.cast<CircleOutside2PtConicalEffect>();
|
||||
this->emitUniforms(builder, ge);
|
||||
fCenterUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, "Conical2FSCenter");
|
||||
|
@ -386,9 +386,8 @@ void SkTwoPointRadialGradient::init() {
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkGr.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
// For brevity
|
||||
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -397,7 +396,7 @@ class GrGLRadial2Gradient : public GrGLGradientEffect {
|
||||
|
||||
public:
|
||||
|
||||
GrGLRadial2Gradient(const GrBackendProcessorFactory& factory, const GrProcessor&);
|
||||
GrGLRadial2Gradient(const GrProcessor&);
|
||||
virtual ~GrGLRadial2Gradient() { }
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
@ -447,9 +446,15 @@ public:
|
||||
|
||||
virtual ~GrRadial2Gradient() { }
|
||||
|
||||
static const char* Name() { return "Two-Point Radial Gradient"; }
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<GrRadial2Gradient>::getInstance();
|
||||
virtual const char* name() const SK_OVERRIDE { return "Two-Point Radial Gradient"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GrGLRadial2Gradient::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GrGLRadial2Gradient, (*this));
|
||||
}
|
||||
|
||||
// The radial gradient parameters can collapse to a linear (instead of quadratic) equation.
|
||||
@ -458,8 +463,6 @@ public:
|
||||
SkScalar radius() const { return fRadius0; }
|
||||
bool isPosRoot() const { return SkToBool(fPosRoot); }
|
||||
|
||||
typedef GrGLRadial2Gradient GLProcessor;
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE {
|
||||
const GrRadial2Gradient& s = sBase.cast<GrRadial2Gradient>();
|
||||
@ -477,6 +480,7 @@ private:
|
||||
, fCenterX1(shader.getCenterX1())
|
||||
, fRadius0(shader.getStartRadius())
|
||||
, fPosRoot(shader.getDiffRadius() < 0) {
|
||||
this->initClassID<GrRadial2Gradient>();
|
||||
// We pass the linear part of the quadratic as a varying.
|
||||
// float b = 2.0 * (fCenterX1 * x - fRadius0 * z)
|
||||
fBTransform = this->getCoordTransform();
|
||||
@ -542,10 +546,8 @@ GrFragmentProcessor* GrRadial2Gradient::TestCreate(SkRandom* random,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
GrGLRadial2Gradient::GrGLRadial2Gradient(const GrProcessor& processor)
|
||||
: fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedCenter(SK_ScalarMax)
|
||||
, fCachedRadius(-SK_ScalarMax)
|
||||
@ -561,7 +563,7 @@ void GrGLRadial2Gradient::emitCode(GrGLFPBuilder* builder,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrGradientEffect& ge = fp.cast<GrGradientEffect>();
|
||||
const GrRadial2Gradient& ge = fp.cast<GrRadial2Gradient>();
|
||||
this->emitUniforms(builder, ge);
|
||||
fParamUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType, "Radial2FSParams", 6);
|
||||
|
@ -11,20 +11,17 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawState.h"
|
||||
#include "GrDrawTargetCaps.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrPathUtils.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkString.h"
|
||||
#include "SkStrokeRec.h"
|
||||
#include "SkTraceEvent.h"
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
|
||||
}
|
||||
@ -516,21 +513,15 @@ public:
|
||||
|
||||
virtual ~QuadEdgeEffect() {}
|
||||
|
||||
static const char* Name() { return "QuadEdge"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "QuadEdge"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inQuadEdge() const { return fInQuadEdge; }
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance();
|
||||
}
|
||||
|
||||
class GLProcessor : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {}
|
||||
GLProcessor(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>();
|
||||
@ -586,8 +577,19 @@ public:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
private:
|
||||
QuadEdgeEffect() {
|
||||
this->initClassID<QuadEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_GrVertexAttribType));
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GrIndexBuffer.h"
|
||||
#include "GrPathUtils.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkGeometry.h"
|
||||
#include "SkStroke.h"
|
||||
#include "SkTemplates.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "GrDrawState.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
@ -62,11 +61,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static const char* Name() { return "DefaultGeometryProcessor"; }
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendGeometryProcessorFactory<DefaultGeoProc>::getInstance();
|
||||
}
|
||||
virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inColor() const { return fInColor; }
|
||||
@ -75,10 +70,8 @@ public:
|
||||
|
||||
class GLProcessor : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {}
|
||||
GLProcessor(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>();
|
||||
@ -127,6 +120,16 @@ public:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
private:
|
||||
DefaultGeoProc(uint32_t gpTypeFlags)
|
||||
: fInPosition(NULL)
|
||||
@ -134,6 +137,7 @@ private:
|
||||
, fInLocalCoords(NULL)
|
||||
, fInCoverage(NULL)
|
||||
, fFlags(gpTypeFlags) {
|
||||
this->initClassID<DefaultGeoProc>();
|
||||
bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_GPType);
|
||||
bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLocalCoord_GPType);
|
||||
bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCoverage_GPType);
|
||||
|
@ -34,6 +34,8 @@ private:
|
||||
uint8_t fData[kMaxSize];
|
||||
};
|
||||
|
||||
class GrGLCaps;
|
||||
class GrGLGeometryProcessor;
|
||||
class GrOptDrawState;
|
||||
|
||||
/**
|
||||
@ -55,7 +57,18 @@ public:
|
||||
, fHasVertexCoverage(false)
|
||||
, fHasLocalCoords(false) {}
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0;
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
/** Implemented using GLProcessor::GenKey as described in this class's comment. */
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const = 0;
|
||||
|
||||
|
||||
/** Returns a new instance of the appropriate *GL* implementation class
|
||||
for the given GrProcessor; caller is responsible for deleting
|
||||
the object. */
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const = 0;
|
||||
|
||||
/*
|
||||
* This is a safeguard to prevent GPs from going beyond platform specific attribute limits.
|
||||
@ -91,7 +104,7 @@ public:
|
||||
would generate the same shader code. To test for identical code generation use the
|
||||
processors' keys computed by the GrBackendEffectFactory. */
|
||||
bool isEqual(const GrGeometryProcessor& that) const {
|
||||
if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAccesses(that)) {
|
||||
if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)) {
|
||||
return false;
|
||||
}
|
||||
return this->onIsEqual(that);
|
||||
@ -143,5 +156,4 @@ private:
|
||||
|
||||
typedef GrProcessor INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,24 +7,20 @@
|
||||
|
||||
#include "GrOvalRenderer.h"
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
#include "GrDrawState.h"
|
||||
#include "GrDrawTarget.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
|
||||
#include "SkRRect.h"
|
||||
#include "SkStrokeRec.h"
|
||||
#include "SkTLazy.h"
|
||||
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "effects/GrRRectEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
namespace {
|
||||
// TODO(joshualitt) add per vertex colors
|
||||
@ -78,23 +74,16 @@ public:
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inCircleEdge() const { return fInCircleEdge; }
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendGeometryProcessorFactory<CircleEdgeEffect>::getInstance();
|
||||
}
|
||||
|
||||
virtual ~CircleEdgeEffect() {}
|
||||
|
||||
static const char* Name() { return "CircleEdge"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "CircleEdge"; }
|
||||
|
||||
inline bool isStroked() const { return fStroke; }
|
||||
|
||||
class GLProcessor : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {}
|
||||
GLProcessor(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>();
|
||||
@ -140,9 +129,19 @@ public:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
private:
|
||||
CircleEdgeEffect(bool stroke) {
|
||||
this->initClassID<CircleEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInCircleEdge = &this->addVertexAttrib(GrAttribute("inCircleEdge",
|
||||
kVec4f_GrVertexAttribType));
|
||||
@ -201,14 +200,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendGeometryProcessorFactory<EllipseEdgeEffect>::getInstance();
|
||||
}
|
||||
|
||||
virtual ~EllipseEdgeEffect() {}
|
||||
|
||||
static const char* Name() { return "EllipseEdge"; }
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "EllipseEdge"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inEllipseOffset() const { return fInEllipseOffset; }
|
||||
@ -218,10 +212,8 @@ public:
|
||||
|
||||
class GLProcessor : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {}
|
||||
GLProcessor(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>();
|
||||
@ -290,8 +282,19 @@ public:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
private:
|
||||
EllipseEdgeEffect(bool stroke) {
|
||||
this->initClassID<EllipseEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInEllipseOffset = &this->addVertexAttrib(GrAttribute("inEllipseOffset",
|
||||
kVec2f_GrVertexAttribType));
|
||||
@ -360,13 +363,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendGeometryProcessorFactory<DIEllipseEdgeEffect>::getInstance();
|
||||
}
|
||||
|
||||
virtual ~DIEllipseEdgeEffect() {}
|
||||
|
||||
static const char* Name() { return "DIEllipseEdge"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DIEllipseEdge"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inEllipseOffsets0() const { return fInEllipseOffsets0; }
|
||||
@ -376,10 +375,8 @@ public:
|
||||
|
||||
class GLProcessor : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {}
|
||||
GLProcessor(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>();
|
||||
@ -463,8 +460,19 @@ public:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
private:
|
||||
DIEllipseEdgeEffect(Mode mode) {
|
||||
this->initClassID<DIEllipseEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInEllipseOffsets0 = &this->addVertexAttrib(GrAttribute("inEllipseOffsets0",
|
||||
kVec2f_GrVertexAttribType));
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "GrProcessor.h"
|
||||
#include "GrBackendProcessorFactory.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrGeometryData.h"
|
||||
@ -16,6 +15,9 @@
|
||||
|
||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
|
||||
class GrFragmentProcessor;
|
||||
class GrGeometryProcessor;
|
||||
|
||||
/*
|
||||
* Originally these were both in the processor unit test header, but then it seemed to cause linker
|
||||
* problems on android.
|
||||
@ -109,17 +111,13 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
int32_t GrBackendProcessorFactory::fCurrProcessorClassID =
|
||||
GrBackendProcessorFactory::kIllegalProcessorClassID;
|
||||
int32_t GrProcessor::gCurrProcessorClassID =
|
||||
GrProcessor::kIllegalProcessorClassID;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrProcessor::~GrProcessor() {}
|
||||
|
||||
const char* GrProcessor::name() const {
|
||||
return this->getFactory().name();
|
||||
}
|
||||
|
||||
void GrProcessor::addTextureAccess(const GrTextureAccess* access) {
|
||||
fTextureAccesses.push_back(access);
|
||||
this->addGpuResource(access->getProgramTexture());
|
||||
@ -181,4 +179,3 @@ void* GrGeometryData::operator new(size_t size) {
|
||||
void GrGeometryData::operator delete(void* target) {
|
||||
GrProcessor_Globals::GetTLS()->release(target);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#ifndef GrProgramDesc_DEFINED
|
||||
#define GrProgramDesc_DEFINED
|
||||
|
||||
#include "GrBackendProcessorFactory.h"
|
||||
#include "GrColor.h"
|
||||
#include "GrTypesPriv.h"
|
||||
#include "SkChecksum.h"
|
||||
|
@ -7,16 +7,14 @@
|
||||
|
||||
#include "GrBezierEffect.h"
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrGLConicEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLConicEffect(const GrBackendProcessorFactory&,
|
||||
const GrGeometryProcessor&,
|
||||
GrGLConicEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
|
||||
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
|
||||
@ -36,10 +34,8 @@ private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor& processor,
|
||||
const GrBatchTracker& bt)
|
||||
: INHERITED (factory) {
|
||||
GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor,
|
||||
const GrBatchTracker& bt) {
|
||||
const GrConicEffect& ce = processor.cast<GrConicEffect>();
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
@ -133,12 +129,19 @@ void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
|
||||
GrConicEffect::~GrConicEffect() {}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& GrConicEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<GrConicEffect>::getInstance();
|
||||
void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLConicEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GrGLConicEffect, (*this, bt));
|
||||
}
|
||||
|
||||
GrConicEffect::GrConicEffect(GrPrimitiveEdgeType edgeType)
|
||||
: fEdgeType(edgeType) {
|
||||
this->initClassID<GrConicEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInConicCoeffs = &this->addVertexAttrib(GrAttribute("inConicCoeffs",
|
||||
kVec4f_GrVertexAttribType));
|
||||
@ -172,8 +175,7 @@ GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GrGLQuadEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLQuadEffect(const GrBackendProcessorFactory&,
|
||||
const GrGeometryProcessor&,
|
||||
GrGLQuadEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
|
||||
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
|
||||
@ -193,10 +195,8 @@ private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor& processor,
|
||||
const GrBatchTracker& bt)
|
||||
: INHERITED (factory) {
|
||||
GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor,
|
||||
const GrBatchTracker& bt) {
|
||||
const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
@ -276,12 +276,19 @@ void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
|
||||
GrQuadEffect::~GrQuadEffect() {}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& GrQuadEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<GrQuadEffect>::getInstance();
|
||||
void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLQuadEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GrGLQuadEffect, (*this, bt));
|
||||
}
|
||||
|
||||
GrQuadEffect::GrQuadEffect(GrPrimitiveEdgeType edgeType)
|
||||
: fEdgeType(edgeType) {
|
||||
this->initClassID<GrQuadEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInHairQuadEdge = &this->addVertexAttrib(GrAttribute("inHairQuadEdge",
|
||||
kVec4f_GrVertexAttribType));
|
||||
@ -315,8 +322,7 @@ GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GrGLCubicEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLCubicEffect(const GrBackendProcessorFactory&,
|
||||
const GrGeometryProcessor&,
|
||||
GrGLCubicEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
|
||||
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
|
||||
@ -336,10 +342,8 @@ private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor& processor,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {
|
||||
GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor,
|
||||
const GrBatchTracker&) {
|
||||
const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
@ -460,12 +464,19 @@ void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
|
||||
GrCubicEffect::~GrCubicEffect() {}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& GrCubicEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<GrCubicEffect>::getInstance();
|
||||
void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLCubicEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GrGLCubicEffect, (*this, bt));
|
||||
}
|
||||
|
||||
GrCubicEffect::GrCubicEffect(GrPrimitiveEdgeType edgeType)
|
||||
: fEdgeType(edgeType) {
|
||||
this->initClassID<GrCubicEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs",
|
||||
kVec4f_GrVertexAttribType));
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
|
||||
virtual ~GrConicEffect();
|
||||
|
||||
static const char* Name() { return "Conic"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Conic"; }
|
||||
|
||||
inline const GrAttribute* inPosition() const { return fInPosition; }
|
||||
inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; }
|
||||
@ -94,9 +94,11 @@ public:
|
||||
inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
|
||||
inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
typedef GrGLConicEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrConicEffect(GrPrimitiveEdgeType);
|
||||
@ -157,7 +159,7 @@ public:
|
||||
|
||||
virtual ~GrQuadEffect();
|
||||
|
||||
static const char* Name() { return "Quad"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Quad"; }
|
||||
|
||||
inline const GrAttribute* inPosition() const { return fInPosition; }
|
||||
inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; }
|
||||
@ -165,9 +167,11 @@ public:
|
||||
inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
|
||||
inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
typedef GrGLQuadEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrQuadEffect(GrPrimitiveEdgeType);
|
||||
@ -230,7 +234,7 @@ public:
|
||||
|
||||
virtual ~GrCubicEffect();
|
||||
|
||||
static const char* Name() { return "Cubic"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Cubic"; }
|
||||
|
||||
inline const GrAttribute* inPosition() const { return fInPosition; }
|
||||
inline const GrAttribute* inCubicCoeffs() const { return fInCubicCoeffs; }
|
||||
@ -238,9 +242,11 @@ public:
|
||||
inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
|
||||
inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
typedef GrGLCubicEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrCubicEffect(GrPrimitiveEdgeType);
|
||||
|
@ -5,9 +5,9 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrBicubicEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
#define DS(x) SkDoubleToScalar(x)
|
||||
|
||||
@ -21,8 +21,7 @@ const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = {
|
||||
|
||||
class GrGLBicubicEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLBicubicEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&);
|
||||
GrGLBicubicEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -49,8 +48,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) {
|
||||
}
|
||||
|
||||
void GrGLBicubicEffect::emitCode(GrGLFPBuilder* builder,
|
||||
@ -140,6 +138,7 @@ GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
|
||||
const SkShader::TileMode tileModes[2])
|
||||
: INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone_FilterMode))
|
||||
, fDomain(GrTextureDomain::IgnoredDomain()) {
|
||||
this->initClassID<GrBicubicEffect>();
|
||||
convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coefficients);
|
||||
}
|
||||
|
||||
@ -150,14 +149,20 @@ GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
|
||||
: INHERITED(texture, matrix, GrTextureParams(SkShader::kClamp_TileMode,
|
||||
GrTextureParams::kNone_FilterMode))
|
||||
, fDomain(domain, GrTextureDomain::kClamp_Mode) {
|
||||
this->initClassID<GrBicubicEffect>();
|
||||
convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coefficients);
|
||||
}
|
||||
|
||||
GrBicubicEffect::~GrBicubicEffect() {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrBicubicEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrBicubicEffect>::getInstance();
|
||||
void GrBicubicEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLBicubicEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrBicubicEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLBicubicEffect, (*this));
|
||||
}
|
||||
|
||||
bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "GrSingleTextureEffect.h"
|
||||
#include "GrTextureDomain.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
class GrGLBicubicEffect;
|
||||
class GrInvariantOutput;
|
||||
@ -24,12 +23,13 @@ public:
|
||||
};
|
||||
virtual ~GrBicubicEffect();
|
||||
|
||||
static const char* Name() { return "Bicubic"; }
|
||||
const float* coefficients() const { return fCoefficients; }
|
||||
|
||||
typedef GrGLBicubicEffect GLProcessor;
|
||||
virtual const char* name() const SK_OVERRIDE { return "Bicubic"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
const GrTextureDomain& domain() const { return fDomain; }
|
||||
|
||||
|
@ -8,17 +8,14 @@
|
||||
#include "GrConfigConversionEffect.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkMatrix.h"
|
||||
|
||||
class GrGLConfigConversionEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLConfigConversionEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED (factory) {
|
||||
GrGLConfigConversionEffect(const GrProcessor& processor) {
|
||||
const GrConfigConversionEffect& configConversionEffect =
|
||||
processor.cast<GrConfigConversionEffect>();
|
||||
fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue();
|
||||
@ -109,16 +106,13 @@ GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture,
|
||||
: GrSingleTextureEffect(texture, matrix)
|
||||
, fSwapRedAndBlue(swapRedAndBlue)
|
||||
, fPMConversion(pmConversion) {
|
||||
this->initClassID<GrConfigConversionEffect>();
|
||||
SkASSERT(kRGBA_8888_GrPixelConfig == texture->config() ||
|
||||
kBGRA_8888_GrPixelConfig == texture->config());
|
||||
// Why did we pollute our texture cache instead of using a GrSingleTextureEffect?
|
||||
SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion);
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrConfigConversionEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrConfigConversionEffect>::getInstance();
|
||||
}
|
||||
|
||||
bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& s) const {
|
||||
const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>();
|
||||
return other.fSwapRedAndBlue == fSwapRedAndBlue &&
|
||||
@ -152,6 +146,16 @@ GrFragmentProcessor* GrConfigConversionEffect::TestCreate(SkRandom* random,
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrConfigConversionEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLConfigConversionEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrConfigConversionEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLConfigConversionEffect, (*this));
|
||||
}
|
||||
|
||||
void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context,
|
||||
PMConversion* pmToUPMRule,
|
||||
PMConversion* upmToPMRule) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "GrSingleTextureEffect.h"
|
||||
|
||||
class GrFragmentStage;
|
||||
class GrGLConfigConversionEffect;
|
||||
class GrInvariantOutput;
|
||||
|
||||
/**
|
||||
@ -38,10 +37,11 @@ public:
|
||||
static const GrFragmentProcessor* Create(GrTexture*, bool swapRedAndBlue, PMConversion,
|
||||
const SkMatrix&);
|
||||
|
||||
static const char* Name() { return "Config Conversion"; }
|
||||
typedef GrGLConfigConversionEffect GLProcessor;
|
||||
virtual const char* name() const SK_OVERRIDE { return "Config Conversion"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
bool swapsRedAndBlue() const { return fSwapRedAndBlue; }
|
||||
PMConversion pmConversion() const { return fPMConversion; }
|
||||
|
@ -5,36 +5,34 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrConvexPolyEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkPath.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
#include "SkPath.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
class GLAARectEffect;
|
||||
|
||||
class AARectEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
typedef GLAARectEffect GLProcessor;
|
||||
|
||||
const SkRect& getRect() const { return fRect; }
|
||||
|
||||
static const char* Name() { return "AARect"; }
|
||||
|
||||
static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
|
||||
return SkNEW_ARGS(AARectEffect, (edgeType, rect));
|
||||
}
|
||||
|
||||
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const SK_OVERRIDE { return "AARect"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect), fEdgeType(edgeType) {
|
||||
AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect)
|
||||
: fRect(rect), fEdgeType(edgeType) {
|
||||
this->initClassID<AARectEffect>();
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
|
||||
@ -85,7 +83,7 @@ GrFragmentProcessor* AARectEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLAARectEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLAARectEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLAARectEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -104,9 +102,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLAARectEffect::GLAARectEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& effect)
|
||||
: INHERITED (factory) {
|
||||
GLAARectEffect::GLAARectEffect(const GrProcessor& effect) {
|
||||
fPrevRect.fLeft = SK_ScalarNaN;
|
||||
}
|
||||
|
||||
@ -169,15 +165,19 @@ void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
|
||||
b->add32(aare.getEdgeType());
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& AARectEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<AARectEffect>::getInstance();
|
||||
void AARectEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
|
||||
GLAARectEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* AARectEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLAARectEffect, (*this));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GrGLConvexPolyEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLConvexPolyEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLConvexPolyEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -196,9 +196,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED (factory) {
|
||||
GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrProcessor&) {
|
||||
fPrevEdges[0] = SK_ScalarNaN;
|
||||
}
|
||||
|
||||
@ -326,13 +324,19 @@ void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance();
|
||||
void GrConvexPolyEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLConvexPolyEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrConvexPolyEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLConvexPolyEffect, (*this));
|
||||
}
|
||||
|
||||
GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, const SkScalar edges[])
|
||||
: fEdgeType(edgeType)
|
||||
, fEdgeCount(n) {
|
||||
this->initClassID<GrConvexPolyEffect>();
|
||||
// Factory function should have already ensured this.
|
||||
SkASSERT(n <= kMaxEdges);
|
||||
memcpy(fEdges, edges, 3 * n * sizeof(SkScalar));
|
||||
|
@ -9,10 +9,10 @@
|
||||
#define GrConvexPolyEffect_DEFINED
|
||||
|
||||
#include "GrDrawTargetCaps.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrTypesPriv.h"
|
||||
|
||||
class GrGLConvexPolyEffect;
|
||||
class GrInvariantOutput;
|
||||
class SkPath;
|
||||
|
||||
@ -61,7 +61,7 @@ public:
|
||||
|
||||
virtual ~GrConvexPolyEffect();
|
||||
|
||||
static const char* Name() { return "ConvexPoly"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "ConvexPoly"; }
|
||||
|
||||
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
@ -69,9 +69,9 @@ public:
|
||||
|
||||
const SkScalar* getEdges() const { return fEdges; }
|
||||
|
||||
typedef GrGLConvexPolyEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, const SkScalar edges[]);
|
||||
|
@ -5,19 +5,18 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrConvolutionEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLTexture.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
// For brevity
|
||||
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
class GrGLConvolutionEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLConvolutionEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLConvolutionEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -45,9 +44,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED(factory) {
|
||||
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProcessor& processor) {
|
||||
const GrConvolutionEffect& c = processor.cast<GrConvolutionEffect>();
|
||||
fRadius = c.radius();
|
||||
fUseBounds = c.useBounds();
|
||||
@ -155,6 +152,7 @@ GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture,
|
||||
bool useBounds,
|
||||
float bounds[2])
|
||||
: Gr1DKernelEffect(texture, direction, radius), fUseBounds(useBounds) {
|
||||
this->initClassID<GrConvolutionEffect>();
|
||||
SkASSERT(radius <= kMaxKernelRadius);
|
||||
SkASSERT(kernel);
|
||||
int width = this->width();
|
||||
@ -171,6 +169,7 @@ GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture,
|
||||
bool useBounds,
|
||||
float bounds[2])
|
||||
: Gr1DKernelEffect(texture, direction, radius), fUseBounds(useBounds) {
|
||||
this->initClassID<GrConvolutionEffect>();
|
||||
SkASSERT(radius <= kMaxKernelRadius);
|
||||
int width = this->width();
|
||||
|
||||
@ -194,8 +193,13 @@ GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture,
|
||||
GrConvolutionEffect::~GrConvolutionEffect() {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrConvolutionEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrConvolutionEffect>::getInstance();
|
||||
void GrConvolutionEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLConvolutionEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrConvolutionEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLConvolutionEffect, (*this));
|
||||
}
|
||||
|
||||
bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "Gr1DKernelEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
|
||||
class GrGLConvolutionEffect;
|
||||
|
||||
/**
|
||||
* A convolution effect. The kernel is specified as an array of 2 * half-width
|
||||
* + 1 weights. Each texel is multiplied by it's weight and summed to determine
|
||||
@ -59,11 +57,11 @@ public:
|
||||
const float* bounds() const { return fBounds; }
|
||||
bool useBounds() const { return fUseBounds; }
|
||||
|
||||
static const char* Name() { return "Convolution"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Convolution"; }
|
||||
|
||||
typedef GrGLConvolutionEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
enum {
|
||||
// This was decided based on the min allowed value for the max texture
|
||||
|
@ -7,20 +7,17 @@
|
||||
|
||||
#include "GrCustomCoordsTextureEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTexture.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLTexture.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrTexture.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {}
|
||||
GrGLCustomCoordsTextureEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
const GrCustomCoordsTextureEffect& cte =
|
||||
@ -74,6 +71,7 @@ GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
|
||||
const GrTextureParams& params,
|
||||
bool hasColor)
|
||||
: fTextureAccess(texture, params), fInColor(NULL) {
|
||||
this->initClassID<GrCustomCoordsTextureEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
if (hasColor) {
|
||||
fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVertexAttribType));
|
||||
@ -99,10 +97,16 @@ void GrCustomCoordsTextureEffect::onComputeInvariantOutput(GrInvariantOutput* in
|
||||
}
|
||||
}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& GrCustomCoordsTextureEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<GrCustomCoordsTextureEffect>::getInstance();
|
||||
void GrCustomCoordsTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLCustomCoordsTextureEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor*
|
||||
GrCustomCoordsTextureEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GrGLCustomCoordsTextureEffect, (*this, bt));
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCustomCoordsTextureEffect);
|
||||
|
@ -27,15 +27,17 @@ public:
|
||||
|
||||
virtual ~GrCustomCoordsTextureEffect() {}
|
||||
|
||||
static const char* Name() { return "Texture"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "Texture"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inColor() const { return fInColor; }
|
||||
const GrAttribute* inTextureCoords() const { return fInTextureCoords; }
|
||||
|
||||
typedef GrGLCustomCoordsTextureEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrCustomCoordsTextureEffect(GrTexture* texture, const GrTextureParams& params, bool hasColor);
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrStrokeInfo.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "SkGr.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
@ -463,7 +462,7 @@ public:
|
||||
|
||||
virtual ~DashingCircleEffect();
|
||||
|
||||
static const char* Name() { return "DashingCircleEffect"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
|
||||
@ -477,9 +476,11 @@ public:
|
||||
|
||||
SkScalar getIntervalLength() const { return fIntervalLength; }
|
||||
|
||||
typedef GLDashingCircleEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker&,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar radius);
|
||||
@ -504,9 +505,7 @@ private:
|
||||
|
||||
class GLDashingCircleEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLDashingCircleEffect(const GrBackendProcessorFactory&,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&);
|
||||
|
||||
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
|
||||
|
||||
@ -527,10 +526,8 @@ private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {
|
||||
GLDashingCircleEffect::GLDashingCircleEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {
|
||||
fPrevRadius = SK_ScalarMin;
|
||||
fPrevCenterX = SK_ScalarMin;
|
||||
fPrevIntervalLength = SK_ScalarMax;
|
||||
@ -618,13 +615,20 @@ void DashingCircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& DashingCircleEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<DashingCircleEffect>::getInstance();
|
||||
void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLDashingCircleEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
|
||||
}
|
||||
|
||||
DashingCircleEffect::DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info,
|
||||
SkScalar radius)
|
||||
: fEdgeType(edgeType) {
|
||||
this->initClassID<DashingCircleEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttribType));
|
||||
SkScalar onLen = info.fIntervals[0];
|
||||
@ -685,7 +689,7 @@ public:
|
||||
|
||||
virtual ~DashingLineEffect();
|
||||
|
||||
static const char* Name() { return "DashingEffect"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
|
||||
@ -697,9 +701,11 @@ public:
|
||||
|
||||
SkScalar getIntervalLength() const { return fIntervalLength; }
|
||||
|
||||
typedef GLDashingLineEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar strokeWidth);
|
||||
@ -723,9 +729,7 @@ private:
|
||||
|
||||
class GLDashingLineEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLDashingLineEffect(const GrBackendProcessorFactory&,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&);
|
||||
|
||||
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
|
||||
|
||||
@ -746,10 +750,8 @@ private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLDashingLineEffect::GLDashingLineEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory) {
|
||||
GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&) {
|
||||
fPrevRect.fLeft = SK_ScalarNaN;
|
||||
fPrevIntervalLength = SK_ScalarMax;
|
||||
}
|
||||
@ -851,13 +853,20 @@ void DashingLineEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& DashingLineEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<DashingLineEffect>::getInstance();
|
||||
void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLDashingLineEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
|
||||
}
|
||||
|
||||
DashingLineEffect::DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info,
|
||||
SkScalar strokeWidth)
|
||||
: fEdgeType(edgeType) {
|
||||
this->initClassID<DashingLineEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttribType));
|
||||
SkScalar onLen = info.fIntervals[0];
|
||||
|
@ -7,26 +7,22 @@
|
||||
|
||||
#include "GrDistanceFieldTextureEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTexture.h"
|
||||
#include "SkDistanceFieldGen.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLTexture.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrTexture.h"
|
||||
|
||||
#include "SkDistanceFieldGen.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
// Assuming a radius of the diagonal of the fragment, hence a factor of sqrt(2)/2
|
||||
#define SK_DistanceFieldAAFactor "0.7071"
|
||||
|
||||
class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldTextureEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
GrGLDistanceFieldTextureEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory)
|
||||
, fTextureSize(SkISize::Make(-1,-1))
|
||||
: fTextureSize(SkISize::Make(-1,-1))
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
, fLuminance(-1.0f)
|
||||
#endif
|
||||
@ -185,6 +181,7 @@ GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture,
|
||||
, fFlags(flags & kNonLCD_DistanceFieldEffectMask)
|
||||
, fInColor(NULL) {
|
||||
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
|
||||
this->initClassID<GrDistanceFieldTextureEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
if (flags & kColorAttr_DistanceFieldEffectFlag) {
|
||||
fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVertexAttribType));
|
||||
@ -211,8 +208,15 @@ void GrDistanceFieldTextureEffect::onComputeInvariantOutput(GrInvariantOutput* i
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::getInstance();
|
||||
void GrDistanceFieldTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLDistanceFieldTextureEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor*
|
||||
GrDistanceFieldTextureEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GrGLDistanceFieldTextureEffect, (*this, bt));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -258,11 +262,9 @@ GrGeometryProcessor* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldNoGammaTextureEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
GrGLDistanceFieldNoGammaTextureEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED(factory)
|
||||
, fTextureSize(SkISize::Make(-1, -1)) {}
|
||||
: fTextureSize(SkISize::Make(-1, -1)) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
const GrDistanceFieldNoGammaTextureEffect& dfTexEffect =
|
||||
@ -383,6 +385,7 @@ GrDistanceFieldNoGammaTextureEffect::GrDistanceFieldNoGammaTextureEffect(GrTextu
|
||||
, fFlags(flags & kNonLCD_DistanceFieldEffectMask)
|
||||
, fInColor(NULL) {
|
||||
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
|
||||
this->initClassID<GrDistanceFieldNoGammaTextureEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
if (flags & kColorAttr_DistanceFieldEffectFlag) {
|
||||
fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVertexAttribType));
|
||||
@ -403,8 +406,15 @@ void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(GrInvariantOu
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& GrDistanceFieldNoGammaTextureEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<GrDistanceFieldNoGammaTextureEffect>::getInstance();
|
||||
void GrDistanceFieldNoGammaTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLDistanceFieldNoGammaTextureEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor*
|
||||
GrDistanceFieldNoGammaTextureEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GrGLDistanceFieldNoGammaTextureEffect, (*this, bt));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -437,11 +447,9 @@ GrGeometryProcessor* GrDistanceFieldNoGammaTextureEffect::TestCreate(SkRandom* r
|
||||
|
||||
class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldLCDTextureEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrGeometryProcessor&,
|
||||
GrGLDistanceFieldLCDTextureEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&)
|
||||
: INHERITED (factory)
|
||||
, fTextureSize(SkISize::Make(-1,-1))
|
||||
: fTextureSize(SkISize::Make(-1,-1))
|
||||
, fTextColor(GrColor_ILLEGAL) {}
|
||||
|
||||
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
|
||||
@ -635,6 +643,7 @@ GrDistanceFieldLCDTextureEffect::GrDistanceFieldLCDTextureEffect(
|
||||
, fTextColor(textColor)
|
||||
, fFlags(flags & kLCD_DistanceFieldEffectMask){
|
||||
SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag));
|
||||
this->initClassID<GrDistanceFieldLCDTextureEffect>();
|
||||
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords",
|
||||
kVec2f_GrVertexAttribType));
|
||||
@ -652,8 +661,15 @@ void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(GrInvariantOutput
|
||||
inout->mulByUnknownColor();
|
||||
}
|
||||
|
||||
const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFactory() const {
|
||||
return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::getInstance();
|
||||
void GrDistanceFieldLCDTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLDistanceFieldLCDTextureEffect::GenKey(*this, bt, caps, b);
|
||||
}
|
||||
|
||||
GrGLGeometryProcessor*
|
||||
GrDistanceFieldLCDTextureEffect::createGLInstance(const GrBatchTracker& bt) const {
|
||||
return SkNEW_ARGS(GrGLDistanceFieldLCDTextureEffect, (*this, bt));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
|
||||
virtual ~GrDistanceFieldTextureEffect() {}
|
||||
|
||||
static const char* Name() { return "DistanceFieldTexture"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DistanceFieldTexture"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inColor() const { return fInColor; }
|
||||
@ -72,9 +72,11 @@ public:
|
||||
#endif
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
|
||||
typedef GrGLDistanceFieldTextureEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& params,
|
||||
@ -118,16 +120,18 @@ public:
|
||||
|
||||
virtual ~GrDistanceFieldNoGammaTextureEffect() {}
|
||||
|
||||
static const char* Name() { return "DistanceFieldTexture"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DistanceFieldTexture"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inColor() const { return fInColor; }
|
||||
const GrAttribute* inTextureCoords() const { return fInTextureCoords; }
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
|
||||
typedef GrGLDistanceFieldNoGammaTextureEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrDistanceFieldNoGammaTextureEffect(GrTexture* texture, const GrTextureParams& params,
|
||||
@ -165,16 +169,18 @@ public:
|
||||
|
||||
virtual ~GrDistanceFieldLCDTextureEffect() {}
|
||||
|
||||
static const char* Name() { return "DistanceFieldLCDTexture"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "DistanceFieldLCDTexture"; }
|
||||
|
||||
const GrAttribute* inPosition() const { return fInPosition; }
|
||||
const GrAttribute* inTextureCoords() const { return fInTextureCoords; }
|
||||
GrColor getTextColor() const { return fTextColor; }
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
|
||||
typedef GrGLDistanceFieldLCDTextureEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& params,
|
||||
|
@ -5,19 +5,16 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrDitherEffect.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkRect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
#include "SkRect.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLDitherEffect;
|
||||
|
||||
class DitherEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create() {
|
||||
@ -26,16 +23,16 @@ public:
|
||||
}
|
||||
|
||||
virtual ~DitherEffect() {};
|
||||
static const char* Name() { return "Dither"; }
|
||||
|
||||
typedef GLDitherEffect GLProcessor;
|
||||
virtual const char* name() const SK_OVERRIDE { return "Dither"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<DitherEffect>::getInstance();
|
||||
}
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
DitherEffect() {
|
||||
this->initClassID<DitherEffect>();
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
|
||||
@ -68,7 +65,7 @@ GrFragmentProcessor* DitherEffect::TestCreate(SkRandom*,
|
||||
|
||||
class GLDitherEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLDitherEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLDitherEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -81,9 +78,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLDitherEffect::GLDitherEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED (factory) {
|
||||
GLDitherEffect::GLDitherEffect(const GrProcessor&) {
|
||||
}
|
||||
|
||||
void GLDitherEffect::emitCode(GrGLFPBuilder* builder,
|
||||
@ -111,4 +106,13 @@ void GLDitherEffect::emitCode(GrGLFPBuilder* builder,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DitherEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLDitherEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* DitherEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLDitherEffect, (*this));
|
||||
}
|
||||
|
||||
GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); }
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "GrTypes.h"
|
||||
#include "GrTypesPriv.h"
|
||||
|
||||
class GrProcessor;
|
||||
class GrFragmentProcessor;
|
||||
|
||||
namespace GrDitherEffect {
|
||||
/**
|
||||
|
@ -4,17 +4,15 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrMatrixConvolutionEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLTexture.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&);
|
||||
GrGLMatrixConvolutionEffect(const GrProcessor&);
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
const char* outputColor,
|
||||
@ -42,9 +40,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& processor)
|
||||
: INHERITED(factory) {
|
||||
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrProcessor& processor) {
|
||||
const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffect>();
|
||||
fKernelSize = m.kernelSize();
|
||||
fConvolveAlpha = m.convolveAlpha();
|
||||
@ -160,6 +156,7 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
|
||||
fBias(SkScalarToFloat(bias) / 255.0f),
|
||||
fConvolveAlpha(convolveAlpha),
|
||||
fDomain(GrTextureDomain::MakeTexelDomain(texture, bounds), tileMode) {
|
||||
this->initClassID<GrMatrixConvolutionEffect>();
|
||||
for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) {
|
||||
fKernel[i] = SkScalarToFloat(kernel[i]);
|
||||
}
|
||||
@ -170,8 +167,13 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
|
||||
GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrMatrixConvolutionEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrMatrixConvolutionEffect>::getInstance();
|
||||
void GrMatrixConvolutionEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLMatrixConvolutionEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrMatrixConvolutionEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLMatrixConvolutionEffect, (*this));
|
||||
}
|
||||
|
||||
bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
|
@ -16,8 +16,6 @@
|
||||
// Allows for a 5x5 kernel (or 25x1, for that matter).
|
||||
#define MAX_KERNEL_SIZE 25
|
||||
|
||||
class GrGLMatrixConvolutionEffect;
|
||||
|
||||
class GrMatrixConvolutionEffect : public GrSingleTextureEffect {
|
||||
public:
|
||||
static GrFragmentProcessor* Create(GrTexture* texture,
|
||||
@ -53,7 +51,6 @@ public:
|
||||
|
||||
virtual ~GrMatrixConvolutionEffect();
|
||||
|
||||
static const char* Name() { return "MatrixConvolution"; }
|
||||
const SkIRect& bounds() const { return fBounds; }
|
||||
const SkISize& kernelSize() const { return fKernelSize; }
|
||||
const float* kernelOffset() const { return fKernelOffset; }
|
||||
@ -63,9 +60,11 @@ public:
|
||||
bool convolveAlpha() const { return fConvolveAlpha; }
|
||||
const GrTextureDomain& domain() const { return fDomain; }
|
||||
|
||||
typedef GrGLMatrixConvolutionEffect GLProcessor;
|
||||
virtual const char* name() const SK_OVERRIDE { return "MatrixConvolution"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrMatrixConvolutionEffect(GrTexture*,
|
||||
|
@ -5,35 +5,34 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrOvalEffect.h"
|
||||
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkRect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
#include "SkRect.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLCircleEffect;
|
||||
|
||||
class CircleEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius);
|
||||
|
||||
virtual ~CircleEffect() {};
|
||||
static const char* Name() { return "Circle"; }
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "Circle"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
const SkPoint& getCenter() const { return fCenter; }
|
||||
SkScalar getRadius() const { return fRadius; }
|
||||
|
||||
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
typedef GLCircleEffect GLProcessor;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius);
|
||||
|
||||
@ -60,14 +59,11 @@ void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& CircleEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<CircleEffect>::getInstance();
|
||||
}
|
||||
|
||||
CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r)
|
||||
: fCenter(c)
|
||||
, fRadius(r)
|
||||
, fEdgeType(edgeType) {
|
||||
this->initClassID<CircleEffect>();
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
|
||||
@ -99,7 +95,7 @@ GrFragmentProcessor* CircleEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLCircleEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLCircleEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -120,9 +116,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLCircleEffect::GLCircleEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED (factory) {
|
||||
GLCircleEffect::GLCircleEffect(const GrProcessor&) {
|
||||
fPrevRadius = -1.f;
|
||||
}
|
||||
|
||||
@ -183,9 +177,18 @@ void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrProces
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLEllipseEffect;
|
||||
void CircleEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLCircleEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* CircleEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLCircleEffect, (*this));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EllipseEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
@ -193,17 +196,18 @@ public:
|
||||
SkScalar ry);
|
||||
|
||||
virtual ~EllipseEffect() {};
|
||||
static const char* Name() { return "Ellipse"; }
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "Ellipse"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
const SkPoint& getCenter() const { return fCenter; }
|
||||
SkVector getRadii() const { return fRadii; }
|
||||
|
||||
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
typedef GLEllipseEffect GLProcessor;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry);
|
||||
|
||||
@ -232,14 +236,11 @@ void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& EllipseEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<EllipseEffect>::getInstance();
|
||||
}
|
||||
|
||||
EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry)
|
||||
: fCenter(c)
|
||||
, fRadii(SkVector::Make(rx, ry))
|
||||
, fEdgeType(edgeType) {
|
||||
this->initClassID<EllipseEffect>();
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
|
||||
@ -272,7 +273,7 @@ GrFragmentProcessor* EllipseEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLEllipseEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLEllipseEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLEllipseEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -293,9 +294,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLEllipseEffect::GLEllipseEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& effect)
|
||||
: INHERITED (factory) {
|
||||
GLEllipseEffect::GLEllipseEffect(const GrProcessor& effect) {
|
||||
fPrevRadii.fX = -1.f;
|
||||
}
|
||||
|
||||
@ -365,6 +364,17 @@ void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrProce
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EllipseEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLEllipseEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* EllipseEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLEllipseEffect, (*this));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrFragmentProcessor* GrOvalEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "GrTypes.h"
|
||||
#include "GrTypesPriv.h"
|
||||
|
||||
class GrProcessor;
|
||||
class GrFragmentProcessor;
|
||||
struct SkRect;
|
||||
|
||||
namespace GrOvalEffect {
|
||||
|
@ -7,11 +7,9 @@
|
||||
|
||||
#include "GrPorterDuffXferProcessor.h"
|
||||
|
||||
#include "GrBackendProcessorFactory.h"
|
||||
#include "GrDrawState.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrTypes.h"
|
||||
#include "GrXferProcessor.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
@ -20,8 +18,7 @@
|
||||
|
||||
class GrGLPorterDuffXferProcessor : public GrGLXferProcessor {
|
||||
public:
|
||||
GrGLPorterDuffXferProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED(factory) {}
|
||||
GrGLPorterDuffXferProcessor(const GrProcessor&) {}
|
||||
|
||||
virtual ~GrGLPorterDuffXferProcessor() {}
|
||||
|
||||
@ -46,13 +43,20 @@ private:
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend)
|
||||
: fSrcBlend(srcBlend), fDstBlend(dstBlend) {}
|
||||
: fSrcBlend(srcBlend), fDstBlend(dstBlend) {
|
||||
this->initClassID<GrPorterDuffXferProcessor>();
|
||||
}
|
||||
|
||||
GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() {
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrPorterDuffXferProcessor::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrPorterDuffXferProcessor>::getInstance();
|
||||
void GrPorterDuffXferProcessor::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLPorterDuffXferProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrPorterDuffXferProcessor::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLPorterDuffXferProcessor, (*this));
|
||||
}
|
||||
|
||||
void GrPorterDuffXferProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||
|
@ -12,9 +12,7 @@
|
||||
#include "GrXferProcessor.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
class GrBackendFragmentProcessorFactory;
|
||||
class GrDrawState;
|
||||
class GrGLPorterDuffXferProcessor;
|
||||
class GrInvariantOutput;
|
||||
|
||||
class GrPorterDuffXferProcessor : public GrXferProcessor {
|
||||
@ -25,10 +23,12 @@ public:
|
||||
|
||||
virtual ~GrPorterDuffXferProcessor();
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual const char* name() const { return "Porter Duff"; }
|
||||
|
||||
typedef GrGLPorterDuffXferProcessor GLProcessor;
|
||||
static const char* Name() { return "Porter Duff"; }
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend);
|
||||
|
@ -5,25 +5,22 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrRRectEffect.h"
|
||||
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "GrConvexPolyEffect.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrOvalEffect.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
|
||||
#include "SkRRect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
// The effects defined here only handle rrect radii >= kRadiusMin.
|
||||
static const SkScalar kRadiusMin = SK_ScalarHalf;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLCircularRRectEffect;
|
||||
|
||||
class CircularRRectEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
|
||||
@ -50,7 +47,12 @@ public:
|
||||
const SkRRect&);
|
||||
|
||||
virtual ~CircularRRectEffect() {};
|
||||
static const char* Name() { return "CircularRRect"; }
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "CircularRRect"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
const SkRRect& getRRect() const { return fRRect; }
|
||||
|
||||
@ -58,10 +60,6 @@ public:
|
||||
|
||||
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
typedef GLCircularRRectEffect GLProcessor;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
CircularRRectEffect(GrPrimitiveEdgeType, uint32_t circularCornerFlags, const SkRRect&);
|
||||
|
||||
@ -91,15 +89,12 @@ void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& CircularRRectEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<CircularRRectEffect>::getInstance();
|
||||
}
|
||||
|
||||
CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t circularCornerFlags,
|
||||
const SkRRect& rrect)
|
||||
: fRRect(rrect)
|
||||
, fEdgeType(edgeType)
|
||||
, fCircularCornerFlags(circularCornerFlags) {
|
||||
this->initClassID<CircularRRectEffect>();
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
|
||||
@ -135,7 +130,7 @@ GrFragmentProcessor* CircularRRectEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLCircularRRectEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLCircularRRectEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLCircularRRectEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -155,9 +150,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLCircularRRectEffect::GLCircularRRectEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& )
|
||||
: INHERITED (factory) {
|
||||
GLCircularRRectEffect::GLCircularRRectEffect(const GrProcessor& ) {
|
||||
fPrevRRect.setEmpty();
|
||||
}
|
||||
|
||||
@ -380,26 +373,35 @@ void GLCircularRRectEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLEllipticalRRectEffect;
|
||||
void CircularRRectEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLCircularRRectEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* CircularRRectEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLCircularRRectEffect, (*this));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EllipticalRRectEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
|
||||
|
||||
virtual ~EllipticalRRectEffect() {};
|
||||
static const char* Name() { return "EllipticalRRect"; }
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "EllipticalRRect"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
const SkRRect& getRRect() const { return fRRect; }
|
||||
|
||||
|
||||
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
|
||||
typedef GLEllipticalRRectEffect GLProcessor;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&);
|
||||
|
||||
@ -427,13 +429,10 @@ void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
|
||||
inout->mulByUnknownAlpha();
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& EllipticalRRectEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<EllipticalRRectEffect>::getInstance();
|
||||
}
|
||||
|
||||
EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const SkRRect& rrect)
|
||||
: fRRect(rrect)
|
||||
, fEdgeType(edgeType){
|
||||
, fEdgeType(edgeType) {
|
||||
this->initClassID<EllipticalRRectEffect>();
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
|
||||
@ -488,7 +487,7 @@ GrFragmentProcessor* EllipticalRRectEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLEllipticalRRectEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLEllipticalRRectEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GLEllipticalRRectEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& effect,
|
||||
@ -508,9 +507,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor& effect)
|
||||
: INHERITED (factory) {
|
||||
GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrProcessor& effect) {
|
||||
fPrevRRect.setEmpty();
|
||||
}
|
||||
|
||||
@ -634,6 +631,17 @@ void GLEllipticalRRectEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EllipticalRRectEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GLEllipticalRRectEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* EllipticalRRectEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GLEllipticalRRectEffect, (*this));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrFragmentProcessor* GrRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "GrTypes.h"
|
||||
#include "GrTypesPriv.h"
|
||||
|
||||
class GrFragmentProcessor;
|
||||
class GrProcessor;
|
||||
class SkRRect;
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrTexture.h"
|
||||
#include "gl/GrGLCaps.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLSL.h"
|
||||
#include "gl/GrGLTexture.h"
|
||||
@ -16,9 +16,7 @@
|
||||
|
||||
class GrGLSimpleTextureEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLSimpleTextureEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED (factory) {
|
||||
}
|
||||
GrGLSimpleTextureEffect(const GrProcessor&) {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -45,8 +43,13 @@ void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
|
||||
this->updateInvariantOutputForModulation(inout);
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrSimpleTextureEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrSimpleTextureEffect>::getInstance();
|
||||
void GrSimpleTextureEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLSimpleTextureEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrSimpleTextureEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLSimpleTextureEffect, (*this));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "GrSingleTextureEffect.h"
|
||||
|
||||
class GrGLSimpleTextureEffect;
|
||||
class GrInvariantOutput;
|
||||
|
||||
/**
|
||||
@ -48,11 +47,11 @@ public:
|
||||
|
||||
virtual ~GrSimpleTextureEffect() {}
|
||||
|
||||
static const char* Name() { return "Texture"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "SimpleTexture"; }
|
||||
|
||||
typedef GrGLSimpleTextureEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrSimpleTextureEffect(GrTexture* texture,
|
||||
@ -60,6 +59,7 @@ private:
|
||||
GrTextureParams::FilterMode filterMode,
|
||||
GrCoordSet coordSet)
|
||||
: GrSingleTextureEffect(texture, matrix, filterMode, coordSet) {
|
||||
this->initClassID<GrSimpleTextureEffect>();
|
||||
}
|
||||
|
||||
GrSimpleTextureEffect(GrTexture* texture,
|
||||
@ -67,6 +67,7 @@ private:
|
||||
const GrTextureParams& params,
|
||||
GrCoordSet coordSet)
|
||||
: GrSingleTextureEffect(texture, matrix, params, coordSet) {
|
||||
this->initClassID<GrSimpleTextureEffect>();
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE { return true; }
|
||||
|
@ -5,14 +5,12 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrTextureDomain.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "SkFloatingPoint.h"
|
||||
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
|
||||
: fIndex(index) {
|
||||
@ -168,7 +166,7 @@ void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
|
||||
|
||||
class GrGLTextureDomainEffect : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLTextureDomainEffect(const GrBackendProcessorFactory&, const GrProcessor&);
|
||||
GrGLTextureDomainEffect(const GrProcessor&);
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder*,
|
||||
const GrFragmentProcessor&,
|
||||
@ -186,9 +184,7 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProcessor&) {
|
||||
}
|
||||
|
||||
void GrGLTextureDomainEffect::emitCode(GrGLFPBuilder* builder,
|
||||
@ -252,14 +248,20 @@ GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture,
|
||||
, fTextureDomain(domain, mode) {
|
||||
SkASSERT(mode != GrTextureDomain::kRepeat_Mode ||
|
||||
filterMode == GrTextureParams::kNone_FilterMode);
|
||||
this->initClassID<GrTextureDomainEffect>();
|
||||
}
|
||||
|
||||
GrTextureDomainEffect::~GrTextureDomainEffect() {
|
||||
|
||||
}
|
||||
|
||||
const GrBackendFragmentProcessorFactory& GrTextureDomainEffect::getFactory() const {
|
||||
return GrTBackendFragmentProcessorFactory<GrTextureDomainEffect>::getInstance();
|
||||
void GrTextureDomainEffect::getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrGLTextureDomainEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLFragmentProcessor* GrTextureDomainEffect::createGLInstance() const {
|
||||
return SkNEW_ARGS(GrGLTextureDomainEffect, (*this));
|
||||
}
|
||||
|
||||
bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
|
||||
|
@ -138,8 +138,6 @@ protected:
|
||||
typedef GrSingleTextureEffect INHERITED;
|
||||
};
|
||||
|
||||
class GrGLTextureDomainEffect;
|
||||
|
||||
/**
|
||||
* A basic texture effect that uses GrTextureDomain.
|
||||
*/
|
||||
@ -155,11 +153,11 @@ public:
|
||||
|
||||
virtual ~GrTextureDomainEffect();
|
||||
|
||||
static const char* Name() { return "TextureDomain"; }
|
||||
virtual const char* name() const SK_OVERRIDE { return "TextureDomain"; }
|
||||
|
||||
typedef GrGLTextureDomainEffect GLProcessor;
|
||||
virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
|
||||
|
||||
const GrTextureDomain& textureDomain() const { return fTextureDomain; }
|
||||
|
||||
|
@ -5,14 +5,13 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrYUVtoRGBEffect.h"
|
||||
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -23,11 +22,7 @@ public:
|
||||
return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, colorSpace));
|
||||
}
|
||||
|
||||
static const char* Name() { return "YUV to RGB"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<YUVtoRGBEffect>::getInstance();
|
||||
}
|
||||
virtual const char* name() const SK_OVERRIDE { return "YUV to RGB"; }
|
||||
|
||||
SkYUVColorSpace getColorSpace() const {
|
||||
return fColorSpace;
|
||||
@ -41,10 +36,7 @@ public:
|
||||
// this class always generates the same code.
|
||||
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
|
||||
|
||||
GLProcessor(const GrBackendProcessorFactory& factory,
|
||||
const GrProcessor&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
GLProcessor(const GrProcessor&) {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor&,
|
||||
@ -86,6 +78,15 @@ public:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProcessor, (*this));
|
||||
}
|
||||
|
||||
private:
|
||||
YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
|
||||
SkYUVColorSpace colorSpace)
|
||||
@ -95,6 +96,7 @@ private:
|
||||
, fUAccess(uTexture)
|
||||
, fVAccess(vTexture)
|
||||
, fColorSpace(colorSpace) {
|
||||
this->initClassID<YUVtoRGBEffect>();
|
||||
this->addCoordTransform(&fCoordTransform);
|
||||
this->addTextureAccess(&fYAccess);
|
||||
this->addTextureAccess(&fUAccess);
|
||||
|
@ -18,11 +18,12 @@ class GrGLGPBuilder;
|
||||
* from this class. Since paths don't have vertices, this class is only meant to be used internally
|
||||
* by skia, for special cases.
|
||||
*/
|
||||
class GrGLGeometryProcessor : public GrGLProcessor {
|
||||
class GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLGeometryProcessor(const GrBackendProcessorFactory& factory)
|
||||
: INHERITED(factory) {}
|
||||
GrGLGeometryProcessor() {}
|
||||
virtual ~GrGLGeometryProcessor() {}
|
||||
|
||||
typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
|
||||
struct EmitArgs {
|
||||
EmitArgs(GrGLGPBuilder* pb,
|
||||
const GrGeometryProcessor& gp,
|
||||
|
@ -8,8 +8,8 @@
|
||||
#ifndef GrGLProcessor_DEFINED
|
||||
#define GrGLProcessor_DEFINED
|
||||
|
||||
#include "GrBackendProcessorFactory.h"
|
||||
#include "GrGLProgramDataManager.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrTextureAccess.h"
|
||||
|
||||
/** @file
|
||||
@ -26,13 +26,9 @@
|
||||
|
||||
These objects are created by the factory object returned by the GrProcessor::getFactory().
|
||||
*/
|
||||
|
||||
// TODO delete this and make TextureSampler its own thing
|
||||
class GrGLProcessor {
|
||||
public:
|
||||
GrGLProcessor(const GrBackendProcessorFactory& factory)
|
||||
: fFactory(factory) {
|
||||
}
|
||||
|
||||
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
/**
|
||||
@ -67,27 +63,20 @@ public:
|
||||
};
|
||||
|
||||
typedef SkTArray<TextureSampler> TextureSamplerArray;
|
||||
|
||||
virtual ~GrGLProcessor() {}
|
||||
|
||||
const char* name() const { return fFactory.name(); }
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
|
||||
|
||||
protected:
|
||||
const GrBackendProcessorFactory& fFactory;
|
||||
};
|
||||
|
||||
class GrGLFPBuilder;
|
||||
|
||||
class GrGLFragmentProcessor : public GrGLProcessor {
|
||||
class GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLFragmentProcessor(const GrBackendProcessorFactory& factory)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
GrGLFragmentProcessor() {}
|
||||
|
||||
virtual ~GrGLFragmentProcessor() {}
|
||||
|
||||
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
|
||||
typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
|
||||
|
||||
/** Called when the program stage should insert its code into the shaders. The code in each
|
||||
shader will be in its own block ({}) and so locally scoped names will not collide across
|
||||
stages.
|
||||
@ -122,15 +111,15 @@ public:
|
||||
// TODO update this to pass in GrFragmentProcessor
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {}
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
|
||||
|
||||
private:
|
||||
typedef GrGLProcessor INHERITED;
|
||||
};
|
||||
|
||||
class GrGLXferProcessor : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GrGLXferProcessor(const GrBackendProcessorFactory& factory)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
GrGLXferProcessor() {}
|
||||
|
||||
virtual ~GrGLXferProcessor() {}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "GrGLProgramDesc.h"
|
||||
|
||||
#include "GrGLProcessor.h"
|
||||
#include "GrBackendProcessorFactory.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "GrGpuGL.h"
|
||||
#include "GrOptDrawState.h"
|
||||
@ -125,7 +124,7 @@ static bool get_meta_key(const GrProcessor& proc,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
size_t processorKeySize = b->size();
|
||||
uint32_t textureKey = gen_texture_key(proc, caps);
|
||||
uint32_t classID = proc.getFactory().classID();
|
||||
uint32_t classID = proc.classID();
|
||||
|
||||
// Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
|
||||
// don't fit.
|
||||
@ -167,8 +166,7 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
|
||||
if (optState.hasGeometryProcessor()) {
|
||||
const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
|
||||
GrProcessorKeyBuilder b(&desc->fKey);
|
||||
const GrBackendGeometryProcessorFactory& factory = gp.getFactory();
|
||||
factory.getGLProcessorKey(gp, optState.getBatchTracker(), gpu->glCaps(), &b);
|
||||
gp.getGLProcessorKey(optState.getBatchTracker(), gpu->glCaps(), &b);
|
||||
if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) {
|
||||
desc->fKey.reset();
|
||||
return false;
|
||||
@ -179,8 +177,7 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
|
||||
const GrPendingFragmentStage& fps = optState.getFragmentStage(s);
|
||||
const GrFragmentProcessor& fp = *fps.getProcessor();
|
||||
GrProcessorKeyBuilder b(&desc->fKey);
|
||||
const GrBackendFragmentProcessorFactory& factory = fp.getFactory();
|
||||
factory.getGLProcessorKey(fp, gpu->glCaps(), &b);
|
||||
fp.getGLProcessorKey(gpu->glCaps(), &b);
|
||||
if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(),
|
||||
gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b)) {
|
||||
desc->fKey.reset();
|
||||
|
@ -336,7 +336,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
|
||||
GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc);
|
||||
|
||||
const GrFragmentProcessor& fp = *fs.getProcessor();
|
||||
ifp->fGLProc.reset(fp.getFactory().createGLInstance(fp));
|
||||
ifp->fGLProc.reset(fp.createGLInstance());
|
||||
|
||||
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
|
||||
this->emitSamplers(fp, &samplers, ifp);
|
||||
@ -360,7 +360,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp,
|
||||
fGeometryProcessor = SkNEW(GrGLInstalledGeoProc);
|
||||
|
||||
const GrBatchTracker& bt = fOptState.getBatchTracker();
|
||||
fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp, bt));
|
||||
fGeometryProcessor->fGLProc.reset(gp.createGLInstance(bt));
|
||||
|
||||
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures());
|
||||
this->emitSamplers(gp, &samplers, fGeometryProcessor);
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GrContextFactory.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrOptDrawState.h"
|
||||
#include "GrTBackendProcessorFactory.h"
|
||||
#include "GrTest.h"
|
||||
#include "SkChecksum.h"
|
||||
#include "SkRandom.h"
|
||||
@ -31,46 +30,9 @@
|
||||
*/
|
||||
static const uint32_t kMaxKeySize = 1024;
|
||||
|
||||
class GLBigKeyProcessor;
|
||||
|
||||
class BigKeyProcessor : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create() {
|
||||
GR_CREATE_STATIC_PROCESSOR(gBigKeyProcessor, BigKeyProcessor, ())
|
||||
return SkRef(gBigKeyProcessor);
|
||||
}
|
||||
|
||||
static const char* Name() { return "Big ol' Key"; }
|
||||
|
||||
virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
|
||||
return GrTBackendFragmentProcessorFactory<BigKeyProcessor>::getInstance();
|
||||
}
|
||||
|
||||
typedef GLBigKeyProcessor GLProcessor;
|
||||
|
||||
private:
|
||||
BigKeyProcessor() { }
|
||||
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
|
||||
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE { }
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor);
|
||||
|
||||
GrFragmentProcessor* BigKeyProcessor::TestCreate(SkRandom*,
|
||||
GrContext*,
|
||||
const GrDrawTargetCaps&,
|
||||
GrTexture*[]) {
|
||||
return BigKeyProcessor::Create();
|
||||
}
|
||||
|
||||
class GLBigKeyProcessor : public GrGLFragmentProcessor {
|
||||
public:
|
||||
GLBigKeyProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
|
||||
: INHERITED(factory) {}
|
||||
GLBigKeyProcessor(const GrProcessor&) {}
|
||||
|
||||
virtual void emitCode(GrGLFPBuilder* builder,
|
||||
const GrFragmentProcessor& fp,
|
||||
@ -89,6 +51,45 @@ private:
|
||||
typedef GrGLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
class BigKeyProcessor : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create() {
|
||||
GR_CREATE_STATIC_PROCESSOR(gBigKeyProcessor, BigKeyProcessor, ())
|
||||
return SkRef(gBigKeyProcessor);
|
||||
}
|
||||
|
||||
virtual const char* name() const SK_OVERRIDE { return "Big Ole Key"; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLBigKeyProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLBigKeyProcessor, (*this));
|
||||
}
|
||||
|
||||
private:
|
||||
BigKeyProcessor() {
|
||||
this->initClassID<BigKeyProcessor>();
|
||||
}
|
||||
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
|
||||
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE { }
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
||||
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor);
|
||||
|
||||
GrFragmentProcessor* BigKeyProcessor::TestCreate(SkRandom*,
|
||||
GrContext*,
|
||||
const GrDrawTargetCaps&,
|
||||
GrTexture*[]) {
|
||||
return BigKeyProcessor::Create();
|
||||
}
|
||||
|
||||
/*
|
||||
* Begin test code
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user