| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #include "SkDeferredCanvas.h" | 9 #include "SkDeferredCanvas.h" |
| 10 | 10 |
| 11 #include "SkBitmapDevice.h" | 11 #include "SkBitmapDevice.h" |
| 12 #include "SkChunkAlloc.h" | 12 #include "SkChunkAlloc.h" |
| 13 #include "SkColorFilter.h" | 13 #include "SkColorFilter.h" |
| 14 #include "SkDrawFilter.h" | 14 #include "SkDrawFilter.h" |
| 15 #include "SkGPipe.h" | 15 #include "SkGPipe.h" |
| 16 #include "SkImage_Base.h" |
| 16 #include "SkPaint.h" | 17 #include "SkPaint.h" |
| 17 #include "SkPaintPriv.h" | 18 #include "SkPaintPriv.h" |
| 18 #include "SkRRect.h" | 19 #include "SkRRect.h" |
| 19 #include "SkShader.h" | 20 #include "SkShader.h" |
| 20 #include "SkSurface.h" | 21 #include "SkSurface.h" |
| 21 | 22 |
| 22 enum { | 23 enum { |
| 23 // Deferred canvas will auto-flush when recording reaches this limit | 24 // Deferred canvas will auto-flush when recording reaches this limit |
| 24 kDefaultMaxRecordingStorageBytes = 64*1024*1024, | 25 kDefaultMaxRecordingStorageBytes = 64*1024*1024, |
| 25 kDeferredCanvasBitmapSizeThreshold = ~0U, // Disables this feature | 26 kDeferredCanvasBitmapSizeThreshold = ~0U, // Disables this feature |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 return sk_64_mul(image->width(), image->height()); | 37 return sk_64_mul(image->width(), image->height()); |
| 37 } | 38 } |
| 38 | 39 |
| 39 // HACK -- see crbug.com/485243 | 40 // HACK -- see crbug.com/485243 |
| 40 // | 41 // |
| 41 // Work around case where Blink gives us an image, but will "mutate" it (by chan
ging its contents | 42 // Work around case where Blink gives us an image, but will "mutate" it (by chan
ging its contents |
| 42 // directly using webgl). Until that is fixed at the call-site, we treat gpu-bac
ked-images as | 43 // directly using webgl). Until that is fixed at the call-site, we treat gpu-bac
ked-images as |
| 43 // mutable for now (at least for the purposes of deferred canvas) | 44 // mutable for now (at least for the purposes of deferred canvas) |
| 44 // | 45 // |
| 45 static bool should_draw_gpu_image_immediately(const SkImage* image) { | 46 static bool should_draw_gpu_image_immediately(const SkImage* image) { |
| 46 return image->getTexture() != NULL; | 47 return as_IB(image)->getTexture() != NULL; |
| 47 } | 48 } |
| 48 | 49 |
| 49 static bool should_draw_immediately(const SkBitmap* bitmap, const SkImage* image
, | 50 static bool should_draw_immediately(const SkBitmap* bitmap, const SkImage* image
, |
| 50 const SkPaint* paint, size_t bitmapSizeThres
hold) { | 51 const SkPaint* paint, size_t bitmapSizeThres
hold) { |
| 51 if (bitmap && ((bitmap->getTexture() && !bitmap->isImmutable()) || | 52 if (bitmap && ((bitmap->getTexture() && !bitmap->isImmutable()) || |
| 52 (bitmap->getSize() > bitmapSizeThreshold))) { | 53 (bitmap->getSize() > bitmapSizeThreshold))) { |
| 53 return true; | 54 return true; |
| 54 } | 55 } |
| 55 if (image) { | 56 if (image) { |
| 56 if (should_draw_gpu_image_immediately(image) || image_area(image) > bitm
apSizeThreshold) { | 57 if (should_draw_gpu_image_immediately(image) || image_area(image) > bitm
apSizeThreshold) { |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 985 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
| 985 this->drawingCanvas()->setDrawFilter(filter); | 986 this->drawingCanvas()->setDrawFilter(filter); |
| 986 this->INHERITED::setDrawFilter(filter); | 987 this->INHERITED::setDrawFilter(filter); |
| 987 this->recordedDrawCommand(); | 988 this->recordedDrawCommand(); |
| 988 return filter; | 989 return filter; |
| 989 } | 990 } |
| 990 | 991 |
| 991 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 992 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
| 992 return this->drawingCanvas(); | 993 return this->drawingCanvas(); |
| 993 } | 994 } |
| OLD | NEW |