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

Side by Side Diff: samplecode/SampleBlur.cpp

Issue 26709002: Revert "change SkColorTable to be immutable" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkColorTable.h ('k') | samplecode/SampleDitherBitmap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
13 #include "SkGradientShader.h" 13 #include "SkGradientShader.h"
14 #include "SkUtils.h" 14 #include "SkUtils.h"
15 #include "SkView.h" 15 #include "SkView.h"
16 16
17 static SkBitmap make_bitmap() { 17 static SkBitmap make_bitmap() {
18 SkPMColor c[256]; 18 SkBitmap bm;
19 SkColorTable* ctable = new SkColorTable(256);
20
21 SkPMColor* c = ctable->lockColors();
19 for (int i = 0; i < 256; i++) { 22 for (int i = 0; i < 256; i++) {
20 c[i] = SkPackARGB32(255 - i, 0, 0, 0); 23 c[i] = SkPackARGB32(255 - i, 0, 0, 0);
21 } 24 }
22 25 ctable->unlockColors(true);
23 SkBitmap bm;
24 SkColorTable* ctable = new SkColorTable(c, 256);
25
26 bm.setConfig(SkBitmap::kIndex8_Config, 256, 256); 26 bm.setConfig(SkBitmap::kIndex8_Config, 256, 256);
27 bm.allocPixels(ctable); 27 bm.allocPixels(ctable);
28 ctable->unref(); 28 ctable->unref();
29 29
30 bm.lockPixels(); 30 bm.lockPixels();
31 const float cx = bm.width() * 0.5f; 31 const float cx = bm.width() * 0.5f;
32 const float cy = bm.height() * 0.5f; 32 const float cy = bm.height() * 0.5f;
33 for (int y = 0; y < bm.height(); y++) { 33 for (int y = 0; y < bm.height(); y++) {
34 float dy = y - cy; 34 float dy = y - cy;
35 dy *= dy; 35 dy *= dy;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 private: 134 private:
135 typedef SkView INHERITED; 135 typedef SkView INHERITED;
136 }; 136 };
137 137
138 ////////////////////////////////////////////////////////////////////////////// 138 //////////////////////////////////////////////////////////////////////////////
139 139
140 static SkView* MyFactory() { return new BlurView; } 140 static SkView* MyFactory() { return new BlurView; }
141 static SkViewRegister reg(MyFactory); 141 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/core/SkColorTable.h ('k') | samplecode/SampleDitherBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698