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

Side by Side Diff: gm/bitmapscroll.cpp

Issue 171723007: add new copyTo version to SkBitmap, which takes SkColorType (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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/bitmapfilters.cpp ('k') | gm/copyTo4444.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 {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Figure out the (x,y) to draw this copy at 122 // Figure out the (x,y) to draw this copy at
123 SkScalar bitmapX = SkIntToScalar( 123 SkScalar bitmapX = SkIntToScalar(
124 x + quarterWidth * 5 * (xMult+1)); 124 x + quarterWidth * 5 * (xMult+1));
125 SkScalar bitmapY = SkIntToScalar( 125 SkScalar bitmapY = SkIntToScalar(
126 y + quarterHeight * 5 * (yMult+1)); 126 y + quarterHeight * 5 * (yMult+1));
127 127
128 // Scroll a new copy of the bitmap, and then draw it. 128 // Scroll a new copy of the bitmap, and then draw it.
129 // scrollRect() should always return true, even if it's a no-op 129 // scrollRect() should always return true, even if it's a no-op
130 SkBitmap scrolledBitmap; 130 SkBitmap scrolledBitmap;
131 SkDEBUGCODE(bool copyToReturnValue = )origBitmap.copyTo( 131 SkDEBUGCODE(bool copyToReturnValue = )origBitmap.copyTo(
132 &scrolledBitmap, origBitmap.config()); 132 &scrolledBitmap, origBitmap.colorType());
133 SkASSERT(copyToReturnValue); 133 SkASSERT(copyToReturnValue);
134 SkDEBUGCODE(bool scrollRectReturnValue = )scrolledBitmap.scrollR ect( 134 SkDEBUGCODE(bool scrollRectReturnValue = )scrolledBitmap.scrollR ect(
135 subset, scrollX * xMult, scrollY * yMult); 135 subset, scrollX * xMult, scrollY * yMult);
136 SkASSERT(scrollRectReturnValue); 136 SkASSERT(scrollRectReturnValue);
137 canvas->drawBitmap(scrolledBitmap, bitmapX, bitmapY); 137 canvas->drawBitmap(scrolledBitmap, bitmapX, bitmapY);
138 } 138 }
139 } 139 }
140 } 140 }
141 141
142 private: 142 private:
143 typedef GM INHERITED; 143 typedef GM INHERITED;
144 static const int quarterWidth = 10; 144 static const int quarterWidth = 10;
145 static const int quarterHeight = 14; 145 static const int quarterHeight = 14;
146 SkBitmap origBitmap; 146 SkBitmap origBitmap;
147 }; 147 };
148 148
149 ////////////////////////////////////////////////////////////////////////////// 149 //////////////////////////////////////////////////////////////////////////////
150 150
151 static GM* MyFactory(void*) { return new BitmapScrollGM; } 151 static GM* MyFactory(void*) { return new BitmapScrollGM; }
152 static GMRegistry reg(MyFactory); 152 static GMRegistry reg(MyFactory);
153 153
154 } 154 }
OLDNEW
« no previous file with comments | « gm/bitmapfilters.cpp ('k') | gm/copyTo4444.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698