2016-02-19 16:19:40 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
#include "SkBitmap.h"
|
2018-05-03 18:39:57 +00:00
|
|
|
#include "SkColorFilter.h"
|
|
|
|
#include "SkColorFilterImageFilter.h"
|
2016-02-19 16:19:40 +00:00
|
|
|
#include "SkImage.h"
|
|
|
|
#include "SkImageFilter.h"
|
2016-04-27 18:31:23 +00:00
|
|
|
#include "SkImageFilterCache.h"
|
2016-02-19 16:19:40 +00:00
|
|
|
#include "SkMatrix.h"
|
|
|
|
#include "SkSpecialImage.h"
|
|
|
|
|
|
|
|
static const int kSmallerSize = 10;
|
|
|
|
static const int kPad = 3;
|
|
|
|
static const int kFullSize = kSmallerSize + 2 * kPad;
|
|
|
|
|
|
|
|
static SkBitmap create_bm() {
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocN32Pixels(kFullSize, kFullSize, true);
|
|
|
|
bm.eraseColor(SK_ColorTRANSPARENT);
|
|
|
|
return bm;
|
|
|
|
}
|
|
|
|
|
2018-05-03 18:39:57 +00:00
|
|
|
static sk_sp<SkImageFilter> make_filter() {
|
|
|
|
sk_sp<SkColorFilter> filter(SkColorFilter::MakeModeFilter(SK_ColorBLUE,
|
|
|
|
SkBlendMode::kSrcIn));
|
|
|
|
return SkColorFilterImageFilter::Make(std::move(filter), nullptr, nullptr);
|
|
|
|
}
|
|
|
|
|
2016-02-19 16:19:40 +00:00
|
|
|
// Ensure the cache can return a cached image
|
|
|
|
static void test_find_existing(skiatest::Reporter* reporter,
|
2016-03-17 21:31:39 +00:00
|
|
|
const sk_sp<SkSpecialImage>& image,
|
|
|
|
const sk_sp<SkSpecialImage>& subset) {
|
2016-02-19 16:19:40 +00:00
|
|
|
static const size_t kCacheSize = 1000000;
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIRect clip = SkIRect::MakeWH(100, 100);
|
2016-04-27 18:31:23 +00:00
|
|
|
SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
|
|
|
|
SkImageFilterCacheKey key2(0, SkMatrix::I(), clip, subset->uniqueID(), subset->subset());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint offset = SkIPoint::Make(3, 4);
|
2018-05-03 18:39:57 +00:00
|
|
|
auto filter = make_filter();
|
|
|
|
cache->set(key1, image.get(), offset, filter.get());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint foundOffset;
|
|
|
|
|
2017-01-12 17:06:14 +00:00
|
|
|
sk_sp<SkSpecialImage> foundImage = cache->get(key1, &foundOffset);
|
2016-02-19 16:19:40 +00:00
|
|
|
REPORTER_ASSERT(reporter, foundImage);
|
|
|
|
REPORTER_ASSERT(reporter, offset == foundOffset);
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset));
|
|
|
|
}
|
|
|
|
|
|
|
|
// If either id is different or the clip or the matrix are different the
|
|
|
|
// cached image won't be found. Even if it is caching the same bitmap.
|
|
|
|
static void test_dont_find_if_diff_key(skiatest::Reporter* reporter,
|
2016-03-17 21:31:39 +00:00
|
|
|
const sk_sp<SkSpecialImage>& image,
|
|
|
|
const sk_sp<SkSpecialImage>& subset) {
|
2016-02-19 16:19:40 +00:00
|
|
|
static const size_t kCacheSize = 1000000;
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIRect clip1 = SkIRect::MakeWH(100, 100);
|
|
|
|
SkIRect clip2 = SkIRect::MakeWH(200, 200);
|
2016-04-27 18:31:23 +00:00
|
|
|
SkImageFilterCacheKey key0(0, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
|
|
|
|
SkImageFilterCacheKey key1(1, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
|
|
|
|
SkImageFilterCacheKey key2(0, SkMatrix::MakeTrans(5, 5), clip1,
|
2016-02-19 16:19:40 +00:00
|
|
|
image->uniqueID(), image->subset());
|
2016-04-27 18:31:23 +00:00
|
|
|
SkImageFilterCacheKey key3(0, SkMatrix::I(), clip2, image->uniqueID(), image->subset());
|
|
|
|
SkImageFilterCacheKey key4(0, SkMatrix::I(), clip1, subset->uniqueID(), subset->subset());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint offset = SkIPoint::Make(3, 4);
|
2018-05-03 18:39:57 +00:00
|
|
|
auto filter = make_filter();
|
|
|
|
cache->set(key0, image.get(), offset, filter.get());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint foundOffset;
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset));
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key3, &foundOffset));
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key4, &foundOffset));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test purging when the max cache size is exceeded
|
2016-03-17 21:31:39 +00:00
|
|
|
static void test_internal_purge(skiatest::Reporter* reporter, const sk_sp<SkSpecialImage>& image) {
|
2016-02-19 16:19:40 +00:00
|
|
|
SkASSERT(image->getSize());
|
2016-02-21 21:36:50 +00:00
|
|
|
const size_t kCacheSize = image->getSize() + 10;
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIRect clip = SkIRect::MakeWH(100, 100);
|
2016-04-27 18:31:23 +00:00
|
|
|
SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
|
|
|
|
SkImageFilterCacheKey key2(1, SkMatrix::I(), clip, image->uniqueID(), image->subset());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint offset = SkIPoint::Make(3, 4);
|
2018-05-03 18:39:57 +00:00
|
|
|
auto filter1 = make_filter();
|
|
|
|
cache->set(key1, image.get(), offset, filter1.get());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint foundOffset;
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset));
|
|
|
|
|
|
|
|
// This should knock the first one out of the cache
|
2018-05-03 18:39:57 +00:00
|
|
|
auto filter2 = make_filter();
|
|
|
|
cache->set(key2, image.get(), offset, filter2.get());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset));
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
|
|
|
|
}
|
|
|
|
|
2017-06-29 15:19:42 +00:00
|
|
|
// Exercise the purgeByKey and purge methods
|
2016-02-19 16:19:40 +00:00
|
|
|
static void test_explicit_purging(skiatest::Reporter* reporter,
|
2016-03-17 21:31:39 +00:00
|
|
|
const sk_sp<SkSpecialImage>& image,
|
|
|
|
const sk_sp<SkSpecialImage>& subset) {
|
2016-02-19 16:19:40 +00:00
|
|
|
static const size_t kCacheSize = 1000000;
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIRect clip = SkIRect::MakeWH(100, 100);
|
2016-04-27 18:31:23 +00:00
|
|
|
SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
|
|
|
|
SkImageFilterCacheKey key2(1, SkMatrix::I(), clip, subset->uniqueID(), image->subset());
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint offset = SkIPoint::Make(3, 4);
|
2018-05-03 18:39:57 +00:00
|
|
|
auto filter1 = make_filter();
|
|
|
|
auto filter2 = make_filter();
|
|
|
|
cache->set(key1, image.get(), offset, filter1.get());
|
|
|
|
cache->set(key2, image.get(), offset, filter2.get());
|
2016-04-18 21:49:57 +00:00
|
|
|
SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->count());)
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
SkIPoint foundOffset;
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset));
|
|
|
|
REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset));
|
|
|
|
|
2018-05-03 18:39:57 +00:00
|
|
|
cache->purgeByImageFilter(filter1.get());
|
2016-04-18 21:49:57 +00:00
|
|
|
SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache->count());)
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
|
|
|
|
REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset));
|
|
|
|
|
|
|
|
cache->purge();
|
2016-04-18 21:49:57 +00:00
|
|
|
SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->count());)
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
|
|
|
|
REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(ImageFilterCache_RasterBacked, reporter) {
|
|
|
|
SkBitmap srcBM = create_bm();
|
|
|
|
|
|
|
|
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
|
|
|
|
|
2016-04-20 18:48:36 +00:00
|
|
|
sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(full, srcBM));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
|
|
|
|
|
2016-04-20 18:48:36 +00:00
|
|
|
sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(subset, srcBM));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
test_find_existing(reporter, fullImg, subsetImg);
|
|
|
|
test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
|
|
|
|
test_internal_purge(reporter, fullImg);
|
|
|
|
test_explicit_purging(reporter, fullImg, subsetImg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-19 18:41:12 +00:00
|
|
|
// Shared test code for both the raster and gpu-backed image cases
|
2016-03-17 21:31:39 +00:00
|
|
|
static void test_image_backed(skiatest::Reporter* reporter, const sk_sp<SkImage>& srcImage) {
|
2016-02-19 16:19:40 +00:00
|
|
|
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
|
2016-12-09 19:51:59 +00:00
|
|
|
SkColorSpace* legacyColorSpace = nullptr;
|
2016-02-19 16:19:40 +00:00
|
|
|
|
2016-12-09 19:51:59 +00:00
|
|
|
sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(full, srcImage, legacyColorSpace));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
|
|
|
|
|
2016-12-09 19:51:59 +00:00
|
|
|
sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(subset, srcImage,
|
|
|
|
legacyColorSpace));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
test_find_existing(reporter, fullImg, subsetImg);
|
|
|
|
test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
|
|
|
|
test_internal_purge(reporter, fullImg);
|
|
|
|
test_explicit_purging(reporter, fullImg, subsetImg);
|
|
|
|
}
|
|
|
|
|
2016-02-19 18:41:12 +00:00
|
|
|
DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) {
|
|
|
|
SkBitmap srcBM = create_bm();
|
|
|
|
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> srcImage(SkImage::MakeFromBitmap(srcBM));
|
2016-02-19 18:41:12 +00:00
|
|
|
|
2016-03-17 21:31:39 +00:00
|
|
|
test_image_backed(reporter, srcImage);
|
2016-02-19 18:41:12 +00:00
|
|
|
}
|
|
|
|
|
2016-02-19 16:19:40 +00:00
|
|
|
#include "GrContext.h"
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
#include "GrContextPriv.h"
|
2018-01-16 13:06:32 +00:00
|
|
|
#include "GrProxyProvider.h"
|
2017-03-04 13:12:46 +00:00
|
|
|
#include "GrResourceProvider.h"
|
2017-06-15 18:01:04 +00:00
|
|
|
#include "GrSurfaceProxyPriv.h"
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
#include "GrTest.h"
|
2017-06-13 16:44:56 +00:00
|
|
|
#include "GrTexture.h"
|
2017-06-15 18:01:04 +00:00
|
|
|
#include "GrTextureProxy.h"
|
2016-02-19 16:19:40 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
static sk_sp<GrTextureProxy> create_proxy(GrProxyProvider* proxyProvider) {
|
2017-02-21 15:19:29 +00:00
|
|
|
SkBitmap srcBM = create_bm();
|
|
|
|
|
|
|
|
GrSurfaceDesc desc;
|
2017-07-21 14:17:45 +00:00
|
|
|
desc.fFlags = kNone_GrSurfaceFlags;
|
2017-02-21 15:19:29 +00:00
|
|
|
desc.fWidth = kFullSize;
|
|
|
|
desc.fHeight = kFullSize;
|
2017-07-27 20:16:25 +00:00
|
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
2017-02-21 15:19:29 +00:00
|
|
|
|
2018-03-07 18:01:25 +00:00
|
|
|
return proxyProvider->createTextureProxy(desc, SkBudgeted::kYes, srcBM.getPixels(),
|
|
|
|
srcBM.rowBytes());
|
2017-02-21 15:19:29 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 18:56:21 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
|
2017-04-06 11:59:41 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
sk_sp<GrTextureProxy> srcProxy(create_proxy(context->contextPriv().proxyProvider()));
|
2017-04-06 11:59:41 +00:00
|
|
|
if (!srcProxy) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-16 20:07:54 +00:00
|
|
|
if (!srcProxy->instantiate(context->contextPriv().resourceProvider())) {
|
2016-02-19 18:41:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-06-05 13:26:07 +00:00
|
|
|
GrTexture* tex = srcProxy->priv().peekTexture();
|
2016-02-19 18:41:12 +00:00
|
|
|
|
2017-12-13 20:00:45 +00:00
|
|
|
GrBackendTexture backendTex = tex->getBackendTexture();
|
|
|
|
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
GrSurfaceOrigin texOrigin = kTopLeft_GrSurfaceOrigin;
|
2017-04-06 11:59:41 +00:00
|
|
|
sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(context,
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
backendTex,
|
|
|
|
texOrigin,
|
2017-12-18 19:48:15 +00:00
|
|
|
kRGBA_8888_SkColorType,
|
|
|
|
kPremul_SkAlphaType, nullptr,
|
|
|
|
nullptr, nullptr));
|
2016-02-19 18:41:12 +00:00
|
|
|
if (!srcImage) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:53:34 +00:00
|
|
|
GrSurfaceOrigin readBackOrigin;
|
2018-04-04 19:54:55 +00:00
|
|
|
GrBackendTexture readBackBackendTex = srcImage->getBackendTexture(false, &readBackOrigin);
|
|
|
|
if (!GrBackendTexture::TestingOnly_Equals(readBackBackendTex, backendTex)) {
|
|
|
|
ERRORF(reporter, "backend mismatch\n");
|
2017-01-31 22:53:34 +00:00
|
|
|
}
|
2018-04-04 19:54:55 +00:00
|
|
|
REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(readBackBackendTex, backendTex));
|
|
|
|
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
if (readBackOrigin != texOrigin) {
|
|
|
|
ERRORF(reporter, "origin mismatch %d %d\n", readBackOrigin, texOrigin);
|
2017-01-31 22:53:34 +00:00
|
|
|
}
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
REPORTER_ASSERT(reporter, readBackOrigin == texOrigin);
|
2017-01-31 22:53:34 +00:00
|
|
|
|
2016-03-17 21:31:39 +00:00
|
|
|
test_image_backed(reporter, srcImage);
|
2016-02-19 18:41:12 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 16:59:58 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, ctxInfo) {
|
2017-02-21 15:19:29 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
2016-02-19 18:41:12 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
sk_sp<GrTextureProxy> srcProxy(create_proxy(context->contextPriv().proxyProvider()));
|
2017-02-21 15:19:29 +00:00
|
|
|
if (!srcProxy) {
|
2016-02-19 16:19:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
|
|
|
|
|
2017-02-21 15:19:29 +00:00
|
|
|
sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeDeferredFromGpu(
|
|
|
|
context, full,
|
2016-03-17 21:31:39 +00:00
|
|
|
kNeedNewImageUniqueID_SpecialImage,
|
2017-02-21 15:19:29 +00:00
|
|
|
srcProxy, nullptr));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
|
|
|
|
|
2017-02-21 15:19:29 +00:00
|
|
|
sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeDeferredFromGpu(
|
|
|
|
context, subset,
|
2016-02-19 16:19:40 +00:00
|
|
|
kNeedNewImageUniqueID_SpecialImage,
|
2017-02-21 15:19:29 +00:00
|
|
|
srcProxy, nullptr));
|
2016-02-19 16:19:40 +00:00
|
|
|
|
|
|
|
test_find_existing(reporter, fullImg, subsetImg);
|
|
|
|
test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
|
|
|
|
test_internal_purge(reporter, fullImg);
|
|
|
|
test_explicit_purging(reporter, fullImg, subsetImg);
|
|
|
|
}
|