diff options
author | bsalomon <bsalomon@google.com> | 2015-01-31 07:51:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-31 07:51:14 -0800 |
commit | b62da80cbf6643c1944d3ebf8df233f286bd3fde (patch) | |
tree | 5e2db72b1dd92cb067ab99d899fcfd7c559d0bcf /gm | |
parent | 6bfef2dfec3253efa48aec0b5ea108e0dc041d15 (diff) |
Add standard way to indicate GM is GPU-only.
TBR=egdaniel@google.com,mtklein@google.com
Review URL: https://codereview.chromium.org/869393007
Diffstat (limited to 'gm')
-rw-r--r-- | gm/beziereffects.cpp | 3 | ||||
-rw-r--r-- | gm/convexpolyeffect.cpp | 1 | ||||
-rw-r--r-- | gm/dcshader.cpp | 6 | ||||
-rw-r--r-- | gm/gm.cpp | 25 | ||||
-rw-r--r-- | gm/gm.h | 3 | ||||
-rw-r--r-- | gm/rrects.cpp | 6 | ||||
-rw-r--r-- | gm/texdata.cpp | 2 | ||||
-rw-r--r-- | gm/texturedomaineffect.cpp | 1 | ||||
-rw-r--r-- | gm/yuvtorgbeffect.cpp | 1 |
9 files changed, 45 insertions, 3 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index e49fc91a86..0ddcc52b95 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -48,6 +48,7 @@ protected: void onDraw(SkCanvas* canvas) SK_OVERRIDE { GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); if (NULL == rt) { + this->drawGpuOnlyMessage(canvas); return; } GrContext* context = rt->getContext(); @@ -203,6 +204,7 @@ protected: void onDraw(SkCanvas* canvas) SK_OVERRIDE { GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); if (NULL == rt) { + this->drawGpuOnlyMessage(canvas); return; } GrContext* context = rt->getContext(); @@ -391,6 +393,7 @@ protected: void onDraw(SkCanvas* canvas) SK_OVERRIDE { GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); if (NULL == rt) { + this->drawGpuOnlyMessage(canvas); return; } GrContext* context = rt->getContext(); diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp index 6e4705745b..281ddca77e 100644 --- a/gm/convexpolyeffect.cpp +++ b/gm/convexpolyeffect.cpp @@ -95,6 +95,7 @@ protected: void onDraw(SkCanvas* canvas) SK_OVERRIDE { GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); if (NULL == rt) { + this->drawGpuOnlyMessage(canvas); return; } GrContext* context = rt->getContext(); diff --git a/gm/dcshader.cpp b/gm/dcshader.cpp index 1f5969bd3c..4b8f5eddc7 100644 --- a/gm/dcshader.cpp +++ b/gm/dcshader.cpp @@ -248,6 +248,12 @@ protected: } void onDraw(SkCanvas* canvas) SK_OVERRIDE { + // This GM exists to test a specific feature of the GPU backend. It does not work with the + // sw rasterizer, tile modes, etc. + if (NULL == canvas->getGrContext()) { + this->drawGpuOnlyMessage(canvas); + return; + } SkPaint paint; SkTArray<SkMatrix> devMats; devMats.push_back().reset(); @@ -6,7 +6,7 @@ */ #include "gm.h" - +#include "SkShader.h" using namespace skiagm; GM::GM() { @@ -64,6 +64,29 @@ void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) { canvas->drawRect(r, paint); } +void GM::drawGpuOnlyMessage(SkCanvas* canvas) { + SkBitmap bmp; + bmp.allocN32Pixels(128, 64); + SkCanvas bmpCanvas(bmp); + bmpCanvas.drawColor(SK_ColorWHITE); + SkPaint paint; + paint.setAntiAlias(true); + paint.setTextSize(20); + paint.setColor(SK_ColorRED); + static const char kTxt[] = "GPU Only"; + bmpCanvas.drawText(kTxt, strlen(kTxt), 20, 40, paint); + SkMatrix localM; + localM.setRotate(35.f); + localM.postTranslate(10.f, 0.f); + SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp, SkShader::kMirror_TileMode, + SkShader::kMirror_TileMode, + &localM)); + paint.setShader(shader); + paint.setFilterQuality(kMedium_SkFilterQuality); + canvas->drawPaint(paint); + return; +} + // need to explicitly declare this, or we get some weird infinite loop llist template GMRegistry* GMRegistry::gHead; @@ -93,6 +93,9 @@ namespace skiagm { } protected: + /** draws a standard message that the GM is only intended to be used with the GPU.*/ + void drawGpuOnlyMessage(SkCanvas* + ); virtual void onOnceBeforeDraw() {} virtual void onDraw(SkCanvas*) = 0; virtual void onDrawBackground(SkCanvas*); diff --git a/gm/rrects.cpp b/gm/rrects.cpp index 046e5e624a..4b8e7648f7 100644 --- a/gm/rrects.cpp +++ b/gm/rrects.cpp @@ -57,13 +57,15 @@ protected: SkISize onISize() SK_OVERRIDE { return SkISize::Make(kImageWidth, kImageHeight); } void onDraw(SkCanvas* canvas) SK_OVERRIDE { + GrContext* context = NULL; #if SK_SUPPORT_GPU GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); - GrContext* context = rt ? rt->getContext() : NULL; + context = rt ? rt->getContext() : NULL; +#endif if (kEffect_Type == fType && NULL == context) { + this->drawGpuOnlyMessage(canvas); return; } -#endif SkPaint paint; if (kAA_Draw_Type == fType) { diff --git a/gm/texdata.cpp b/gm/texdata.cpp index dafd579e1f..4644758344 100644 --- a/gm/texdata.cpp +++ b/gm/texdata.cpp @@ -128,6 +128,8 @@ protected: 4 * stride); ctx->drawRect(paint, vm, SkRect::MakeWH(2*S, 2*S)); } + } else { + this->drawGpuOnlyMessage(canvas); } } diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index 570ec254f3..d39375b3a2 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -75,6 +75,7 @@ protected: } GrContext* context = rt->getContext(); if (NULL == context) { + this->drawGpuOnlyMessage(canvas); return; } diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index 1a2c9c9f39..fb0c67d3d1 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -66,6 +66,7 @@ protected: } GrContext* context = rt->getContext(); if (NULL == context) { + this->drawGpuOnlyMessage(canvas); return; } |