Index: src/gpu/utils/GrUtils.cpp |
diff --git a/src/gpu/utils/GrUtils.cpp b/src/gpu/utils/GrUtils.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0b0d203a911eb0ed74304d9782983bdb42a25ea8 |
--- /dev/null |
+++ b/src/gpu/utils/GrUtils.cpp |
@@ -0,0 +1,29 @@ |
+ |
+/* |
+ * Copyright 2013 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#if SK_SUPPORT_GPU |
+ |
+#include "GrContext.h" |
+#include "GrUtils.h" |
+#include "GrRenderTarget.h" |
+#include "SkCanvas.h" |
+#include "SkDevice.h" |
+ |
+// canvas could almost be a const&, but accessRenderTarget isn't const. |
+GrContext* GrUtils::GetGr(SkCanvas* canvas) { |
+ SkASSERT(NULL != canvas); |
+ SkBaseDevice* device = canvas->getTopDevice(); |
+ GrRenderTarget* renderTarget = device->accessRenderTarget(); |
+ if (NULL != renderTarget) { |
+ return renderTarget->getContext(); |
+ } |
+ |
+ return NULL; |
+} |
+ |
+#endif |