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

Unified Diff: gm/imagefiltersscaled.cpp

Issue 834303005: Factor out checkerboard function in gm and sampleapp into tools. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rename to sk_tools::DrawCheckerboard Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefiltersscaled.cpp
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index b419187ffff37be31cad7d4eeaaaae7b62d6f2df..084de00fbe5afe13ffb9167719ff94fd457e2d9b 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -5,20 +5,21 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "SkColor.h"
+#include "Checkerboard.h"
#include "SkBitmapSource.h"
#include "SkBlurImageFilter.h"
+#include "SkColor.h"
#include "SkDisplacementMapEffect.h"
#include "SkDropShadowImageFilter.h"
#include "SkGradientShader.h"
#include "SkLightingImageFilter.h"
+#include "SkMatrixImageFilter.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkPerlinNoiseShader.h"
#include "SkRectShaderImageFilter.h"
-#include "SkMatrixImageFilter.h"
#include "SkScalar.h"
+#include "gm.h"
#define RESIZE_FACTOR SkIntToScalar(4)
@@ -40,27 +41,6 @@ protected:
return SkISize::Make(1428, 500);
}
- void make_checkerboard() {
- fCheckerboard.allocN32Pixels(64, 64);
- SkCanvas canvas(fCheckerboard);
- canvas.clear(0x00000000);
- SkPaint darkPaint;
- darkPaint.setColor(0xFF404040);
- SkPaint lightPaint;
- lightPaint.setColor(0xFFA0A0A0);
- for (int y = 0; y < 64; y += 16) {
- for (int x = 0; x < 64; x += 16) {
- canvas.save();
- canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
- canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
- canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
- canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
- canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
- canvas.restore();
- }
- }
- }
-
void make_gradient_circle(int width, int height) {
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
@@ -82,7 +62,10 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
- this->make_checkerboard();
+ fCheckerboard.allocN32Pixels(64, 64);
+ SkCanvas checkerboardCanvas(fCheckerboard);
+ sk_tools::DrawCheckerboard(&checkerboardCanvas, 0xFFA0A0A0, 0xFF404040, 8);
+
this->make_gradient_circle(64, 64);
fInitialized = true;
}
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698