OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 SkGatherPixelRefsAndRects_DEFINED | 8 #ifndef SkGatherPixelRefsAndRects_DEFINED |
9 #define SkGatherPixelRefsAndRects_DEFINED | 9 #define SkGatherPixelRefsAndRects_DEFINED |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 fSize.set(width, height); | 28 fSize.set(width, height); |
29 fPRCont = prCont; | 29 fPRCont = prCont; |
30 SkSafeRef(fPRCont); | 30 SkSafeRef(fPRCont); |
31 fEmptyBitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); | 31 fEmptyBitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); |
32 } | 32 } |
33 | 33 |
34 virtual ~SkGatherPixelRefsAndRectsDevice() { | 34 virtual ~SkGatherPixelRefsAndRectsDevice() { |
35 SkSafeUnref(fPRCont); | 35 SkSafeUnref(fPRCont); |
36 } | 36 } |
37 | 37 |
38 virtual SkImageInfo imageInfo() const SK_OVERRIDE { | 38 SkImageInfo imageInfo() const SK_OVERRIDE { |
39 return fEmptyBitmap.info(); | 39 return fEmptyBitmap.info(); |
40 } | 40 } |
41 | 41 |
42 protected: | 42 protected: |
43 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) SK_OVERRIDE
{ | 43 void drawPaint(const SkDraw& draw, const SkPaint& paint) SK_OVERRIDE { |
44 SkBitmap bm; | 44 SkBitmap bm; |
45 | 45 |
46 if (GetBitmapFromPaint(paint, &bm)) { | 46 if (GetBitmapFromPaint(paint, &bm)) { |
47 SkRect clipRect = SkRect::Make(draw.fRC->getBounds()); | 47 SkRect clipRect = SkRect::Make(draw.fRC->getBounds()); |
48 fPRCont->add(bm.pixelRef(), clipRect); | 48 fPRCont->add(bm.pixelRef(), clipRect); |
49 } | 49 } |
50 } | 50 } |
51 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t
count, | 51 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t
count, |
52 const SkPoint points[], const SkPaint& paint) SK_OVE
RRIDE { | 52 const SkPoint points[], const SkPaint& paint) SK_OVE
RRIDE { |
53 SkBitmap bm; | 53 SkBitmap bm; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 const SkColor colors[], SkXfermode* xmode, | 261 const SkColor colors[], SkXfermode* xmode, |
262 const uint16_t indices[], int indexCount, | 262 const uint16_t indices[], int indexCount, |
263 const SkPaint& paint) SK_OVERRIDE { | 263 const SkPaint& paint) SK_OVERRIDE { |
264 this->drawPoints(draw, SkCanvas::kPolygon_PointMode, vertexCount, verts,
paint); | 264 this->drawPoints(draw, SkCanvas::kPolygon_PointMode, vertexCount, verts,
paint); |
265 } | 265 } |
266 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 266 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
267 const SkPaint&) SK_OVERRIDE { | 267 const SkPaint&) SK_OVERRIDE { |
268 NothingToDo(); | 268 NothingToDo(); |
269 } | 269 } |
270 // TODO: allow this call to return failure, or move to SkBitmapDevice only. | 270 // TODO: allow this call to return failure, or move to SkBitmapDevice only. |
271 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE { | 271 const SkBitmap& onAccessBitmap() SK_OVERRIDE { |
272 return fEmptyBitmap; | 272 return fEmptyBitmap; |
273 } | 273 } |
274 virtual void lockPixels() SK_OVERRIDE { NothingToDo(); } | 274 void lockPixels() SK_OVERRIDE { NothingToDo(); } |
275 virtual void unlockPixels() SK_OVERRIDE { NothingToDo(); } | 275 void unlockPixels() SK_OVERRIDE { NothingToDo(); } |
276 virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { return fal
se; } | 276 bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { return false; } |
277 virtual bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { return
false; } | 277 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { return false;
} |
278 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImag
eFilter::Context&, | 278 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImag
eFilter::Context&, |
279 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE { | 279 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE { |
280 return false; | 280 return false; |
281 } | 281 } |
282 | 282 |
283 private: | 283 private: |
284 SkPictureUtils::SkPixelRefContainer* fPRCont; | 284 SkPictureUtils::SkPixelRefContainer* fPRCont; |
285 SkISize fSize; | 285 SkISize fSize; |
286 | 286 |
287 SkBitmap fEmptyBitmap; // legacy -- need to remo
ve | 287 SkBitmap fEmptyBitmap; // legacy -- need to remo
ve |
288 | 288 |
289 static bool GetBitmapFromPaint(const SkPaint &paint, SkBitmap* bitmap) { | 289 static bool GetBitmapFromPaint(const SkPaint &paint, SkBitmap* bitmap) { |
290 SkShader* shader = paint.getShader(); | 290 SkShader* shader = paint.getShader(); |
291 if (shader) { | 291 if (shader) { |
292 if (SkShader::kNone_GradientType == shader->asAGradient(NULL)) { | 292 if (SkShader::kNone_GradientType == shader->asAGradient(NULL)) { |
293 return SkShader::kNone_BitmapType != shader->asABitmap(bitmap, N
ULL, NULL); | 293 return SkShader::kNone_BitmapType != shader->asABitmap(bitmap, N
ULL, NULL); |
294 } | 294 } |
295 } | 295 } |
296 return false; | 296 return false; |
297 } | 297 } |
298 | 298 |
299 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRI
DE { | 299 void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE { |
300 NotSupported(); | 300 NotSupported(); |
301 } | 301 } |
302 | 302 |
303 virtual SkBaseDevice* onCreateCompatibleDevice(const CreateInfo& info) SK_OV
ERRIDE { | 303 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo& info) SK_OVERRIDE { |
304 // we expect to only get called via savelayer, in which case it is fine. | 304 // we expect to only get called via savelayer, in which case it is fine. |
305 SkASSERT(kSaveLayer_Usage == info.fUsage); | 305 SkASSERT(kSaveLayer_Usage == info.fUsage); |
306 return SkNEW_ARGS(SkGatherPixelRefsAndRectsDevice, | 306 return SkNEW_ARGS(SkGatherPixelRefsAndRectsDevice, |
307 (info.fInfo.width(), info.fInfo.height(), fPRCont)); | 307 (info.fInfo.width(), info.fInfo.height(), fPRCont)); |
308 } | 308 } |
309 | 309 |
310 static void NotSupported() { | 310 static void NotSupported() { |
311 SkDEBUGFAIL("this method should never be called"); | 311 SkDEBUGFAIL("this method should never be called"); |
312 } | 312 } |
313 | 313 |
314 static void NothingToDo() {} | 314 static void NothingToDo() {} |
315 | 315 |
316 typedef SkBaseDevice INHERITED; | 316 typedef SkBaseDevice INHERITED; |
317 }; | 317 }; |
318 | 318 |
319 #endif // SkGatherPixelRefsAndRects_DEFINED | 319 #endif // SkGatherPixelRefsAndRects_DEFINED |
OLD | NEW |