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 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); | 920 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); |
921 if (isOpaque && paint) { | 921 SkPixelGeometry geo = fProps.pixelGeometry(); |
| 922 if (paint) { |
922 // TODO: perhaps add a query to filters so we might preserve opaqueness.
.. | 923 // TODO: perhaps add a query to filters so we might preserve opaqueness.
.. |
923 if (paint->getImageFilter() || paint->getColorFilter()) { | 924 if (paint->getImageFilter() || paint->getColorFilter()) { |
924 isOpaque = false; | 925 isOpaque = false; |
| 926 geo = kUnknown_SkPixelGeometry; |
925 } | 927 } |
926 } | 928 } |
927 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), | 929 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), |
928 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 930 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
929 | 931 |
930 SkBaseDevice* device = this->getTopDevice(); | 932 SkBaseDevice* device = this->getTopDevice(); |
931 if (NULL == device) { | 933 if (NULL == device) { |
932 SkDebugf("Unable to find device for layer."); | 934 SkDebugf("Unable to find device for layer."); |
933 return; | 935 return; |
934 } | 936 } |
935 | 937 |
936 SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; | 938 SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; |
937 #if 1 | 939 #if 1 |
938 // this seems needed for current GMs, but makes us draw slower on the GPU | 940 // this seems needed for current GMs, but makes us draw slower on the GPU |
939 // Related to https://code.google.com/p/skia/issues/detail?id=3519 ? | 941 // Related to https://code.google.com/p/skia/issues/detail?id=3519 ? |
940 // | 942 // |
941 if (paint && paint->getImageFilter()) { | 943 if (paint && paint->getImageFilter()) { |
942 usage = SkBaseDevice::kPossible_TileUsage; | 944 usage = SkBaseDevice::kPossible_TileUsage; |
943 } | 945 } |
944 #endif | 946 #endif |
945 device = device->onCreateDevice(SkBaseDevice::CreateInfo(info, usage, fProps
.pixelGeometry()), | 947 device = device->onCreateDevice(SkBaseDevice::CreateInfo(info, usage, geo),
paint); |
946 paint); | |
947 if (NULL == device) { | 948 if (NULL == device) { |
948 SkErrorInternals::SetError( kInternalError_SkError, | 949 SkErrorInternals::SetError( kInternalError_SkError, |
949 "Unable to create device for layer."); | 950 "Unable to create device for layer."); |
950 return; | 951 return; |
951 } | 952 } |
952 | 953 |
953 device->setOrigin(ir.fLeft, ir.fTop); | 954 device->setOrigin(ir.fLeft, ir.fTop); |
954 DeviceCM* layer = SkNEW_ARGS(DeviceCM, (device, paint, this, fConservativeRa
sterClip)); | 955 DeviceCM* layer = SkNEW_ARGS(DeviceCM, (device, paint, this, fConservativeRa
sterClip)); |
955 device->unref(); | 956 device->unref(); |
956 | 957 |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 } | 2520 } |
2520 | 2521 |
2521 if (matrix) { | 2522 if (matrix) { |
2522 canvas->concat(*matrix); | 2523 canvas->concat(*matrix); |
2523 } | 2524 } |
2524 } | 2525 } |
2525 | 2526 |
2526 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2527 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2527 fCanvas->restoreToCount(fSaveCount); | 2528 fCanvas->restoreToCount(fSaveCount); |
2528 } | 2529 } |
OLD | NEW |