• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
22 class GrContext;
23 
24 class SK_API SkGpuDeviceFactory : public SkDeviceFactory {
25 public:
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
29      *  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.
35      */
36     SkGpuDeviceFactory(GrContext*, GrRenderTarget* rootRenderTarget);
37 
38     /**
39      * When the root layer is both a GrRenderTarget and a GrTexture it
40      * is handy to have the factory hang on to a ref to the GrTexture object.
41      * This is because the GrTexture has a ref to the GrRenderTarget but not
42      * vice-versa.
43      */
44     SkGpuDeviceFactory(GrContext*, GrTexture* rootRenderTargetTexture);
45 
46     virtual ~SkGpuDeviceFactory();
47 
48     virtual SkDevice* newDevice(SkCanvas*, SkBitmap::Config, int width,
49                                 int height, bool isOpaque, bool isLayer);
50 
51 private:
52     GrContext* fContext;
53     GrRenderTarget* fRootRenderTarget;
54     GrTexture* fRootTexture;
55 };
56 
57 #endif
58 
59