Use TextureProxy size directly in GrYUVToRGBEffect FragmentProcessor
Instead of take extra input to indicate size for texture proxies of different planes, directly use texture proxy's size. Bug: skia:7903 Change-Id: I5d6c859510f7390948c6dcfbdd17343faa786aca Reviewed-on: https://skia-review.googlesource.com/130964 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Weiliang Chen <weiliangc@chromium.org>
This commit is contained in:
parent
c940f5d5ff
commit
3e95e578c2
@ -101,7 +101,6 @@ protected:
|
|||||||
constexpr SkScalar kDrawPad = 10.f;
|
constexpr SkScalar kDrawPad = 10.f;
|
||||||
constexpr SkScalar kTestPad = 10.f;
|
constexpr SkScalar kTestPad = 10.f;
|
||||||
constexpr SkScalar kColorSpaceOffset = 36.f;
|
constexpr SkScalar kColorSpaceOffset = 36.f;
|
||||||
SkISize sizes[3] = {{YSIZE, YSIZE}, {USIZE, USIZE}, {VSIZE, VSIZE}};
|
|
||||||
|
|
||||||
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {
|
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {
|
||||||
SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()),
|
SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()),
|
||||||
@ -119,7 +118,6 @@ protected:
|
|||||||
GrYUVtoRGBEffect::Make(proxy[indices[i][0]],
|
GrYUVtoRGBEffect::Make(proxy[indices[i][0]],
|
||||||
proxy[indices[i][1]],
|
proxy[indices[i][1]],
|
||||||
proxy[indices[i][2]],
|
proxy[indices[i][2]],
|
||||||
sizes,
|
|
||||||
static_cast<SkYUVColorSpace>(space),
|
static_cast<SkYUVColorSpace>(space),
|
||||||
false));
|
false));
|
||||||
if (fp) {
|
if (fp) {
|
||||||
@ -227,7 +225,6 @@ protected:
|
|||||||
constexpr SkScalar kDrawPad = 10.f;
|
constexpr SkScalar kDrawPad = 10.f;
|
||||||
constexpr SkScalar kTestPad = 10.f;
|
constexpr SkScalar kTestPad = 10.f;
|
||||||
constexpr SkScalar kColorSpaceOffset = 36.f;
|
constexpr SkScalar kColorSpaceOffset = 36.f;
|
||||||
SkISize sizes[3] = {{YSIZE, YSIZE}, {USIZE, USIZE}, {VSIZE, VSIZE}};
|
|
||||||
|
|
||||||
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {
|
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {
|
||||||
SkRect renderRect =
|
SkRect renderRect =
|
||||||
@ -239,7 +236,7 @@ protected:
|
|||||||
|
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
|
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
|
||||||
auto fp = GrYUVtoRGBEffect::Make(proxy[0], proxy[1], proxy[2], sizes,
|
auto fp = GrYUVtoRGBEffect::Make(proxy[0], proxy[1], proxy[2],
|
||||||
static_cast<SkYUVColorSpace>(space), true);
|
static_cast<SkYUVColorSpace>(space), true);
|
||||||
if (fp) {
|
if (fp) {
|
||||||
SkMatrix viewMatrix;
|
SkMatrix viewMatrix;
|
||||||
|
@ -124,7 +124,7 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS
|
|||||||
GrYUVtoRGBEffect::Make(std::move(yuvTextureProxies[0]),
|
GrYUVtoRGBEffect::Make(std::move(yuvTextureProxies[0]),
|
||||||
std::move(yuvTextureProxies[1]),
|
std::move(yuvTextureProxies[1]),
|
||||||
std::move(yuvTextureProxies[2]),
|
std::move(yuvTextureProxies[2]),
|
||||||
yuvInfo.fSizeInfo.fSizes, yuvInfo.fColorSpace, false);
|
yuvInfo.fColorSpace, false);
|
||||||
paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor));
|
paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor));
|
||||||
|
|
||||||
// If the caller expects the pixels in a different color space than the one from the image,
|
// If the caller expects the pixels in a different color space than the one from the image,
|
||||||
|
@ -27,22 +27,21 @@ std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(sk_sp<GrTextureProxy
|
|||||||
uProxy,
|
uProxy,
|
||||||
sk_sp<GrTextureProxy>
|
sk_sp<GrTextureProxy>
|
||||||
vProxy,
|
vProxy,
|
||||||
const SkISize sizes[3],
|
|
||||||
SkYUVColorSpace colorSpace,
|
SkYUVColorSpace colorSpace,
|
||||||
bool nv12) {
|
bool nv12) {
|
||||||
SkScalar w[3], h[3];
|
SkScalar w[3], h[3];
|
||||||
w[0] = SkIntToScalar(sizes[0].fWidth);
|
w[0] = SkIntToScalar(yProxy->width());
|
||||||
h[0] = SkIntToScalar(sizes[0].fHeight);
|
h[0] = SkIntToScalar(yProxy->height());
|
||||||
w[1] = SkIntToScalar(sizes[1].fWidth);
|
w[1] = SkIntToScalar(uProxy->width());
|
||||||
h[1] = SkIntToScalar(sizes[1].fHeight);
|
h[1] = SkIntToScalar(uProxy->height());
|
||||||
w[2] = SkIntToScalar(sizes[2].fWidth);
|
w[2] = SkIntToScalar(vProxy->width());
|
||||||
h[2] = SkIntToScalar(sizes[2].fHeight);
|
h[2] = SkIntToScalar(vProxy->height());
|
||||||
SkMatrix yTransform = SkMatrix::I();
|
SkMatrix yTransform = SkMatrix::I();
|
||||||
SkMatrix uTransform = SkMatrix::MakeScale(w[1] / w[0], h[1] / h[0]);
|
SkMatrix uTransform = SkMatrix::MakeScale(w[1] / w[0], h[1] / h[0]);
|
||||||
SkMatrix vTransform = SkMatrix::MakeScale(w[2] / w[0], h[2] / h[0]);
|
SkMatrix vTransform = SkMatrix::MakeScale(w[2] / w[0], h[2] / h[0]);
|
||||||
GrSamplerState::Filter uvFilterMode =
|
GrSamplerState::Filter uvFilterMode =
|
||||||
((sizes[1].fWidth != sizes[0].fWidth) || (sizes[1].fHeight != sizes[0].fHeight) ||
|
((uProxy->width() != yProxy->width()) || (uProxy->height() != yProxy->height()) ||
|
||||||
(sizes[2].fWidth != sizes[0].fWidth) || (sizes[2].fHeight != sizes[0].fHeight))
|
(vProxy->width() != yProxy->width()) || (vProxy->height() != yProxy->height()))
|
||||||
? GrSamplerState::Filter::kBilerp
|
? GrSamplerState::Filter::kBilerp
|
||||||
: GrSamplerState::Filter::kNearest;
|
: GrSamplerState::Filter::kNearest;
|
||||||
SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
|
SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
|
||||||
|
@ -40,7 +40,6 @@ layout(key) in bool nv12;
|
|||||||
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> yProxy,
|
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> yProxy,
|
||||||
sk_sp<GrTextureProxy> uProxy,
|
sk_sp<GrTextureProxy> uProxy,
|
||||||
sk_sp<GrTextureProxy> vProxy,
|
sk_sp<GrTextureProxy> vProxy,
|
||||||
const SkISize sizes[3],
|
|
||||||
SkYUVColorSpace colorSpace, bool nv12);
|
SkYUVColorSpace colorSpace, bool nv12);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,24 +68,23 @@ layout(key) in bool nv12;
|
|||||||
std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(sk_sp<GrTextureProxy> yProxy,
|
std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(sk_sp<GrTextureProxy> yProxy,
|
||||||
sk_sp<GrTextureProxy> uProxy,
|
sk_sp<GrTextureProxy> uProxy,
|
||||||
sk_sp<GrTextureProxy> vProxy,
|
sk_sp<GrTextureProxy> vProxy,
|
||||||
const SkISize sizes[3],
|
|
||||||
SkYUVColorSpace colorSpace,
|
SkYUVColorSpace colorSpace,
|
||||||
bool nv12) {
|
bool nv12) {
|
||||||
SkScalar w[3], h[3];
|
SkScalar w[3], h[3];
|
||||||
w[0] = SkIntToScalar(sizes[0].fWidth);
|
w[0] = SkIntToScalar(yProxy->width());
|
||||||
h[0] = SkIntToScalar(sizes[0].fHeight);
|
h[0] = SkIntToScalar(yProxy->height());
|
||||||
w[1] = SkIntToScalar(sizes[1].fWidth);
|
w[1] = SkIntToScalar(uProxy->width());
|
||||||
h[1] = SkIntToScalar(sizes[1].fHeight);
|
h[1] = SkIntToScalar(uProxy->height());
|
||||||
w[2] = SkIntToScalar(sizes[2].fWidth);
|
w[2] = SkIntToScalar(vProxy->width());
|
||||||
h[2] = SkIntToScalar(sizes[2].fHeight);
|
h[2] = SkIntToScalar(vProxy->height());
|
||||||
SkMatrix yTransform = SkMatrix::I();
|
SkMatrix yTransform = SkMatrix::I();
|
||||||
SkMatrix uTransform = SkMatrix::MakeScale(w[1] / w[0], h[1] / h[0]);
|
SkMatrix uTransform = SkMatrix::MakeScale(w[1] / w[0], h[1] / h[0]);
|
||||||
SkMatrix vTransform = SkMatrix::MakeScale(w[2] / w[0], h[2] / h[0]);
|
SkMatrix vTransform = SkMatrix::MakeScale(w[2] / w[0], h[2] / h[0]);
|
||||||
GrSamplerState::Filter uvFilterMode =
|
GrSamplerState::Filter uvFilterMode =
|
||||||
((sizes[1].fWidth != sizes[0].fWidth) ||
|
((uProxy->width() != yProxy->width()) ||
|
||||||
(sizes[1].fHeight != sizes[0].fHeight) ||
|
(uProxy->height() != yProxy->height()) ||
|
||||||
(sizes[2].fWidth != sizes[0].fWidth) ||
|
(vProxy->width() != yProxy->width()) ||
|
||||||
(sizes[2].fHeight != sizes[0].fHeight)) ?
|
(vProxy->height() != yProxy->height())) ?
|
||||||
GrSamplerState::Filter::kBilerp :
|
GrSamplerState::Filter::kBilerp :
|
||||||
GrSamplerState::Filter::kNearest;
|
GrSamplerState::Filter::kNearest;
|
||||||
SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
|
SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
|
||||||
|
@ -18,7 +18,6 @@ public:
|
|||||||
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> yProxy,
|
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> yProxy,
|
||||||
sk_sp<GrTextureProxy> uProxy,
|
sk_sp<GrTextureProxy> uProxy,
|
||||||
sk_sp<GrTextureProxy> vProxy,
|
sk_sp<GrTextureProxy> vProxy,
|
||||||
const SkISize sizes[3],
|
|
||||||
SkYUVColorSpace colorSpace, bool nv12);
|
SkYUVColorSpace colorSpace, bool nv12);
|
||||||
SkMatrix44 ySamplerTransform() const { return fYSamplerTransform; }
|
SkMatrix44 ySamplerTransform() const { return fYSamplerTransform; }
|
||||||
SkMatrix44 uSamplerTransform() const { return fUSamplerTransform; }
|
SkMatrix44 uSamplerTransform() const { return fUSamplerTransform; }
|
||||||
|
@ -439,14 +439,10 @@ sk_sp<SkImage> SkImage_Gpu::MakeFromYUVATexturesCopyImpl(GrContext* ctx,
|
|||||||
|
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||||
// TODO: Move the sizes into GrYUVtoRGBEffect since this can just be done there.
|
|
||||||
SkISize sizes[] = {{yProxy->width(), yProxy->height()},
|
|
||||||
{uProxy->width(), uProxy->height()},
|
|
||||||
{vProxy->width(), vProxy->height()}};
|
|
||||||
// TODO: Modify the fragment processor to sample from different channel instead of taking nv12
|
// TODO: Modify the fragment processor to sample from different channel instead of taking nv12
|
||||||
// bool.
|
// bool.
|
||||||
paint.addColorFragmentProcessor(
|
paint.addColorFragmentProcessor(
|
||||||
GrYUVtoRGBEffect::Make(yProxy, uProxy, vProxy, sizes, colorSpace, nv12));
|
GrYUVtoRGBEffect::Make(yProxy, uProxy, vProxy, colorSpace, nv12));
|
||||||
|
|
||||||
const SkRect rect = SkRect::MakeIWH(width, height);
|
const SkRect rect = SkRect::MakeIWH(width, height);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user