skia2/tests/ImageFilterCacheTest.cpp

286 lines
12 KiB
C++
Raw Normal View History

/*
* 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 "tests/Test.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkMatrix.h"
#include "include/effects/SkImageFilters.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkSpecialImage.h"
SK_USE_FLUENT_IMAGE_FILTER_TYPES
static const int kSmallerSize = 10;
static const int kPad = 3;
static const int kFullSize = kSmallerSize + 2 * kPad;
static SkBitmap create_bm() {
SkImageInfo ii = SkImageInfo::Make(kFullSize, kFullSize, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
SkBitmap bm;
bm.allocPixels(ii);
bm.eraseColor(SK_ColorTRANSPARENT);
bm.setImmutable();
return bm;
}
static sk_sp<SkImageFilter> make_filter() {
sk_sp<SkColorFilter> filter(SkColorFilters::Blend(SK_ColorBLUE, SkBlendMode::kSrcIn));
return SkImageFilters::ColorFilter(std::move(filter), nullptr, nullptr);
}
// Ensure the cache can return a cached image
static void test_find_existing(skiatest::Reporter* reporter,
const sk_sp<SkSpecialImage>& image,
const sk_sp<SkSpecialImage>& subset) {
static const size_t kCacheSize = 1000000;
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
SkIRect clip = SkIRect::MakeWH(100, 100);
SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
SkImageFilterCacheKey key2(0, SkMatrix::I(), clip, subset->uniqueID(), subset->subset());
SkIPoint offset = SkIPoint::Make(3, 4);
auto filter = make_filter();
Define coord space tagged geometry for image filters v2. This is an alternative approach to https://skia-review.googlesource.com/c/skia/+/234896 It inverts the templates and coordinate spaces, so that each coordinate space is defined by a struct that accepts the SkIRect/etc. type as an argument. For parameter space and device space, the only exposed functionality is holding on to the coordinates and moving into and out of the layer space (using the Mapping type, which now encapsulates the definition of parameter, layer, and device space for a given CTM). The LayerSpace struct has specialized definitions for each of the 6 key geometric types, exposes accessors/mutators and operations like join/intersect that work on appropriate layer-space geometry. FilterResult and Context have been updated to use these new types, although they no longer take a Usage enum. If this strategy works, FilterResult will be updated to have more utilities to operate and read from its image in layer-space so there won't be a need to have the image space (and the usage enum to differentiate between different image spaces). To further reinforce the differences between getInputBounds() and getOutputBounds() (which previously used Usage to do this), they now accept/return values in device and parameter space. This is no different than what SkCanvas would have done before calling the old functions, but now that work is owned by SkImageFilter (seems like a good thing), and achieves the same reinforcement. Change-Id: I8bebb9fadf6c8f2bd51fa863b2d6f2e4a33dd08b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244515 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-10-02 17:38:29 +00:00
cache->set(key1, filter.get(),
skif::FilterResult<For::kOutput>(image, skif::LayerSpace<SkIPoint>(offset)));
skif::FilterResult<For::kOutput> foundImage;
REPORTER_ASSERT(reporter, cache->get(key1, &foundImage));
Define coord space tagged geometry for image filters v2. This is an alternative approach to https://skia-review.googlesource.com/c/skia/+/234896 It inverts the templates and coordinate spaces, so that each coordinate space is defined by a struct that accepts the SkIRect/etc. type as an argument. For parameter space and device space, the only exposed functionality is holding on to the coordinates and moving into and out of the layer space (using the Mapping type, which now encapsulates the definition of parameter, layer, and device space for a given CTM). The LayerSpace struct has specialized definitions for each of the 6 key geometric types, exposes accessors/mutators and operations like join/intersect that work on appropriate layer-space geometry. FilterResult and Context have been updated to use these new types, although they no longer take a Usage enum. If this strategy works, FilterResult will be updated to have more utilities to operate and read from its image in layer-space so there won't be a need to have the image space (and the usage enum to differentiate between different image spaces). To further reinforce the differences between getInputBounds() and getOutputBounds() (which previously used Usage to do this), they now accept/return values in device and parameter space. This is no different than what SkCanvas would have done before calling the old functions, but now that work is owned by SkImageFilter (seems like a good thing), and achieves the same reinforcement. Change-Id: I8bebb9fadf6c8f2bd51fa863b2d6f2e4a33dd08b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244515 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-10-02 17:38:29 +00:00
REPORTER_ASSERT(reporter, offset == SkIPoint(foundImage.layerOrigin()));
REPORTER_ASSERT(reporter, !cache->get(key2, &foundImage));
}
// 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,
const sk_sp<SkSpecialImage>& image,
const sk_sp<SkSpecialImage>& subset) {
static const size_t kCacheSize = 1000000;
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
SkIRect clip1 = SkIRect::MakeWH(100, 100);
SkIRect clip2 = SkIRect::MakeWH(200, 200);
SkImageFilterCacheKey key0(0, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
SkImageFilterCacheKey key1(1, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
SkImageFilterCacheKey key2(0, SkMatrix::Translate(5, 5), clip1,
image->uniqueID(), image->subset());
SkImageFilterCacheKey key3(0, SkMatrix::I(), clip2, image->uniqueID(), image->subset());
SkImageFilterCacheKey key4(0, SkMatrix::I(), clip1, subset->uniqueID(), subset->subset());
SkIPoint offset = SkIPoint::Make(3, 4);
auto filter = make_filter();
Define coord space tagged geometry for image filters v2. This is an alternative approach to https://skia-review.googlesource.com/c/skia/+/234896 It inverts the templates and coordinate spaces, so that each coordinate space is defined by a struct that accepts the SkIRect/etc. type as an argument. For parameter space and device space, the only exposed functionality is holding on to the coordinates and moving into and out of the layer space (using the Mapping type, which now encapsulates the definition of parameter, layer, and device space for a given CTM). The LayerSpace struct has specialized definitions for each of the 6 key geometric types, exposes accessors/mutators and operations like join/intersect that work on appropriate layer-space geometry. FilterResult and Context have been updated to use these new types, although they no longer take a Usage enum. If this strategy works, FilterResult will be updated to have more utilities to operate and read from its image in layer-space so there won't be a need to have the image space (and the usage enum to differentiate between different image spaces). To further reinforce the differences between getInputBounds() and getOutputBounds() (which previously used Usage to do this), they now accept/return values in device and parameter space. This is no different than what SkCanvas would have done before calling the old functions, but now that work is owned by SkImageFilter (seems like a good thing), and achieves the same reinforcement. Change-Id: I8bebb9fadf6c8f2bd51fa863b2d6f2e4a33dd08b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244515 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-10-02 17:38:29 +00:00
cache->set(key0, filter.get(),
skif::FilterResult<For::kOutput>(image, skif::LayerSpace<SkIPoint>(offset)));
skif::FilterResult<For::kOutput> foundImage;
REPORTER_ASSERT(reporter, !cache->get(key1, &foundImage));
REPORTER_ASSERT(reporter, !cache->get(key2, &foundImage));
REPORTER_ASSERT(reporter, !cache->get(key3, &foundImage));
REPORTER_ASSERT(reporter, !cache->get(key4, &foundImage));
}
// Test purging when the max cache size is exceeded
static void test_internal_purge(skiatest::Reporter* reporter, const sk_sp<SkSpecialImage>& image) {
SkASSERT(image->getSize());
const size_t kCacheSize = image->getSize() + 10;
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
SkIRect clip = SkIRect::MakeWH(100, 100);
SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
SkImageFilterCacheKey key2(1, SkMatrix::I(), clip, image->uniqueID(), image->subset());
SkIPoint offset = SkIPoint::Make(3, 4);
auto filter1 = make_filter();
Define coord space tagged geometry for image filters v2. This is an alternative approach to https://skia-review.googlesource.com/c/skia/+/234896 It inverts the templates and coordinate spaces, so that each coordinate space is defined by a struct that accepts the SkIRect/etc. type as an argument. For parameter space and device space, the only exposed functionality is holding on to the coordinates and moving into and out of the layer space (using the Mapping type, which now encapsulates the definition of parameter, layer, and device space for a given CTM). The LayerSpace struct has specialized definitions for each of the 6 key geometric types, exposes accessors/mutators and operations like join/intersect that work on appropriate layer-space geometry. FilterResult and Context have been updated to use these new types, although they no longer take a Usage enum. If this strategy works, FilterResult will be updated to have more utilities to operate and read from its image in layer-space so there won't be a need to have the image space (and the usage enum to differentiate between different image spaces). To further reinforce the differences between getInputBounds() and getOutputBounds() (which previously used Usage to do this), they now accept/return values in device and parameter space. This is no different than what SkCanvas would have done before calling the old functions, but now that work is owned by SkImageFilter (seems like a good thing), and achieves the same reinforcement. Change-Id: I8bebb9fadf6c8f2bd51fa863b2d6f2e4a33dd08b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244515 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-10-02 17:38:29 +00:00
cache->set(key1, filter1.get(),
skif::FilterResult<For::kOutput>(image, skif::LayerSpace<SkIPoint>(offset)));
skif::FilterResult<For::kOutput> foundImage;
REPORTER_ASSERT(reporter, cache->get(key1, &foundImage));
// This should knock the first one out of the cache
auto filter2 = make_filter();
Define coord space tagged geometry for image filters v2. This is an alternative approach to https://skia-review.googlesource.com/c/skia/+/234896 It inverts the templates and coordinate spaces, so that each coordinate space is defined by a struct that accepts the SkIRect/etc. type as an argument. For parameter space and device space, the only exposed functionality is holding on to the coordinates and moving into and out of the layer space (using the Mapping type, which now encapsulates the definition of parameter, layer, and device space for a given CTM). The LayerSpace struct has specialized definitions for each of the 6 key geometric types, exposes accessors/mutators and operations like join/intersect that work on appropriate layer-space geometry. FilterResult and Context have been updated to use these new types, although they no longer take a Usage enum. If this strategy works, FilterResult will be updated to have more utilities to operate and read from its image in layer-space so there won't be a need to have the image space (and the usage enum to differentiate between different image spaces). To further reinforce the differences between getInputBounds() and getOutputBounds() (which previously used Usage to do this), they now accept/return values in device and parameter space. This is no different than what SkCanvas would have done before calling the old functions, but now that work is owned by SkImageFilter (seems like a good thing), and achieves the same reinforcement. Change-Id: I8bebb9fadf6c8f2bd51fa863b2d6f2e4a33dd08b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244515 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-10-02 17:38:29 +00:00
cache->set(key2, filter2.get(),
skif::FilterResult<For::kOutput>(image, skif::LayerSpace<SkIPoint>(offset)));
REPORTER_ASSERT(reporter, cache->get(key2, &foundImage));
REPORTER_ASSERT(reporter, !cache->get(key1, &foundImage));
}
// Exercise the purgeByKey and purge methods
static void test_explicit_purging(skiatest::Reporter* reporter,
const sk_sp<SkSpecialImage>& image,
const sk_sp<SkSpecialImage>& subset) {
static const size_t kCacheSize = 1000000;
sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize));
SkIRect clip = SkIRect::MakeWH(100, 100);
SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
SkImageFilterCacheKey key2(1, SkMatrix::I(), clip, subset->uniqueID(), image->subset());
SkIPoint offset = SkIPoint::Make(3, 4);
auto filter1 = make_filter();
auto filter2 = make_filter();
Define coord space tagged geometry for image filters v2. This is an alternative approach to https://skia-review.googlesource.com/c/skia/+/234896 It inverts the templates and coordinate spaces, so that each coordinate space is defined by a struct that accepts the SkIRect/etc. type as an argument. For parameter space and device space, the only exposed functionality is holding on to the coordinates and moving into and out of the layer space (using the Mapping type, which now encapsulates the definition of parameter, layer, and device space for a given CTM). The LayerSpace struct has specialized definitions for each of the 6 key geometric types, exposes accessors/mutators and operations like join/intersect that work on appropriate layer-space geometry. FilterResult and Context have been updated to use these new types, although they no longer take a Usage enum. If this strategy works, FilterResult will be updated to have more utilities to operate and read from its image in layer-space so there won't be a need to have the image space (and the usage enum to differentiate between different image spaces). To further reinforce the differences between getInputBounds() and getOutputBounds() (which previously used Usage to do this), they now accept/return values in device and parameter space. This is no different than what SkCanvas would have done before calling the old functions, but now that work is owned by SkImageFilter (seems like a good thing), and achieves the same reinforcement. Change-Id: I8bebb9fadf6c8f2bd51fa863b2d6f2e4a33dd08b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244515 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-10-02 17:38:29 +00:00
cache->set(key1, filter1.get(),
skif::FilterResult<For::kOutput>(image, skif::LayerSpace<SkIPoint>(offset)));
cache->set(key2, filter2.get(),
skif::FilterResult<For::kOutput>(image, skif::LayerSpace<SkIPoint>(offset)));
SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->count());)
skif::FilterResult<For::kOutput> foundImage;
REPORTER_ASSERT(reporter, cache->get(key1, &foundImage));
REPORTER_ASSERT(reporter, cache->get(key2, &foundImage));
cache->purgeByImageFilter(filter1.get());
SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache->count());)
REPORTER_ASSERT(reporter, !cache->get(key1, &foundImage));
REPORTER_ASSERT(reporter, cache->get(key2, &foundImage));
cache->purge();
SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->count());)
REPORTER_ASSERT(reporter, !cache->get(key1, &foundImage));
REPORTER_ASSERT(reporter, !cache->get(key2, &foundImage));
}
DEF_TEST(ImageFilterCache_RasterBacked, reporter) {
SkBitmap srcBM = create_bm();
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(full, srcBM));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(subset, srcBM));
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);
}
// Shared test code for both the raster and gpu-backed image cases
static void test_image_backed(skiatest::Reporter* reporter,
GrRecordingContext* rContext,
const sk_sp<SkImage>& srcImage) {
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(rContext, full, srcImage));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(rContext, subset, srcImage));
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);
}
DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) {
SkBitmap srcBM = create_bm();
sk_sp<SkImage> srcImage(SkImage::MakeFromBitmap(srcBM));
test_image_backed(reporter, nullptr, srcImage);
}
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurfaceProxyPriv.h"
Reland "Move GrGpuResource GrSurface and GrTexture into src." This reverts commit f6ed96d1c23b79130ca7344c984b07ef9d94fb7b. Reason for revert: google3 change landed Original change's description: > Revert "Move GrGpuResource GrSurface and GrTexture into src." > > This reverts commit e5a06ce678aad7640411f99f70f220f82ad49908. > > Reason for revert: Need to make change in google3 first > > Original change's description: > > Move GrGpuResource GrSurface and GrTexture into src. > > > > Must land https://chromium-review.googlesource.com/c/chromium/src/+/2087980 > > before this can land. > > > > Bug: skia:7966 > > Change-Id: I60bbb1765bfbb2c96b2bc0c9826b6b9d57eb2a03 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275077 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com > > Change-Id: Id39e0a351e49a87209de88a6ad9fadb0219db72c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:7966 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275216 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com Change-Id: I746ce739cb084cefc46f9dab24ef773e7c3cc621 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7966 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275436 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-03-05 19:14:18 +00:00
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
Reland "Migrate SkImage::MakeFromTexture to GrRecordingContext" This reverts commit 74b83a4ea9e31dbdc1996a1ed2d1844d5cdbe9b7. Reason for revert: Flutter is updated Original change's description: > Revert "Migrate SkImage::MakeFromTexture to GrRecordingContext" > > This reverts commit daa9e7455d4f0f54dc07f405becba5d0c5964847. > > Reason for revert: Broke Build-Debian9-Clang-arm-Release-Flutter_Android_Docker > > Original change's description: > > Migrate SkImage::MakeFromTexture to GrRecordingContext > > > > Android migration landed in Android CL 12234077 > > Chrome migration is landing in Chrome CL 2335812 > > > > Note: makeFromCompressedTexture is not used by Chrome. > > > > Bug: skia:104662 > > Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Auto-Submit: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I570945521c6cd78dfeea81e492b7e2b31dd0e6f5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308505 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia:104662 Change-Id: Ie1d7fd9e597e6e6e5bd91bec086e83a8c1f45a37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309321 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Adlai Holler <adlai@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
2020-08-11 15:48:49 +00:00
static GrSurfaceProxyView create_proxy_view(GrRecordingContext* rContext) {
SkBitmap srcBM = create_bm();
Reland "Migrate SkImage::MakeFromTexture to GrRecordingContext" This reverts commit 74b83a4ea9e31dbdc1996a1ed2d1844d5cdbe9b7. Reason for revert: Flutter is updated Original change's description: > Revert "Migrate SkImage::MakeFromTexture to GrRecordingContext" > > This reverts commit daa9e7455d4f0f54dc07f405becba5d0c5964847. > > Reason for revert: Broke Build-Debian9-Clang-arm-Release-Flutter_Android_Docker > > Original change's description: > > Migrate SkImage::MakeFromTexture to GrRecordingContext > > > > Android migration landed in Android CL 12234077 > > Chrome migration is landing in Chrome CL 2335812 > > > > Note: makeFromCompressedTexture is not used by Chrome. > > > > Bug: skia:104662 > > Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Auto-Submit: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I570945521c6cd78dfeea81e492b7e2b31dd0e6f5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308505 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia:104662 Change-Id: Ie1d7fd9e597e6e6e5bd91bec086e83a8c1f45a37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309321 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Adlai Holler <adlai@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
2020-08-11 15:48:49 +00:00
GrBitmapTextureMaker maker(rContext, srcBM, GrImageTexGenPolicy::kNew_Uncached_Budgeted);
return maker.view(GrMipmapped::kNo);
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
GrSurfaceProxyView srcView = create_proxy_view(dContext);
if (!srcView.proxy()) {
return;
}
if (!srcView.proxy()->instantiate(dContext->priv().resourceProvider())) {
return;
}
GrTexture* tex = srcView.proxy()->peekTexture();
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;
sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(dContext,
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,
kRGBA_8888_SkColorType,
kPremul_SkAlphaType, nullptr,
nullptr, nullptr));
if (!srcImage) {
return;
}
GrSurfaceOrigin readBackOrigin;
GrBackendTexture readBackBackendTex = srcImage->getBackendTexture(false, &readBackOrigin);
if (!GrBackendTexture::TestingOnly_Equals(readBackBackendTex, backendTex)) {
ERRORF(reporter, "backend mismatch\n");
}
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);
}
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);
test_image_backed(reporter, dContext, srcImage);
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, ctxInfo) {
Reland "Migrate SkImage::MakeFromTexture to GrRecordingContext" This reverts commit 74b83a4ea9e31dbdc1996a1ed2d1844d5cdbe9b7. Reason for revert: Flutter is updated Original change's description: > Revert "Migrate SkImage::MakeFromTexture to GrRecordingContext" > > This reverts commit daa9e7455d4f0f54dc07f405becba5d0c5964847. > > Reason for revert: Broke Build-Debian9-Clang-arm-Release-Flutter_Android_Docker > > Original change's description: > > Migrate SkImage::MakeFromTexture to GrRecordingContext > > > > Android migration landed in Android CL 12234077 > > Chrome migration is landing in Chrome CL 2335812 > > > > Note: makeFromCompressedTexture is not used by Chrome. > > > > Bug: skia:104662 > > Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Auto-Submit: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I570945521c6cd78dfeea81e492b7e2b31dd0e6f5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308505 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia:104662 Change-Id: Ie1d7fd9e597e6e6e5bd91bec086e83a8c1f45a37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309321 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Adlai Holler <adlai@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
2020-08-11 15:48:49 +00:00
auto dContext = ctxInfo.directContext();
Reland "Migrate SkImage::MakeFromTexture to GrRecordingContext" This reverts commit 74b83a4ea9e31dbdc1996a1ed2d1844d5cdbe9b7. Reason for revert: Flutter is updated Original change's description: > Revert "Migrate SkImage::MakeFromTexture to GrRecordingContext" > > This reverts commit daa9e7455d4f0f54dc07f405becba5d0c5964847. > > Reason for revert: Broke Build-Debian9-Clang-arm-Release-Flutter_Android_Docker > > Original change's description: > > Migrate SkImage::MakeFromTexture to GrRecordingContext > > > > Android migration landed in Android CL 12234077 > > Chrome migration is landing in Chrome CL 2335812 > > > > Note: makeFromCompressedTexture is not used by Chrome. > > > > Bug: skia:104662 > > Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Auto-Submit: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I570945521c6cd78dfeea81e492b7e2b31dd0e6f5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308505 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia:104662 Change-Id: Ie1d7fd9e597e6e6e5bd91bec086e83a8c1f45a37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309321 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Adlai Holler <adlai@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
2020-08-11 15:48:49 +00:00
GrSurfaceProxyView srcView = create_proxy_view(dContext);
if (!srcView.proxy()) {
return;
}
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeDeferredFromGpu(
Reland "Migrate SkImage::MakeFromTexture to GrRecordingContext" This reverts commit 74b83a4ea9e31dbdc1996a1ed2d1844d5cdbe9b7. Reason for revert: Flutter is updated Original change's description: > Revert "Migrate SkImage::MakeFromTexture to GrRecordingContext" > > This reverts commit daa9e7455d4f0f54dc07f405becba5d0c5964847. > > Reason for revert: Broke Build-Debian9-Clang-arm-Release-Flutter_Android_Docker > > Original change's description: > > Migrate SkImage::MakeFromTexture to GrRecordingContext > > > > Android migration landed in Android CL 12234077 > > Chrome migration is landing in Chrome CL 2335812 > > > > Note: makeFromCompressedTexture is not used by Chrome. > > > > Bug: skia:104662 > > Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Auto-Submit: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I570945521c6cd78dfeea81e492b7e2b31dd0e6f5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308505 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia:104662 Change-Id: Ie1d7fd9e597e6e6e5bd91bec086e83a8c1f45a37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309321 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Adlai Holler <adlai@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
2020-08-11 15:48:49 +00:00
dContext, full,
kNeedNewImageUniqueID_SpecialImage,
srcView,
GrColorType::kRGBA_8888, nullptr));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeDeferredFromGpu(
Reland "Migrate SkImage::MakeFromTexture to GrRecordingContext" This reverts commit 74b83a4ea9e31dbdc1996a1ed2d1844d5cdbe9b7. Reason for revert: Flutter is updated Original change's description: > Revert "Migrate SkImage::MakeFromTexture to GrRecordingContext" > > This reverts commit daa9e7455d4f0f54dc07f405becba5d0c5964847. > > Reason for revert: Broke Build-Debian9-Clang-arm-Release-Flutter_Android_Docker > > Original change's description: > > Migrate SkImage::MakeFromTexture to GrRecordingContext > > > > Android migration landed in Android CL 12234077 > > Chrome migration is landing in Chrome CL 2335812 > > > > Note: makeFromCompressedTexture is not used by Chrome. > > > > Bug: skia:104662 > > Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Auto-Submit: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I570945521c6cd78dfeea81e492b7e2b31dd0e6f5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308505 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia:104662 Change-Id: Ie1d7fd9e597e6e6e5bd91bec086e83a8c1f45a37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309321 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Adlai Holler <adlai@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
2020-08-11 15:48:49 +00:00
dContext, subset,
kNeedNewImageUniqueID_SpecialImage,
std::move(srcView),
GrColorType::kRGBA_8888, nullptr));
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);
}