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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsContextTest.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... Created 4 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 SkCanvas canvas(bitmap); 71 SkCanvas canvas(bitmap);
72 72
73 std::unique_ptr<PaintController> paintController = PaintController::create() ; 73 std::unique_ptr<PaintController> paintController = PaintController::create() ;
74 GraphicsContext context(*paintController); 74 GraphicsContext context(*paintController);
75 75
76 Color opaque(1.0f, 0.0f, 0.0f, 1.0f); 76 Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
77 FloatRect bounds(0, 0, 100, 100); 77 FloatRect bounds(0, 0, 100, 100);
78 78
79 context.beginRecording(bounds); 79 context.beginRecording(bounds);
80 context.fillRect(FloatRect(0, 0, 50, 50), opaque, SkXfermode::kSrcOver_Mode) ; 80 context.fillRect(FloatRect(0, 0, 50, 50), opaque, SkXfermode::kSrcOver_Mode) ;
81 RefPtr<const SkPicture> picture = context.endRecording(); 81 sk_sp<const SkPicture> picture = context.endRecording();
82 canvas.drawPicture(picture.get()); 82 canvas.drawPicture(picture.get());
83 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(0, 0, 50, 50)) 83 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(0, 0, 50, 50))
84 84
85 context.beginRecording(bounds); 85 context.beginRecording(bounds);
86 context.fillRect(FloatRect(0, 0, 100, 100), opaque, SkXfermode::kSrcOver_Mod e); 86 context.fillRect(FloatRect(0, 0, 100, 100), opaque, SkXfermode::kSrcOver_Mod e);
87 picture = context.endRecording(); 87 picture = context.endRecording();
88 // Make sure the opaque region was unaffected by the rect drawn during Pictu re recording. 88 // Make sure the opaque region was unaffected by the rect drawn during Pictu re recording.
89 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(0, 0, 50, 50)) 89 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(0, 0, 50, 50))
90 90
91 canvas.drawPicture(picture.get()); 91 canvas.drawPicture(picture.get());
(...skipping 22 matching lines...) Expand all
114 context.setStrokeStyle(SolidStroke); 114 context.setStrokeStyle(SolidStroke);
115 115
116 // Make skia unable to compute fast bounds for our paths. 116 // Make skia unable to compute fast bounds for our paths.
117 DashArray dashArray; 117 DashArray dashArray;
118 dashArray.append(1); 118 dashArray.append(1);
119 dashArray.append(0); 119 dashArray.append(0);
120 context.setLineDash(dashArray, 0); 120 context.setLineDash(dashArray, 0);
121 121
122 // Make the device opaque in 10,10 40x40. 122 // Make the device opaque in 10,10 40x40.
123 context.fillRect(FloatRect(10, 10, 40, 40), opaque, SkXfermode::kSrcOver_Mod e); 123 context.fillRect(FloatRect(10, 10, 40, 40), opaque, SkXfermode::kSrcOver_Mod e);
124 RefPtr<const SkPicture> picture = context.endRecording(); 124 sk_sp<const SkPicture> picture = context.endRecording();
125 canvas.drawPicture(picture.get()); 125 canvas.drawPicture(picture.get());
126 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(10, 10, 40, 40)); 126 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(10, 10, 40, 40));
127 127
128 context.beginRecording(bounds); 128 context.beginRecording(bounds);
129 // Clip to the left edge of the opaque area. 129 // Clip to the left edge of the opaque area.
130 context.clip(IntRect(10, 10, 10, 40)); 130 context.clip(IntRect(10, 10, 10, 40));
131 131
132 // Draw a path that gets clipped. This should destroy the opaque area but on ly inside the clip. 132 // Draw a path that gets clipped. This should destroy the opaque area but on ly inside the clip.
133 Path path; 133 Path path;
134 path.moveTo(FloatPoint(10, 10)); 134 path.moveTo(FloatPoint(10, 10));
135 path.addLineTo(FloatPoint(40, 40)); 135 path.addLineTo(FloatPoint(40, 40));
136 SkPaint paint; 136 SkPaint paint;
137 paint.setColor(alpha.rgb()); 137 paint.setColor(alpha.rgb());
138 paint.setXfermodeMode(SkXfermode::kSrcOut_Mode); 138 paint.setXfermodeMode(SkXfermode::kSrcOut_Mode);
139 context.drawPath(path.getSkPath(), paint); 139 context.drawPath(path.getSkPath(), paint);
140 140
141 picture = context.endRecording(); 141 picture = context.endRecording();
142 canvas.drawPicture(picture.get()); 142 canvas.drawPicture(picture.get());
143 EXPECT_OPAQUE_PIXELS_IN_RECT(bitmap, IntRect(20, 10, 30, 40)); 143 EXPECT_OPAQUE_PIXELS_IN_RECT(bitmap, IntRect(20, 10, 30, 40));
144 } 144 }
145 145
146 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698