| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkGpuDevice_DEFINED | 8 #ifndef SkGpuDevice_DEFINED |
| 9 #define SkGpuDevice_DEFINED | 9 #define SkGpuDevice_DEFINED |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 class SK_API SkGpuDevice : public SkBaseDevice { | 30 class SK_API SkGpuDevice : public SkBaseDevice { |
| 31 public: | 31 public: |
| 32 enum InitContents { | 32 enum InitContents { |
| 33 kClear_InitContents, | 33 kClear_InitContents, |
| 34 kUninit_InitContents | 34 kUninit_InitContents |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Creates an SkGpuDevice from a GrRenderTarget. | 38 * Creates an SkGpuDevice from a GrRenderTarget. |
| 39 * TODO: rm this factory. It is used by SkSurface::MakeRenderTargetDirect, |
| 40 * MakeFromBackendTexture, MakeFromBackendRenderTarget, |
| 41 * and MakeFromBackendTextureAsRenderTarget. Only the first is worriso
me. |
| 39 */ | 42 */ |
| 40 static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target, | 43 static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target, |
| 41 const SkSurfaceProps*, | 44 const SkSurfaceProps*, |
| 42 InitContents); | 45 InitContents); |
| 43 | 46 |
| 44 /** | 47 /** |
| 45 * Creates an SkGpuDevice from a GrRenderTarget whose texture width/height i
s | 48 * Creates an SkGpuDevice from a GrDrawContext whose backing width/height is |
| 46 * different than its actual width/height (e.g., approx-match scratch textur
e). | 49 * different than its actual width/height (e.g., approx-match scratch textur
e). |
| 47 */ | 50 */ |
| 48 static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target, int width, int
height, | 51 static sk_sp<SkBaseDevice> Make(sk_sp<GrDrawContext> drawContext, |
| 49 const SkSurfaceProps*, InitContents); | 52 int width, int height, |
| 53 InitContents); |
| 50 | 54 |
| 51 /** | 55 /** |
| 52 * New device that will create an offscreen renderTarget based on the ImageI
nfo and | 56 * New device that will create an offscreen renderTarget based on the ImageI
nfo and |
| 53 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against | 57 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against |
| 54 * the resource cache budget. On failure, returns nullptr. | 58 * the resource cache budget. On failure, returns nullptr. |
| 55 */ | 59 */ |
| 56 static sk_sp<SkGpuDevice> Make(GrContext*, SkBudgeted, const SkImageInfo&, | 60 static sk_sp<SkGpuDevice> Make(GrContext*, SkBudgeted, const SkImageInfo&, |
| 57 int sampleCount, const SkSurfaceProps*, InitC
ontents); | 61 int sampleCount, const SkSurfaceProps*, InitC
ontents); |
| 58 | 62 |
| 59 ~SkGpuDevice() override {} | 63 ~SkGpuDevice() override {} |
| 60 | 64 |
| 61 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { | 65 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { |
| 62 SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), k
Possible_TileUsage, | 66 SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), k
Possible_TileUsage, |
| 63 props.pixelGeometry(
)), | 67 props.pixelGeometry(
)), |
| 64 nullptr); | 68 nullptr); |
| 65 return static_cast<SkGpuDevice*>(dev); | 69 return static_cast<SkGpuDevice*>(dev); |
| 66 } | 70 } |
| 67 | 71 |
| 68 GrContext* context() const override { return fContext; } | 72 GrContext* context() const override { return fContext; } |
| 69 | 73 |
| 70 // set all pixels to 0 | 74 // set all pixels to 0 |
| 71 void clearAll(); | 75 void clearAll(); |
| 72 | 76 |
| 73 void replaceRenderTarget(bool shouldRetainContent); | 77 void replaceDrawContext(bool shouldRetainContent); |
| 74 | 78 |
| 75 GrRenderTarget* accessRenderTarget() override; | 79 GrRenderTarget* accessRenderTarget() override; |
| 76 GrDrawContext* accessDrawContext() override; | 80 GrDrawContext* accessDrawContext() override; |
| 77 | 81 |
| 78 SkImageInfo imageInfo() const override { | 82 SkImageInfo imageInfo() const override { |
| 79 return fLegacyBitmap.info(); | 83 return fLegacyBitmap.info(); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void drawPaint(const SkDraw&, const SkPaint& paint) override; | 86 void drawPaint(const SkDraw&, const SkPaint& paint) override; |
| 83 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 87 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri
de; | 145 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri
de; |
| 142 bool onShouldDisableLCD(const SkPaint&) const final; | 146 bool onShouldDisableLCD(const SkPaint&) const final; |
| 143 | 147 |
| 144 /** PRIVATE / EXPERIMENTAL -- do not call */ | 148 /** PRIVATE / EXPERIMENTAL -- do not call */ |
| 145 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, | 149 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, |
| 146 const SkMatrix*, const SkPaint*) overr
ide; | 150 const SkMatrix*, const SkPaint*) overr
ide; |
| 147 | 151 |
| 148 private: | 152 private: |
| 149 // We want these unreffed in DrawContext, RenderTarget, GrContext order. | 153 // We want these unreffed in DrawContext, RenderTarget, GrContext order. |
| 150 SkAutoTUnref<GrContext> fContext; | 154 SkAutoTUnref<GrContext> fContext; |
| 151 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 155 sk_sp<GrRenderTarget> fRenderTarget; |
| 152 sk_sp<GrDrawContext> fDrawContext; | 156 sk_sp<GrDrawContext> fDrawContext; |
| 153 | 157 |
| 154 SkAutoTUnref<const SkClipStack> fClipStack; | 158 SkAutoTUnref<const SkClipStack> fClipStack; |
| 155 SkIPoint fClipOrigin; | 159 SkIPoint fClipOrigin; |
| 156 GrClipStackClip fClip; | 160 GrClipStackClip fClip; |
| 157 // remove when our clients don't rely on accessBitmap() | 161 // remove when our clients don't rely on accessBitmap() |
| 158 SkBitmap fLegacyBitmap; | 162 SkBitmap fLegacyBitmap; |
| 159 bool fOpaque; | 163 bool fOpaque; |
| 160 | 164 |
| 161 enum Flags { | 165 enum Flags { |
| 162 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear | 166 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear |
| 163 kIsOpaque_Flag = 1 << 1, //!< Hint from client that rendering to this
device will be | 167 kIsOpaque_Flag = 1 << 1, //!< Hint from client that rendering to this
device will be |
| 164 // opaque even if the config supports alpha
. | 168 // opaque even if the config supports alpha
. |
| 165 }; | 169 }; |
| 166 static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents
init, | 170 static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents
init, |
| 167 unsigned* flags); | 171 unsigned* flags); |
| 168 | 172 |
| 169 SkGpuDevice(GrRenderTarget*, int width, int height, const SkSurfaceProps*, u
nsigned flags); | 173 SkGpuDevice(sk_sp<GrDrawContext>, int width, int height, unsigned flags); |
| 170 | 174 |
| 171 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | 175 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
| 172 | 176 |
| 173 sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&) over
ride; | 177 sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&) over
ride; |
| 174 | 178 |
| 175 SkImageFilterCache* getImageFilterCache() override; | 179 SkImageFilterCache* getImageFilterCache() override; |
| 176 | 180 |
| 177 bool forceConservativeRasterClip() const override { return true; } | 181 bool forceConservativeRasterClip() const override { return true; } |
| 178 | 182 |
| 179 // sets the render target and clip on context | 183 // sets the render target and clip on context |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 const SkPaint&); | 246 const SkPaint&); |
| 243 | 247 |
| 244 bool drawFilledDRRect(const SkMatrix& viewMatrix, const SkRRect& outer, | 248 bool drawFilledDRRect(const SkMatrix& viewMatrix, const SkRRect& outer, |
| 245 const SkRRect& inner, const SkPaint& paint); | 249 const SkRRect& inner, const SkPaint& paint); |
| 246 | 250 |
| 247 void drawProducerNine(const SkDraw&, GrTextureProducer*, const SkIRect& cent
er, | 251 void drawProducerNine(const SkDraw&, GrTextureProducer*, const SkIRect& cent
er, |
| 248 const SkRect& dst, const SkPaint&); | 252 const SkRect& dst, const SkPaint&); |
| 249 | 253 |
| 250 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); | 254 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); |
| 251 | 255 |
| 252 static GrRenderTarget* CreateRenderTarget(GrContext*, SkBudgeted, const SkIm
ageInfo&, | 256 static sk_sp<GrDrawContext> CreateDrawContext(GrContext*, |
| 253 int sampleCount); | 257 SkBudgeted, |
| 258 const SkImageInfo&, |
| 259 int sampleCount, |
| 260 const SkSurfaceProps*); |
| 254 | 261 |
| 255 void drawSpriteWithFilter(const SkDraw&, const SkBitmap&, int x, int y, | 262 void drawSpriteWithFilter(const SkDraw&, const SkBitmap&, int x, int y, |
| 256 const SkPaint&) override; | 263 const SkPaint&) override; |
| 257 | 264 |
| 258 friend class GrAtlasTextContext; | 265 friend class GrAtlasTextContext; |
| 259 friend class SkSurface_Gpu; // for access to surfaceProps | 266 friend class SkSurface_Gpu; // for access to surfaceProps |
| 260 typedef SkBaseDevice INHERITED; | 267 typedef SkBaseDevice INHERITED; |
| 261 }; | 268 }; |
| 262 | 269 |
| 263 #endif | 270 #endif |
| OLD | NEW |