blob: a2e67f2336cdd4593502a17421d3882afa45c395 [file] [log] [blame]
reed@google.com7b201d22011-01-11 18:59:23 +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#ifndef SkGpuDeviceFactory_DEFINED
18#define SkGpuDeviceFactory_DEFINED
19
20#include "SkDevice.h"
21
22class GrContext;
23
bsalomon@google.com91826102011-03-21 19:51:57 +000024class SK_API SkGpuDeviceFactory : public SkDeviceFactory {
reed@google.com7b201d22011-01-11 18:59:23 +000025public:
26 /**
27 * The constructor will ref() the context, passing it to each device
28 * that it creates. It will be unref()'d in the destructor
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +000029 * Non-layered devices created by the factory will draw to the
30 * rootRenderTarget. rootRenderTarget is ref-counted by the factory.
31 * SkGpuDevice::Current3DApiRenderTarget() can be passed as a special
32 * value that will cause the factory to create a render target object
33 * that reflects the state of the underlying 3D API at the time of
34 * construction.
reed@google.com7b201d22011-01-11 18:59:23 +000035 */
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +000036 SkGpuDeviceFactory(GrContext*, GrRenderTarget* rootRenderTarget);
reed@google.com7b201d22011-01-11 18:59:23 +000037
38 virtual ~SkGpuDeviceFactory();
39
40 virtual SkDevice* newDevice(SkCanvas*, SkBitmap::Config, int width,
41 int height, bool isOpaque, bool isLayer);
42
43private:
44 GrContext* fContext;
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +000045 GrRenderTarget* fRootRenderTarget;
reed@google.com7b201d22011-01-11 18:59:23 +000046};
47
48#endif
49