blob: 57a4b1b40fe39985caf670c43b7b0b8a075e48f9 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#ifndef SkGpuCanvas_DEFINED
19#define SkGpuCanvas_DEFINED
20
21#include "SkCanvas.h"
22
23class GrContext;
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +000024class GrRenderTarget;
reed@google.comac10a2d2010-12-22 21:39:39 +000025
26/**
27 * Subclass of canvas that creates devices compatible with the GrContext pass
28 * to the canvas' constructor.
29 */
30class SkGpuCanvas : public SkCanvas {
31public:
32 /**
reed@google.com7b201d22011-01-11 18:59:23 +000033 * The GrContext object is reference counted. When passed to our
34 * constructor, its reference count is incremented. In our destructor, the
reed@google.comac10a2d2010-12-22 21:39:39 +000035 * GrGpu's reference count will be decremented.
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +000036 * GrRenderTarget represents the rendering destination in the underlying
37 * 3D API. Its reference count is incremented in the constructor and
38 * decremented in the destructor.
39 * SkGpuDevice::Current3DApiRenderTarget() can be passed as a special
40 * value that will cause the factory to create a render target object
41 * that reflects the state of the underlying 3D API at the time of
42 * construction.
reed@google.comac10a2d2010-12-22 21:39:39 +000043 */
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +000044 explicit SkGpuCanvas(GrContext*, GrRenderTarget*);
reed@google.comac10a2d2010-12-22 21:39:39 +000045 virtual ~SkGpuCanvas();
46
47 /**
reed@google.comac10a2d2010-12-22 21:39:39 +000048 * Override from SkCanvas. Returns true, and if not-null, sets size to
49 * be the width/height of our viewport.
50 */
51 virtual bool getViewport(SkIPoint* size) const;
52
reed@google.comac10a2d2010-12-22 21:39:39 +000053#if 0
54 virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
55 SaveFlags flags = kARGB_ClipLayer_SaveFlag) {
56 return this->save(flags);
57 }
58#endif
reed@google.com7b201d22011-01-11 18:59:23 +000059
reed@google.comac10a2d2010-12-22 21:39:39 +000060private:
61 GrContext* fContext;
62
63 typedef SkCanvas INHERITED;
64};
65
66#endif
67
68