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

Side by Side Diff: gm/bitmapscroll.cpp

Issue 140593005: add legacy/helper allocN32Pixels, and convert gm to use it (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/bitmaprecttest.cpp ('k') | gm/bitmapshader.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 "gm.h" 8 #include "gm.h"
9 9
10 namespace skiagm { 10 namespace skiagm {
11 11
12 /** Create a bitmap image suitable for testing SkBitmap::scrollRect(). 12 /** Create a bitmap image suitable for testing SkBitmap::scrollRect().
13 * 13 *
14 * @param quarterWidth bitmap will be 4x this many pixels wide 14 * @param quarterWidth bitmap will be 4x this many pixels wide
15 * @param quarterHeight bitmap will be 4x this many pixels tall 15 * @param quarterHeight bitmap will be 4x this many pixels tall
16 * @param bitmap the bitmap data is written into this object 16 * @param bitmap the bitmap data is written into this object
17 */ 17 */
18 static void make_bitmap(int quarterWidth, int quarterHeight, SkBitmap *bitmap) { 18 static void make_bitmap(int quarterWidth, int quarterHeight, SkBitmap *bitmap) {
19 SkPaint pRed, pWhite, pGreen, pBlue, pLine, pAlphaGray; 19 SkPaint pRed, pWhite, pGreen, pBlue, pLine, pAlphaGray;
20 pRed.setColor(0xFFFF9999); 20 pRed.setColor(0xFFFF9999);
21 pWhite.setColor(0xFFFFFFFF); 21 pWhite.setColor(0xFFFFFFFF);
22 pGreen.setColor(0xFF99FF99); 22 pGreen.setColor(0xFF99FF99);
23 pBlue.setColor(0xFF9999FF); 23 pBlue.setColor(0xFF9999FF);
24 pLine.setColor(0xFF000000); 24 pLine.setColor(0xFF000000);
25 pLine.setStyle(SkPaint::kStroke_Style); 25 pLine.setStyle(SkPaint::kStroke_Style);
26 pAlphaGray.setColor(0x66888888); 26 pAlphaGray.setColor(0x66888888);
27 27
28 // Prepare bitmap, and a canvas that draws into it. 28 // Prepare bitmap, and a canvas that draws into it.
29 bitmap->reset(); 29 bitmap->allocN32Pixels(quarterWidth*4, quarterHeight*4);
30 bitmap->setConfig(SkBitmap::kARGB_8888_Config,
31 quarterWidth*4, quarterHeight*4);
32 bitmap->allocPixels();
33 SkCanvas canvas(*bitmap); 30 SkCanvas canvas(*bitmap);
34 31
35 SkScalar w = SkIntToScalar(quarterWidth); 32 SkScalar w = SkIntToScalar(quarterWidth);
36 SkScalar h = SkIntToScalar(quarterHeight); 33 SkScalar h = SkIntToScalar(quarterHeight);
37 canvas.drawRectCoords( 0, 0, w*2, h*2, pRed); 34 canvas.drawRectCoords( 0, 0, w*2, h*2, pRed);
38 canvas.drawRectCoords(w*2, 0, w*4, h*2, pGreen); 35 canvas.drawRectCoords(w*2, 0, w*4, h*2, pGreen);
39 canvas.drawRectCoords( 0, h*2, w*2, h*4, pBlue); 36 canvas.drawRectCoords( 0, h*2, w*2, h*4, pBlue);
40 canvas.drawRectCoords(w*2, h*2, w*4, h*4, pWhite); 37 canvas.drawRectCoords(w*2, h*2, w*4, h*4, pWhite);
41 canvas.drawRectCoords(w, h, w*3, h*3, pAlphaGray); 38 canvas.drawRectCoords(w, h, w*3, h*3, pAlphaGray);
42 canvas.drawLine(w*2, 0, w*2, h*4, pLine); 39 canvas.drawLine(w*2, 0, w*2, h*4, pLine);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 static const int quarterHeight = 14; 145 static const int quarterHeight = 14;
149 SkBitmap origBitmap; 146 SkBitmap origBitmap;
150 }; 147 };
151 148
152 ////////////////////////////////////////////////////////////////////////////// 149 //////////////////////////////////////////////////////////////////////////////
153 150
154 static GM* MyFactory(void*) { return new BitmapScrollGM; } 151 static GM* MyFactory(void*) { return new BitmapScrollGM; }
155 static GMRegistry reg(MyFactory); 152 static GMRegistry reg(MyFactory);
156 153
157 } 154 }
OLDNEW
« no previous file with comments | « gm/bitmaprecttest.cpp ('k') | gm/bitmapshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698