Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(904)

Unified Diff: gm/gm.cpp

Issue 23567032: Have GMs read the GrContext via a setter/getter rather than a global. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: use Brian's suggestion Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/gm.h ('k') | gm/gmmain.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gm.cpp
diff --git a/gm/gm.cpp b/gm/gm.cpp
index f794fbf9992aa76fd2b444182f340015629612cd..06d3c6dc1a6293036cdcb13178e6b44d1aef099a 100644
--- a/gm/gm.cpp
+++ b/gm/gm.cpp
@@ -62,5 +62,18 @@ void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) {
canvas->drawRect(r, paint);
}
+#if SK_SUPPORT_GPU
+// canvas could almost be a const&, but accessRenderTarget isn't const.
+/*static*/ GrContext* GM::GetGr(SkCanvas* canvas) {
+ SkASSERT(NULL != canvas);
+ SkBaseDevice* device = canvas->getTopDevice();
+ GrRenderTarget* renderTarget = device->accessRenderTarget();
+ if (NULL != renderTarget) {
+ return renderTarget->getContext();
+ }
+ return NULL;
+}
+#endif
+
// need to explicitly declare this, or we get some weird infinite loop llist
template GMRegistry* SkTRegistry<GM*(*)(void*)>::gHead;
« no previous file with comments | « gm/gm.h ('k') | gm/gmmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698