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

Unified Diff: samplecode/SampleFatBits.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 | « samplecode/SampleColorFilter.cpp ('k') | samplecode/SampleUnpremul.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleFatBits.cpp
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 9b9af3e3e9bcf544e1cc839435a93265f7b8ccb0..9da351370ad1e0e2a2a5368dcf282136d4f413a3 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "Checkerboard.h"
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
@@ -35,18 +36,6 @@ static void erase(SkSurface* surface) {
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
}
-static SkShader* createChecker(const SkMatrix& localMatrix) {
-// SkColor colors[] = { 0xFFFDFDFD, 0xFFF4F4F4 };
- SkColor colors[] = { 0xFFFFFFFF, 0xFFFFFFFF };
- SkBitmap bm;
- bm.allocN32Pixels(2, 2);
- bm.lockPixels();
- *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = SkPreMultiplyColor(colors[0]);
- *bm.getAddr32(0, 1) = *bm.getAddr32(1, 0) = SkPreMultiplyColor(colors[1]);
- return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &localMatrix);
-}
-
class FatBits {
public:
FatBits() {
@@ -98,7 +87,8 @@ public:
fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zoom));
fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
- fShader.reset(createChecker(fMatrix));
+ fShader.reset(sk_tools::CreateCheckerboardShader(
+ 0xFFCCCCCC, 0xFFFFFFFF, zoom));
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
fMinSurface.reset(SkSurface::NewRaster(info));
« no previous file with comments | « samplecode/SampleColorFilter.cpp ('k') | samplecode/SampleUnpremul.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698