YUV to RGB Texture threading GrProcessorDataManager

BUG=skia:

Review URL: https://codereview.chromium.org/1230803002
This commit is contained in:
joshualitt 2015-07-09 07:31:31 -07:00 committed by Commit bot
parent 8d3f7bde94
commit 2cdec31c29
6 changed files with 29 additions and 20 deletions

View File

@ -111,8 +111,10 @@ protected:
{1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
for (int i = 0; i < 6; ++i) {
GrPipelineBuilder pipelineBuilder;
SkAutoTUnref<GrFragmentProcessor> fp(
GrYUVtoRGBEffect::Create(texture[indices[i][0]],
GrYUVtoRGBEffect::Create(pipelineBuilder.getProcessorDataManager(),
texture[indices[i][0]],
texture[indices[i][1]],
texture[indices[i][2]],
sizes,
@ -120,7 +122,6 @@ protected:
if (fp) {
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.addColorProcessor(fp);
tt.target()->drawSimpleRect(&pipelineBuilder,

View File

@ -14,6 +14,7 @@
#include "GrGpuResourceRef.h"
#include "GrFragmentStage.h"
#include "GrProcOptInfo.h"
#include "GrProcessorDataManager.h"
#include "GrRenderTarget.h"
#include "GrStencil.h"
#include "GrXferProcessor.h"
@ -391,6 +392,8 @@ public:
void setClip(const GrClip& clip) { fClip = clip; }
const GrClip& clip() const { return fClip; }
GrProcessorDataManager* getProcessorDataManager() { return &fProcDataManager; }
private:
// Calculating invariant color / coverage information is expensive, so we partially cache the
// results.
@ -431,6 +434,7 @@ private:
typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
GrProcessorDataManager fProcDataManager;
SkAutoTUnref<GrRenderTarget> fRenderTarget;
uint32_t fFlags;
GrStencilSettings fStencilSettings;

View File

@ -428,10 +428,11 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrUniqueKey& optionalKe
GrRenderTarget* renderTarget = result->asRenderTarget();
SkASSERT(renderTarget);
SkAutoTUnref<GrFragmentProcessor>
yuvToRgbProcessor(GrYUVtoRGBEffect::Create(yuvTextures[0], yuvTextures[1], yuvTextures[2],
yuvInfo.fSize, yuvInfo.fColorSpace));
GrPaint paint;
SkAutoTUnref<GrFragmentProcessor>
yuvToRgbProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(), yuvTextures[0],
yuvTextures[1], yuvTextures[2],
yuvInfo.fSize, yuvInfo.fColorSpace));
paint.addColorProcessor(yuvToRgbProcessor);
SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth),
SkIntToScalar(yuvInfo.fSize[0].fHeight));

View File

@ -17,9 +17,9 @@ namespace {
class YUVtoRGBEffect : public GrFragmentProcessor {
public:
static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
GrTexture* vTexture, const SkISize sizes[3],
SkYUVColorSpace colorSpace) {
static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, GrTexture* yTexture,
GrTexture* uTexture, GrTexture* vTexture,
const SkISize sizes[3], SkYUVColorSpace colorSpace) {
SkScalar w[3], h[3];
w[0] = SkIntToScalar(sizes[0].fWidth) / SkIntToScalar(yTexture->width());
h[0] = SkIntToScalar(sizes[0].fHeight) / SkIntToScalar(yTexture->height());
@ -40,7 +40,7 @@ public:
(sizes[2].fHeight != sizes[0].fHeight)) ?
GrTextureParams::kBilerp_FilterMode :
GrTextureParams::kNone_FilterMode;
return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatrix,
return SkNEW_ARGS(YUVtoRGBEffect, (procDataManager, yTexture, uTexture, vTexture, yuvMatrix,
uvFilterMode, colorSpace));
}
@ -110,9 +110,9 @@ public:
}
private:
YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
const SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFilterMode,
SkYUVColorSpace colorSpace)
YUVtoRGBEffect(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTexture,
GrTexture* vTexture, const SkMatrix yuvMatrix[3],
GrTextureParams::FilterMode uvFilterMode, SkYUVColorSpace colorSpace)
: fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kNone_FilterMode)
, fYAccess(yTexture)
, fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode)
@ -166,8 +166,9 @@ const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = {
//////////////////////////////////////////////////////////////////////////////
GrFragmentProcessor*
GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
const SkISize sizes[3], SkYUVColorSpace colorSpace) {
SkASSERT(yTexture && uTexture && vTexture && sizes);
return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpace);
GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTexture,
GrTexture* uTexture, GrTexture* vTexture, const SkISize sizes[3],
SkYUVColorSpace colorSpace) {
SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes);
return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture, sizes, colorSpace);
}

View File

@ -11,14 +11,16 @@
#include "SkImageInfo.h"
class GrFragmentProcessor;
class GrProcessorDataManager;
class GrTexture;
namespace GrYUVtoRGBEffect {
/**
* Creates an effect that performs color conversion from YUV to RGB
*/
GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
const SkISize sizes[3], SkYUVColorSpace colorSpace);
GrFragmentProcessor* Create(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTexture,
GrTexture* vTexture, const SkISize sizes[3],
SkYUVColorSpace colorSpace);
};
#endif

View File

@ -230,8 +230,8 @@ SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.addColorProcessor(GrYUVtoRGBEffect::Create(yTex, uTex, vTex, yuvSizes,
colorSpace))->unref();
paint.addColorProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(), yTex, uTex,
vTex, yuvSizes, colorSpace))->unref();
const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
SkIntToScalar(dstDesc.fHeight));