| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
| 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 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 return kFullLayer_SaveLayerStrategy; | 932 return kFullLayer_SaveLayerStrategy; |
| 933 } | 933 } |
| 934 | 934 |
| 935 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, | 935 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 936 SaveFlags flags) { | 936 SaveFlags flags) { |
| 937 // Overriding classes may return false to signal that we don't need to creat
e a layer. | 937 // Overriding classes may return false to signal that we don't need to creat
e a layer. |
| 938 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); | 938 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); |
| 939 return this->internalSaveLayer(bounds, paint, flags, false, strategy); | 939 return this->internalSaveLayer(bounds, paint, flags, false, strategy); |
| 940 } | 940 } |
| 941 | 941 |
| 942 static SkBaseDevice* createCompatibleDevice(SkCanvas* canvas, | 942 static SkBaseDevice* create_compatible_device(SkCanvas* canvas, |
| 943 const SkImageInfo& info) { | 943 const SkImageInfo& info) { |
| 944 SkBaseDevice* device = canvas->getDevice(); | 944 SkBaseDevice* device = canvas->getDevice(); |
| 945 return device ? device->createCompatibleDevice(info) : NULL; | 945 return device ? device->createCompatibleDevice(info) : NULL; |
| 946 } | 946 } |
| 947 | 947 |
| 948 int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Save
Flags flags, | 948 int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Save
Flags flags, |
| 949 bool justForImageFilter, SaveLayerStrategy strat
egy) { | 949 bool justForImageFilter, SaveLayerStrategy strat
egy) { |
| 950 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 950 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
| 951 flags = (SaveFlags)(flags | kClipToLayer_SaveFlag); | 951 flags = (SaveFlags)(flags | kClipToLayer_SaveFlag); |
| 952 #endif | 952 #endif |
| 953 | 953 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 981 paint = p; | 981 paint = p; |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 | 984 |
| 985 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); | 985 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); |
| 986 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), | 986 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), |
| 987 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 987 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
| 988 | 988 |
| 989 SkBaseDevice* device; | 989 SkBaseDevice* device; |
| 990 if (paint && paint->getImageFilter()) { | 990 if (paint && paint->getImageFilter()) { |
| 991 device = createCompatibleDevice(this, info); | 991 device = create_compatible_device(this, info); |
| 992 } else { | 992 } else { |
| 993 device = this->createLayerDevice(info); | 993 device = this->createLayerDevice(info); |
| 994 } | 994 } |
| 995 if (NULL == device) { | 995 if (NULL == device) { |
| 996 SkDebugf("Unable to create device for layer."); | 996 SkDebugf("Unable to create device for layer."); |
| 997 return count; | 997 return count; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 device->setOrigin(ir.fLeft, ir.fTop); | 1000 device->setOrigin(ir.fLeft, ir.fTop); |
| 1001 DeviceCM* layer = SkNEW_ARGS(DeviceCM, (device, ir.fLeft, ir.fTop, paint, th
is)); | 1001 DeviceCM* layer = SkNEW_ARGS(DeviceCM, (device, ir.fLeft, ir.fTop, paint, th
is)); |
| (...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 if (!bitmap.installPixels(info, pixels, rowBytes)) { | 2654 if (!bitmap.installPixels(info, pixels, rowBytes)) { |
| 2655 return NULL; | 2655 return NULL; |
| 2656 } | 2656 } |
| 2657 | 2657 |
| 2658 // should this functionality be moved into allocPixels()? | 2658 // should this functionality be moved into allocPixels()? |
| 2659 if (!bitmap.info().isOpaque()) { | 2659 if (!bitmap.info().isOpaque()) { |
| 2660 bitmap.eraseColor(0); | 2660 bitmap.eraseColor(0); |
| 2661 } | 2661 } |
| 2662 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2662 return SkNEW_ARGS(SkCanvas, (bitmap)); |
| 2663 } | 2663 } |
| OLD | NEW |