OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
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 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter(
) : NULL)) { | 910 if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter(
) : NULL)) { |
911 return; | 911 return; |
912 } | 912 } |
913 | 913 |
914 // FIXME: do willSaveLayer() overriders returning kNoLayer_SaveLayerStrategy
really care about | 914 // FIXME: do willSaveLayer() overriders returning kNoLayer_SaveLayerStrategy
really care about |
915 // the clipRectBounds() call above? | 915 // the clipRectBounds() call above? |
916 if (kNoLayer_SaveLayerStrategy == strategy) { | 916 if (kNoLayer_SaveLayerStrategy == strategy) { |
917 return; | 917 return; |
918 } | 918 } |
919 | 919 |
920 // Kill the imagefilter if our device doesn't allow it | 920 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); |
921 SkLazyPaint lazyP; | 921 if (isOpaque && paint) { |
922 if (paint && paint->getImageFilter()) { | 922 // TODO: perhaps add a query to filters so we might preserve opaqueness.
.. |
923 if (!this->getTopDevice()->allowImageFilter(paint->getImageFilter())) { | 923 if (paint->getImageFilter() || paint->getColorFilter()) { |
924 if (justForImageFilter) { | 924 isOpaque = false; |
925 // early exit if the layer was just for the imageFilter | |
926 return; | |
927 } | |
928 SkPaint* p = lazyP.set(*paint); | |
929 p->setImageFilter(NULL); | |
930 paint = p; | |
931 } | 925 } |
932 } | 926 } |
933 | |
934 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); | |
935 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), | 927 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), |
936 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 928 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
937 | 929 |
938 SkBaseDevice* device = this->getTopDevice(); | 930 SkBaseDevice* device = this->getTopDevice(); |
939 if (NULL == device) { | 931 if (NULL == device) { |
940 SkDebugf("Unable to find device for layer."); | 932 SkDebugf("Unable to find device for layer."); |
941 return; | 933 return; |
942 } | 934 } |
943 | 935 |
944 SkBaseDevice::Usage usage = SkBaseDevice::kSaveLayer_Usage; | 936 SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; |
| 937 #if 0 |
| 938 // this seems needed for current GMs, but makes us draw slower on the GPU |
945 if (paint && paint->getImageFilter()) { | 939 if (paint && paint->getImageFilter()) { |
946 usage = SkBaseDevice::kImageFilter_Usage; | 940 usage = SkBaseDevice::kPossible_TileUsage; |
947 } | 941 } |
948 device = device->onCreateCompatibleDevice(SkBaseDevice::CreateInfo(info, usa
ge, | 942 #endif |
949 fProps.pi
xelGeometry())); | 943 device = device->onCreateDevice(SkBaseDevice::CreateInfo(info, usage, fProps
.pixelGeometry()), |
| 944 paint); |
950 if (NULL == device) { | 945 if (NULL == device) { |
951 SkErrorInternals::SetError( kInternalError_SkError, | 946 SkErrorInternals::SetError( kInternalError_SkError, |
952 "Unable to create device for layer."); | 947 "Unable to create device for layer."); |
953 return; | 948 return; |
954 } | 949 } |
955 | 950 |
956 device->setOrigin(ir.fLeft, ir.fTop); | 951 device->setOrigin(ir.fLeft, ir.fTop); |
957 DeviceCM* layer = SkNEW_ARGS(DeviceCM, | 952 DeviceCM* layer = SkNEW_ARGS(DeviceCM, |
958 (device, ir.fLeft, ir.fTop, paint, this, fConse
rvativeRasterClip)); | 953 (device, ir.fLeft, ir.fTop, paint, this, fConse
rvativeRasterClip)); |
959 device->unref(); | 954 device->unref(); |
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 } | 2518 } |
2524 | 2519 |
2525 if (matrix) { | 2520 if (matrix) { |
2526 canvas->concat(*matrix); | 2521 canvas->concat(*matrix); |
2527 } | 2522 } |
2528 } | 2523 } |
2529 | 2524 |
2530 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2525 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2531 fCanvas->restoreToCount(fSaveCount); | 2526 fCanvas->restoreToCount(fSaveCount); |
2532 } | 2527 } |
OLD | NEW |