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

Side by Side Diff: samplecode/SampleCamera.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites Created 4 years, 9 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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 21 matching lines...) Expand all
32 for (int i = 0;; i++) { 32 for (int i = 0;; i++) {
33 SkString str; 33 SkString str;
34 str.printf("/skimages/elephant%d.jpeg", i); 34 str.printf("/skimages/elephant%d.jpeg", i);
35 SkBitmap bm; 35 SkBitmap bm;
36 if (SkImageDecoder::DecodeFile(str.c_str(), &bm)) { 36 if (SkImageDecoder::DecodeFile(str.c_str(), &bm)) {
37 SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm .height()) }; 37 SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm .height()) };
38 SkRect dst = { -150, -150, 150, 150 }; 38 SkRect dst = { -150, -150, 150, 150 };
39 SkMatrix matrix; 39 SkMatrix matrix;
40 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); 40 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
41 41
42 SkShader* s = SkShader::CreateBitmapShader(bm, 42 SkShader* s = SkShader::MakeBitmapShader(bm,
43 SkShader::kClamp_Tile Mode, 43 SkShader::kClamp_Tile Mode,
44 SkShader::kClamp_Tile Mode, 44 SkShader::kClamp_Tile Mode,
45 &matrix); 45 &matrix).release();
46 *fShaders.append() = s; 46 *fShaders.append() = s;
47 } else { 47 } else {
48 break; 48 break;
49 } 49 }
50 } 50 }
51 this->setBGColor(0xFFDDDDDD); 51 this->setBGColor(0xFFDDDDDD);
52 } 52 }
53 53
54 virtual ~CameraView() { 54 virtual ~CameraView() {
55 fShaders.unrefAll(); 55 fShaders.unrefAll();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 private: 101 private:
102 SkScalar fRX, fRY, fRZ; 102 SkScalar fRX, fRY, fRZ;
103 typedef SampleView INHERITED; 103 typedef SampleView INHERITED;
104 }; 104 };
105 105
106 ////////////////////////////////////////////////////////////////////////////// 106 //////////////////////////////////////////////////////////////////////////////
107 107
108 static SkView* MyFactory() { return new CameraView; } 108 static SkView* MyFactory() { return new CameraView; }
109 static SkViewRegister reg(MyFactory); 109 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698