aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-05-27 13:23:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-27 13:23:23 -0700
commit4ee6bd86c500d9b464e2f8cb3565544b8c97c0a9 (patch)
treed5c05d429959793bbb9040b4756bdda01115cf64 /gm
parenta9f1db7902227143f97e4e29c1eefcd690f6aced (diff)
Add caps overrides to GMs
Diffstat (limited to 'gm')
-rw-r--r--gm/bleed.cpp69
-rw-r--r--gm/discard.cpp1
-rw-r--r--gm/gm.h7
-rw-r--r--gm/textblobuseaftergpufree.cpp1
4 files changed, 32 insertions, 46 deletions
diff --git a/gm/bleed.cpp b/gm/bleed.cpp
index 75cf8ca9a5..a96917baa2 100644
--- a/gm/bleed.cpp
+++ b/gm/bleed.cpp
@@ -12,6 +12,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextOptions.h"
#endif
// Create a black&white checked texture with 2 1-pixel rings
@@ -188,67 +189,52 @@ protected:
canvas->scale(0.71f, 1.22f);
}
- // First draw a column with no bleeding, tiling, or filtering
+ // First draw a column with no bleeding and no filtering
this->drawCase1(canvas, kCol0X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
this->drawCase2(canvas, kCol0X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
this->drawCase3(canvas, kCol0X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
- // Then draw a column with no bleeding or tiling but with low filtering
+ // Then draw a column with no bleeding and low filtering
this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
- // Then draw a column with no bleeding or tiling but with high filtering
+ // Then draw a column with no bleeding and high filtering
this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-#if SK_SUPPORT_GPU
- GrContext* ctx = canvas->getGrContext();
- int oldMaxTextureSize = 0;
- if (ctx) {
- // shrink the max texture size so all our textures can be reasonably sized
- oldMaxTextureSize = ctx->getMaxTextureSize();
- ctx->setMaxTextureSizeOverride(kMaxTextureSize);
- }
-#endif
+ // Then draw a column with bleeding and no filtering (bleed should have no effect w/out blur)
+ this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
+ this->drawCase2(canvas, kCol3X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
+ this->drawCase3(canvas, kCol3X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
+ this->drawCase4(canvas, kCol3X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
- // Then draw a column with no bleeding but with tiling and low filtering
- this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase2(canvas, kCol3X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase3(canvas, kCol3X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase4(canvas, kCol3X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
-
- // Then draw a column with no bleeding but with tiling and high filtering
- this->drawCase1(canvas, kCol4X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase2(canvas, kCol4X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase3(canvas, kCol4X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase4(canvas, kCol4X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-
- // Then draw a column with bleeding, tiling, and low filtering
- this->drawCase1(canvas, kCol5X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase2(canvas, kCol5X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase3(canvas, kCol5X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase4(canvas, kCol5X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
-
- // Finally draw a column with bleeding, tiling, and high filtering
- this->drawCase1(canvas, kCol6X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase2(canvas, kCol6X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase3(canvas, kCol6X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase4(canvas, kCol6X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+ // Then draw a column with bleeding and low filtering
+ this->drawCase1(canvas, kCol4X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
+ this->drawCase2(canvas, kCol4X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
+ this->drawCase3(canvas, kCol4X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
+ this->drawCase4(canvas, kCol4X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
+
+ // Finally draw a column with bleeding and high filtering
+ this->drawCase1(canvas, kCol5X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+ this->drawCase2(canvas, kCol5X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+ this->drawCase3(canvas, kCol5X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+ this->drawCase4(canvas, kCol5X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-#if SK_SUPPORT_GPU
- if (ctx) {
- ctx->setMaxTextureSizeOverride(oldMaxTextureSize);
- }
-#endif
canvas->restore();
}
}
+#if SK_SUPPORT_GPU
+ void modifyGrContextOptions(GrContextOptions* options) override {
+ options->fMaxTextureSizeOverride = kMaxTextureSize;
+ }
+#endif
+
private:
static const int kBlockSize = 70;
static const int kBlockSpacing = 5;
@@ -259,8 +245,7 @@ private:
static const int kCol3X = 4*kBlockSpacing + 3*kBlockSize;
static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize;
static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize;
- static const int kCol6X = 7*kBlockSpacing + 6*kBlockSize;
- static const int kWidth = 8*kBlockSpacing + 7*kBlockSize;
+ static const int kWidth = 7*kBlockSpacing + 6*kBlockSize;
static const int kRow0Y = kBlockSpacing;
static const int kRow1Y = 2*kBlockSpacing + kBlockSize;
diff --git a/gm/discard.cpp b/gm/discard.cpp
index a76228897e..106a6becc0 100644
--- a/gm/discard.cpp
+++ b/gm/discard.cpp
@@ -9,6 +9,7 @@
#include "SkCanvas.h"
#include "SkColorShader.h"
#include "SkPaint.h"
+#include "SkRandom.h"
#include "SkSurface.h"
#if SK_SUPPORT_GPU
diff --git a/gm/gm.h b/gm/gm.h
index 87ad92722a..24c610041c 100644
--- a/gm/gm.h
+++ b/gm/gm.h
@@ -17,10 +17,7 @@
#include "sk_tool_utils.h"
class SkAnimTimer;
-
-#if SK_SUPPORT_GPU
-#include "GrContext.h"
-#endif
+struct GrContextOptions;
#define DEF_GM(code) \
static skiagm::GM* SK_MACRO_APPEND_LINE(F_)(void*) { code; } \
@@ -96,6 +93,8 @@ namespace skiagm {
bool animate(const SkAnimTimer&);
+ virtual void modifyGrContextOptions(GrContextOptions* options) {}
+
protected:
/** draws a standard message that the GM is only intended to be used with the GPU.*/
void drawGpuOnlyMessage(SkCanvas*);
diff --git a/gm/textblobuseaftergpufree.cpp b/gm/textblobuseaftergpufree.cpp
index 127e4367d6..070c9ef155 100644
--- a/gm/textblobuseaftergpufree.cpp
+++ b/gm/textblobuseaftergpufree.cpp
@@ -12,6 +12,7 @@
#include "SkCanvas.h"
#include "SkSurface.h"
#include "SkTextBlob.h"
+#include "GrContext.h"
// This tests that we correctly regenerate textblobs after freeing all gpu resources crbug/491350
namespace skiagm {