| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | |
| 10 | |
| 11 #ifndef SkGpuDevice_DEFINED | 9 #ifndef SkGpuDevice_DEFINED |
| 12 #define SkGpuDevice_DEFINED | 10 #define SkGpuDevice_DEFINED |
| 13 | 11 |
| 14 #include "SkGr.h" | 12 #include "SkGr.h" |
| 15 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
| 16 #include "SkDevice.h" | 14 #include "SkDevice.h" |
| 17 #include "SkPicture.h" | 15 #include "SkPicture.h" |
| 18 #include "SkRegion.h" | 16 #include "SkRegion.h" |
| 17 #include "SkSurface.h" |
| 19 #include "GrContext.h" | 18 #include "GrContext.h" |
| 20 #include "GrSurfacePriv.h" | 19 #include "GrSurfacePriv.h" |
| 21 | 20 |
| 22 struct SkDrawProcs; | 21 struct SkDrawProcs; |
| 23 struct GrSkDrawProcs; | 22 struct GrSkDrawProcs; |
| 24 | 23 |
| 25 class GrAccelData; | 24 class GrAccelData; |
| 26 struct GrCachedLayer; | 25 struct GrCachedLayer; |
| 27 class GrTextContext; | 26 class GrTextContext; |
| 28 | 27 |
| 29 /** | 28 /** |
| 30 * Subclass of SkBaseDevice, which directs all drawing to the GrGpu owned by th
e | 29 * Subclass of SkBaseDevice, which directs all drawing to the GrGpu owned by th
e |
| 31 * canvas. | 30 * canvas. |
| 32 */ | 31 */ |
| 33 class SK_API SkGpuDevice : public SkBaseDevice { | 32 class SK_API SkGpuDevice : public SkBaseDevice { |
| 34 public: | 33 public: |
| 35 enum Flags { | 34 enum Flags { |
| 36 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear | 35 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear |
| 37 kDFText_Flag = 1 << 1, //!< Surface should render text using signed d
istance fields | |
| 38 }; | 36 }; |
| 39 | 37 |
| 40 /** | 38 /** |
| 41 * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is
not a render | 39 * Creates an SkGpuDevice from a GrRenderTarget. |
| 42 * target. The caller owns a ref on the returned device. If the surface is c
ached, | |
| 43 * the kCached_Flag should be specified to make the device responsible for u
nlocking | |
| 44 * the surface when it is released. | |
| 45 */ | 40 */ |
| 46 static SkGpuDevice* Create(GrSurface* surface, const SkSurfaceProps&, unsign
ed flags = 0); | 41 static SkGpuDevice* Create(GrRenderTarget* target, const SkSurfaceProps*, un
signed flags = 0); |
| 47 | 42 |
| 48 /** | 43 /** |
| 49 * New device that will create an offscreen renderTarget based on the | 44 * New device that will create an offscreen renderTarget based on the ImageI
nfo and |
| 50 * ImageInfo and sampleCount. The device's storage will not | 45 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against |
| 51 * count against the GrContext's texture cache budget. The device's pixels | 46 * the resource cache budget. On failure, returns NULL. |
| 52 * will be uninitialized. On failure, returns NULL. | |
| 53 */ | 47 */ |
| 54 static SkGpuDevice* Create(GrContext*, const SkImageInfo&, const SkSurfacePr
ops&, | 48 static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInf
o&, |
| 55 int sampleCount); | 49 int sampleCount, const SkSurfaceProps*, unsigned
flags = 0); |
| 56 | 50 |
| 57 virtual ~SkGpuDevice(); | 51 virtual ~SkGpuDevice(); |
| 58 | 52 |
| 59 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { | 53 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { |
| 60 SkBaseDevice* dev = this->onCreateCompatibleDevice(CreateInfo(this->imag
eInfo(), | 54 SkBaseDevice* dev = this->onCreateCompatibleDevice(CreateInfo(this->imag
eInfo(), |
| 61 kGeneral_U
sage, | 55 kGeneral_U
sage, |
| 62 props.pixe
lGeometry())); | 56 props.pixe
lGeometry())); |
| 63 return static_cast<SkGpuDevice*>(dev); | 57 return static_cast<SkGpuDevice*>(dev); |
| 64 } | 58 } |
| 65 | 59 |
| 66 GrContext* context() const { return fContext; } | 60 GrContext* context() const { return fRenderTarget->getContext(); } |
| 67 | 61 |
| 68 // set all pixels to 0 | 62 // set all pixels to 0 |
| 69 void clearAll(); | 63 void clearAll(); |
| 70 | 64 |
| 71 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 65 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
| 72 | 66 |
| 73 SkImageInfo imageInfo() const SK_OVERRIDE { | 67 SkImageInfo imageInfo() const SK_OVERRIDE { |
| 74 return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo
::MakeUnknown(); | 68 return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo
::MakeUnknown(); |
| 75 } | 69 } |
| 76 | 70 |
| 71 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
| 72 |
| 77 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; | 73 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; |
| 78 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 74 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
| 79 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; | 75 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; |
| 80 virtual void drawRect(const SkDraw&, const SkRect& r, | 76 virtual void drawRect(const SkDraw&, const SkRect& r, |
| 81 const SkPaint& paint) SK_OVERRIDE; | 77 const SkPaint& paint) SK_OVERRIDE; |
| 82 virtual void drawRRect(const SkDraw&, const SkRRect& r, | 78 virtual void drawRRect(const SkDraw&, const SkRRect& r, |
| 83 const SkPaint& paint) SK_OVERRIDE; | 79 const SkPaint& paint) SK_OVERRIDE; |
| 84 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, | 80 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, |
| 85 const SkRRect& inner, const SkPaint& paint) SK_OVERR
IDE; | 81 const SkRRect& inner, const SkPaint& paint) SK_OVERR
IDE; |
| 86 virtual void drawOval(const SkDraw&, const SkRect& oval, | 82 virtual void drawOval(const SkDraw&, const SkRect& oval, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) SK_OVERRIDE; | 128 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) SK_OVERRIDE; |
| 133 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVE
RRIDE; | 129 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVE
RRIDE; |
| 134 bool onShouldDisableLCD(const SkPaint&) const SK_OVERRIDE; | 130 bool onShouldDisableLCD(const SkPaint&) const SK_OVERRIDE; |
| 135 | 131 |
| 136 /** PRIVATE / EXPERIMENTAL -- do not call */ | 132 /** PRIVATE / EXPERIMENTAL -- do not call */ |
| 137 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, | 133 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, |
| 138 const SkMatrix*, const SkPaint*) SK_OV
ERRIDE; | 134 const SkMatrix*, const SkPaint*) SK_OV
ERRIDE; |
| 139 | 135 |
| 140 private: | 136 private: |
| 141 GrContext* fContext; | 137 GrContext* fContext; |
| 138 GrSkDrawProcs* fDrawProcs; |
| 139 GrClipData fClipData; |
| 140 GrTextContext* fTextContext; |
| 141 SkSurfaceProps fSurfaceProps; |
| 142 GrRenderTarget* fRenderTarget; |
| 143 // remove when our clients don't rely on accessBitmap() |
| 144 SkBitmap fLegacyBitmap; |
| 145 bool fNeedClear; |
| 142 | 146 |
| 143 GrSkDrawProcs* fDrawProcs; | 147 SkGpuDevice(GrRenderTarget*, const SkSurfaceProps*, unsigned flags); |
| 144 | |
| 145 GrClipData fClipData; | |
| 146 | |
| 147 GrTextContext* fTextContext; | |
| 148 | |
| 149 // state for our render-target | |
| 150 GrRenderTarget* fRenderTarget; | |
| 151 uint32_t fFlags; | |
| 152 | |
| 153 // remove when our clients don't rely on accessBitmap() | |
| 154 SkBitmap fLegacyBitmap; | |
| 155 | |
| 156 SkGpuDevice(GrSurface*, const SkSurfaceProps&, unsigned flags = 0); | |
| 157 | 148 |
| 158 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; | 149 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; |
| 159 | 150 |
| 160 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; | 151 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; |
| 161 | 152 |
| 162 SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; | 153 SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; |
| 163 | 154 |
| 164 bool forceConservativeRasterClip() const SK_OVERRIDE { return true; } | 155 bool forceConservativeRasterClip() const SK_OVERRIDE { return true; } |
| 165 | 156 |
| 166 // sets the render target and clip on context | 157 // sets the render target and clip on context |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 bool bicubic); | 199 bool bicubic); |
| 209 | 200 |
| 210 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); | 201 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); |
| 211 | 202 |
| 212 static SkPicture::AccelData::Key ComputeAccelDataKey(); | 203 static SkPicture::AccelData::Key ComputeAccelDataKey(); |
| 213 | 204 |
| 214 typedef SkBaseDevice INHERITED; | 205 typedef SkBaseDevice INHERITED; |
| 215 }; | 206 }; |
| 216 | 207 |
| 217 #endif | 208 #endif |
| OLD | NEW |