Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Side by Side Diff: src/utils/SkDeferredCanvas.cpp

Issue 1166993002: Towards removing getTexture() from SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698