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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 GrContext* context() const override { return fContext; } | 74 GrContext* context() const override { return fContext; } |
75 | 75 |
76 // set all pixels to 0 | 76 // set all pixels to 0 |
77 void clearAll(); | 77 void clearAll(); |
78 | 78 |
79 void replaceDrawContext(bool shouldRetainContent); | 79 void replaceDrawContext(bool shouldRetainContent); |
80 | 80 |
81 GrDrawContext* accessDrawContext() override; | 81 GrDrawContext* accessDrawContext() override; |
82 | 82 |
83 SkImageInfo imageInfo() const override { | 83 SkImageInfo imageInfo() const override { |
84 return fLegacyBitmap.info(); | 84 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
85 SkImageInfo info = fRenderTarget->surfacePriv().info(at).makeWH(fSize.fW idth, | |
reed1
2016/07/21 14:13:59
We could land this right-away, on its own, correct
robertphillips
2016/07/21 14:16:51
Acknowledged.
| |
86 fSize.fH eight); | |
87 return info; | |
85 } | 88 } |
86 | 89 |
87 void drawPaint(const SkDraw&, const SkPaint& paint) override; | 90 void drawPaint(const SkDraw&, const SkPaint& paint) override; |
88 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun t, | 91 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun t, |
89 const SkPoint[], const SkPaint& paint) override; | 92 const SkPoint[], const SkPaint& paint) override; |
90 virtual void drawRect(const SkDraw&, const SkRect& r, | 93 virtual void drawRect(const SkDraw&, const SkRect& r, |
91 const SkPaint& paint) override; | 94 const SkPaint& paint) override; |
92 virtual void drawRRect(const SkDraw&, const SkRRect& r, | 95 virtual void drawRRect(const SkDraw&, const SkRRect& r, |
93 const SkPaint& paint) override; | 96 const SkPaint& paint) override; |
94 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, | 97 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 int left, int top, const SkPaint& paint) override; | 137 int left, int top, const SkPaint& paint) override; |
135 sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&) override; | 138 sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&) override; |
136 sk_sp<SkSpecialImage> makeSpecial(const SkImage*) override; | 139 sk_sp<SkSpecialImage> makeSpecial(const SkImage*) override; |
137 sk_sp<SkSpecialImage> snapSpecial() override; | 140 sk_sp<SkSpecialImage> snapSpecial() override; |
138 | 141 |
139 void flush() override; | 142 void flush() override; |
140 | 143 |
141 void onAttachToCanvas(SkCanvas* canvas) override; | 144 void onAttachToCanvas(SkCanvas* canvas) override; |
142 void onDetachFromCanvas() override; | 145 void onDetachFromCanvas() override; |
143 | 146 |
144 const SkBitmap& onAccessBitmap() override; | |
145 bool onAccessPixels(SkPixmap*) override; | 147 bool onAccessPixels(SkPixmap*) override; |
146 | 148 |
147 // for debugging purposes only | 149 // for debugging purposes only |
148 void drawTexture(GrTexture*, const SkRect& dst, const SkPaint&); | 150 void drawTexture(GrTexture*, const SkRect& dst, const SkPaint&); |
149 | 151 |
150 protected: | 152 protected: |
151 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) override; | 153 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) override; |
152 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri de; | 154 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri de; |
153 bool onShouldDisableLCD(const SkPaint&) const final; | 155 bool onShouldDisableLCD(const SkPaint&) const final; |
154 | 156 |
155 private: | 157 private: |
156 // We want these unreffed in DrawContext, RenderTarget, GrContext order. | 158 // We want these unreffed in DrawContext, RenderTarget, GrContext order. |
157 SkAutoTUnref<GrContext> fContext; | 159 SkAutoTUnref<GrContext> fContext; |
158 sk_sp<GrRenderTarget> fRenderTarget; | 160 sk_sp<GrRenderTarget> fRenderTarget; |
159 sk_sp<GrDrawContext> fDrawContext; | 161 sk_sp<GrDrawContext> fDrawContext; |
160 | 162 |
161 SkAutoTUnref<const SkClipStack> fClipStack; | 163 SkAutoTUnref<const SkClipStack> fClipStack; |
162 SkIPoint fClipOrigin; | 164 SkIPoint fClipOrigin; |
163 GrClipStackClip fClip; | 165 GrClipStackClip fClip; |
164 // remove when our clients don't rely on accessBitmap() | 166 SkISize fSize; |
165 SkBitmap fLegacyBitmap; | |
166 bool fOpaque; | 167 bool fOpaque; |
167 | 168 |
168 enum Flags { | 169 enum Flags { |
169 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear | 170 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear |
170 kIsOpaque_Flag = 1 << 1, //!< Hint from client that rendering to this device will be | 171 kIsOpaque_Flag = 1 << 1, //!< Hint from client that rendering to this device will be |
171 // opaque even if the config supports alpha . | 172 // opaque even if the config supports alpha . |
172 }; | 173 }; |
173 static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init, | 174 static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init, |
174 unsigned* flags); | 175 unsigned* flags); |
175 | 176 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 const SkImageInfo&, | 269 const SkImageInfo&, |
269 int sampleCount, | 270 int sampleCount, |
270 const SkSurfaceProps*); | 271 const SkSurfaceProps*); |
271 | 272 |
272 friend class GrAtlasTextContext; | 273 friend class GrAtlasTextContext; |
273 friend class SkSurface_Gpu; // for access to surfaceProps | 274 friend class SkSurface_Gpu; // for access to surfaceProps |
274 typedef SkBaseDevice INHERITED; | 275 typedef SkBaseDevice INHERITED; |
275 }; | 276 }; |
276 | 277 |
277 #endif | 278 #endif |
OLD | NEW |