#define WARN(msg) \
SkDebugf("%s:%d: %s\n", __FILE__, __LINE__, msg);
-namespace {
-
// Do the commands in 'input' match the supplied pattern? Note: this is a pretty
// heavy-weight operation since we are drawing the picture into a debug canvas
// to extract the commands.
-bool check_pattern(SkPicture& input, const SkTDArray<DrawType> &pattern) {
+static bool check_pattern(SkPicture& input, const SkTDArray<DrawType> &pattern) {
SkDebugCanvas debugCanvas(input.width(), input.height());
debugCanvas.setBounds(input.width(), input.height());
input.draw(&debugCanvas);
// takes a different path if this is false)
// colorsMatch - control if the saveLayer and dbmr2r paint colors
// match (the optimization will fail if they do not)
-SkPicture* create_save_layer_opt_1(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard,
- bool saveLayerHasPaint,
- bool dbmr2rHasPaint,
- bool colorsMatch) {
+static SkPicture* create_save_layer_opt_1(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard,
+ bool saveLayerHasPaint,
+ bool dbmr2rHasPaint,
+ bool colorsMatch) {
// Create the pattern that should trigger the optimization
preOptPattern->setCount(5);
(*preOptPattern)[0] = SAVE;
}
// straight-ahead version that is seen in the skps
-SkPicture* create_save_layer_opt_1_v1(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_1_v1(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_1(preOptPattern, postOptPattern, checkerBoard,
true, // saveLayer has a paint
true, // dbmr2r has a paint
}
// alternate version that should still succeed
-SkPicture* create_save_layer_opt_1_v2(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_1_v2(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_1(preOptPattern, postOptPattern, checkerBoard,
false, // saveLayer doesn't have a paint!
true, // dbmr2r has a paint
}
// alternate version that should still succeed
-SkPicture* create_save_layer_opt_1_v3(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_1_v3(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_1(preOptPattern, postOptPattern, checkerBoard,
true, // saveLayer has a paint
false, // dbmr2r doesn't have a paint!
}
// version in which the optimization fails b.c. the colors don't match
-SkPicture* create_save_layer_opt_1_v4(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_1_v4(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_1(preOptPattern, postOptPattern, checkerBoard,
true, // saveLayer has a paint
true, // dbmr2r has a paint
// takes a different path if this is false)
// colorsMatch - control if the saveLayer and dbmr2r paint colors
// match (the optimization will fail if they do not)
-SkPicture* create_save_layer_opt_2(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard,
- bool saveLayerHasPaint,
- bool dbmr2rHasPaint,
- bool colorsMatch) {
+static SkPicture* create_save_layer_opt_2(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard,
+ bool saveLayerHasPaint,
+ bool dbmr2rHasPaint,
+ bool colorsMatch) {
// Create the pattern that should trigger the optimization
preOptPattern->setCount(8);
(*preOptPattern)[0] = SAVE;
}
// straight-ahead version that is seen in the skps
-SkPicture* create_save_layer_opt_2_v1(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_2_v1(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_2(preOptPattern, postOptPattern, checkerBoard,
true, // saveLayer has a paint
true, // dbmr2r has a paint
}
// alternate version that should still succeed
-SkPicture* create_save_layer_opt_2_v2(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_2_v2(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_2(preOptPattern, postOptPattern, checkerBoard,
false, // saveLayer doesn't have a paint!
true, // dbmr2r has a paint
}
// alternate version that should still succeed
-SkPicture* create_save_layer_opt_2_v3(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_2_v3(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_2(preOptPattern, postOptPattern, checkerBoard,
true, // saveLayer has a paint
false, // dbmr2r doesn't have a paint!
}
// version in which the optimization fails b.c. the colors don't match
-SkPicture* create_save_layer_opt_2_v4(SkTDArray<DrawType> *preOptPattern,
- SkTDArray<DrawType> *postOptPattern,
- const SkBitmap& checkerBoard) {
+static SkPicture* create_save_layer_opt_2_v4(SkTDArray<DrawType>* preOptPattern,
+ SkTDArray<DrawType>* postOptPattern,
+ const SkBitmap& checkerBoard) {
return create_save_layer_opt_2(preOptPattern, postOptPattern, checkerBoard,
true, // saveLayer has a paint
true, // dbmr2r has a paint
false); // and the colors don't match!
}
-};
-
-
// As our .skp optimizations get folded into the captured skps our code will
// no longer be locally exercised. This GM manually constructs the patterns
// our optimizations will remove to test them. It acts as both a GM and a unit