aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SpecialImageTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-11-01 17:28:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-02 15:32:04 +0000
commit8bc06d07f57ede17ccabfa38f1d7e31bbf311ab5 (patch)
tree5b983d773fd391bfc07e6c9429f28ad941fa4bfc /tests/SpecialImageTest.cpp
parent9caeb0bc83ab45859a996efecbcd1215be0f1b1e (diff)
Back SkSpecialImage_Gpu with a GrTextureProxy
This is split out of https://codereview.chromium.org/2215323003/ (Start using RenderTargetProxy (omnibus)) The addition of the gpuMemorySize methods is for the SkSpecialImage cache. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4227 Change-Id: Ia9b9d42fb2a0caf61bbfa3ebcc84308c56f541fc Reviewed-on: https://skia-review.googlesource.com/4227 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/SpecialImageTest.cpp')
-rw-r--r--tests/SpecialImageTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index e992177430..23e8d5b7e3 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -17,6 +17,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrTextureProxy.h"
#endif
@@ -290,4 +291,44 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
}
}
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo) {
+ GrContext* context = ctxInfo.grContext();
+ SkBitmap bm = create_bm();
+
+ GrSurfaceDesc desc;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fWidth = kFullSize;
+ desc.fHeight = kFullSize;
+
+ sk_sp<GrTextureProxy> proxy(GrTextureProxy::Make(context->textureProvider(), desc,
+ SkBackingFit::kExact, SkBudgeted::kNo,
+ bm.getPixels(), 0));
+ if (!proxy) {
+ return;
+ }
+
+ sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeDeferredFromGpu(
+ context,
+ SkIRect::MakeWH(kFullSize, kFullSize),
+ kNeedNewImageUniqueID_SpecialImage,
+ proxy, nullptr));
+
+ const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
+
+ {
+ sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu(
+ context,
+ subset,
+ kNeedNewImageUniqueID_SpecialImage,
+ proxy, nullptr));
+ test_image(subSImg1, reporter, context, true, kPad, kFullSize);
+ }
+
+ {
+ sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset));
+ test_image(subSImg2, reporter, context, true, kPad, kFullSize);
+ }
+}
+
#endif