aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-01-18 20:57:22 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-01-18 20:57:22 +0000
commit2e7b43d33cc495663cb814a7a9d1ecdc09c31828 (patch)
tree10d01113bbac30d6e3b121d4a9ab5552a6567fd6 /include/gpu
parent44b2c73ca6358ba9c4a413d7b39db7991612a6a2 (diff)
Remove notion of default rendertarget. This doesn't map well to usage patterns outside sample app. Make binding between SkGpuDevice and a GrRenderTarget more explicit. Create method on GrContext to wrap the current target in the 3D API with a GrRenderTarget.
git-svn-id: http://skia.googlecode.com/svn/trunk@706 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/SkGpuCanvas.h10
-rw-r--r--include/gpu/SkGpuDevice.h25
-rw-r--r--include/gpu/SkGpuDeviceFactory.h9
3 files changed, 33 insertions, 11 deletions
diff --git a/include/gpu/SkGpuCanvas.h b/include/gpu/SkGpuCanvas.h
index 8194e12123..57a4b1b40f 100644
--- a/include/gpu/SkGpuCanvas.h
+++ b/include/gpu/SkGpuCanvas.h
@@ -21,6 +21,7 @@
#include "SkCanvas.h"
class GrContext;
+class GrRenderTarget;
/**
* Subclass of canvas that creates devices compatible with the GrContext pass
@@ -32,8 +33,15 @@ public:
* The GrContext object is reference counted. When passed to our
* constructor, its reference count is incremented. In our destructor, the
* GrGpu's reference count will be decremented.
+ * GrRenderTarget represents the rendering destination in the underlying
+ * 3D API. Its reference count is incremented in the constructor and
+ * decremented in the destructor.
+ * SkGpuDevice::Current3DApiRenderTarget() can be passed as a special
+ * value that will cause the factory to create a render target object
+ * that reflects the state of the underlying 3D API at the time of
+ * construction.
*/
- explicit SkGpuCanvas(GrContext*);
+ explicit SkGpuCanvas(GrContext*, GrRenderTarget*);
virtual ~SkGpuCanvas();
/**
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 141ed96423..9c612c5c01 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -32,7 +32,22 @@ class GrTextContext;
*/
class SkGpuDevice : public SkDevice {
public:
- SkGpuDevice(GrContext*, const SkBitmap& bitmap, bool isLayer);
+ /**
+ * The SkGpuDevice will render to the GrRenderTarget, or if the paremeter is
+ * null it will create its own render target and manage that target's
+ * lifetime.
+ */
+ SkGpuDevice(GrContext*,
+ const SkBitmap& bitmap,
+ GrRenderTarget* renderTargetOrNull);
+
+ /**
+ * Magic value that can be passed to constructor. Causes
+ * the device to infer rendertarget from underlying 3D API (e.g. GL or D3D).
+ * This isn't a valid pointer, don't attempt to dereference.
+ */
+ static GrRenderTarget* Current3DApiRenderTarget();
+
virtual ~SkGpuDevice();
GrContext* context() const { return fContext; }
@@ -46,14 +61,6 @@ public:
*/
intptr_t getLayerTextureHandle() const;
- /**
- * Attaches the device to a rendering surface. This device will then render
- * to the surface.
- * For example, in OpenGL, the device will interpret handle as an FBO ID
- * and drawing to the device would direct GL to the FBO.
- */
- void bindDeviceToTargetHandle(intptr_t handle);
-
// call to set the clip to the specified rect
void scissor(const SkIRect&);
diff --git a/include/gpu/SkGpuDeviceFactory.h b/include/gpu/SkGpuDeviceFactory.h
index dd57da2c75..5dcba6a293 100644
--- a/include/gpu/SkGpuDeviceFactory.h
+++ b/include/gpu/SkGpuDeviceFactory.h
@@ -26,8 +26,14 @@ public:
/**
* The constructor will ref() the context, passing it to each device
* that it creates. It will be unref()'d in the destructor
+ * Non-layered devices created by the factory will draw to the
+ * rootRenderTarget. rootRenderTarget is ref-counted by the factory.
+ * SkGpuDevice::Current3DApiRenderTarget() can be passed as a special
+ * value that will cause the factory to create a render target object
+ * that reflects the state of the underlying 3D API at the time of
+ * construction.
*/
- SkGpuDeviceFactory(GrContext*);
+ SkGpuDeviceFactory(GrContext*, GrRenderTarget* rootRenderTarget);
virtual ~SkGpuDeviceFactory();
@@ -36,6 +42,7 @@ public:
private:
GrContext* fContext;
+ GrRenderTarget* fRootRenderTarget;
};
#endif