reed@google.com | 7b201d2 | 2011-01-11 18:59:23 +0000 | [diff] [blame] | 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 | |
bsalomon@google.com | 9182610 | 2011-03-21 19:51:57 +0000 | [diff] [blame^] | 24 | class SK_API SkGpuDeviceFactory : public SkDeviceFactory { |
reed@google.com | 7b201d2 | 2011-01-11 18:59:23 +0000 | [diff] [blame] | 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 |
bsalomon@google.com | 2e7b43d | 2011-01-18 20:57:22 +0000 | [diff] [blame] | 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. |
reed@google.com | 7b201d2 | 2011-01-11 18:59:23 +0000 | [diff] [blame] | 35 | */ |
bsalomon@google.com | 2e7b43d | 2011-01-18 20:57:22 +0000 | [diff] [blame] | 36 | SkGpuDeviceFactory(GrContext*, GrRenderTarget* rootRenderTarget); |
reed@google.com | 7b201d2 | 2011-01-11 18:59:23 +0000 | [diff] [blame] | 37 | |
| 38 | virtual ~SkGpuDeviceFactory(); |
| 39 | |
| 40 | virtual SkDevice* newDevice(SkCanvas*, SkBitmap::Config, int width, |
| 41 | int height, bool isOpaque, bool isLayer); |
| 42 | |
| 43 | private: |
| 44 | GrContext* fContext; |
bsalomon@google.com | 2e7b43d | 2011-01-18 20:57:22 +0000 | [diff] [blame] | 45 | GrRenderTarget* fRootRenderTarget; |
reed@google.com | 7b201d2 | 2011-01-11 18:59:23 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | #endif |
| 49 | |