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

Side by Side Diff: tests/GpuBitmapCopyTest.cpp

Issue 168653002: Change device factories to take SkImageInfo instead of SkBitmap::Config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix PdfViewer 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 | « tests/CanvasStateTest.cpp ('k') | tests/ImageFilterTest.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 2012 Google Inc. 3 * Copyright 2012 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 8
9 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 GrContext* grContext = factory->get(glType); 115 GrContext* grContext = factory->get(glType);
116 if (NULL == grContext) { 116 if (NULL == grContext) {
117 continue; 117 continue;
118 } 118 }
119 119
120 120
121 if (NULL == grContext) { 121 if (NULL == grContext) {
122 return; 122 return;
123 } 123 }
124 static const Pair gPairs[] = { 124 static const Pair gPairs[] = {
125 { SkBitmap::kNo_Config, "00" }, 125 // SkGpuDevice can no longer be Create()ed with kNo_Config
126 { SkBitmap::kARGB_8888_Config, "01" }, 126 // (or kUnknown_SkColorType in the new world), hence much of this
127 // test will be skipped, since it was checking that calling
128 // copyTo or deepCopyTo with src or dst set to kUnknown/kNo would
129 // successfully fail.
130 //
131 // If we can declare that you can *never* create a texture with
132 // kUnknown, then perhaps we can remove this entire test...
133 //
134 // { SkBitmap::kNo_Config, "00" },
135 // { SkBitmap::kARGB_8888_Config, "01" },
136 { SkBitmap::kARGB_8888_Config, "1" },
127 }; 137 };
128 138
129 const int W = 20; 139 const int W = 20;
130 const int H = 33; 140 const int H = 33;
131 141
132 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) { 142 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) {
143 SkImageInfo info = SkImageInfo::Make(W, H,
144 SkBitmapConfigToColorType(gPair s[i].fConfig),
145 kPremul_SkAlphaType);
133 SkBitmap src, dst; 146 SkBitmap src, dst;
134 147
135 SkGpuDevice* device = SkNEW_ARGS(SkGpuDevice, (grContext, gPairs[i]. fConfig, W, H)); 148 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(grContext, info , 0));
136 SkAutoUnref aur(device); 149 SkASSERT(device.get());
150
137 src = device->accessBitmap(false); 151 src = device->accessBitmap(false);
138 device->clear(SK_ColorWHITE); 152 device->clear(SK_ColorWHITE);
139 153
140 // Draw something different to the same portion of the bitmap that w e will extract as a 154 // Draw something different to the same portion of the bitmap that w e will extract as a
141 // subset, so that comparing the pixels of the subset will be meanin gful. 155 // subset, so that comparing the pixels of the subset will be meanin gful.
142 SkIRect subsetRect = SkIRect::MakeLTRB(W/2, H/2, W, H); 156 SkIRect subsetRect = SkIRect::MakeLTRB(W/2, H/2, W, H);
143 SkCanvas drawingCanvas(device); 157 SkCanvas drawingCanvas(device);
144 SkPaint paint; 158 SkPaint paint;
145 paint.setColor(SK_ColorRED); 159 paint.setColor(SK_ColorRED);
146 drawingCanvas.drawRect(SkRect::Make(subsetRect), paint); 160 drawingCanvas.drawRect(SkRect::Make(subsetRect), paint);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 REPORTER_ASSERT(reporter, success == canSucceed); 226 REPORTER_ASSERT(reporter, success == canSucceed);
213 TestIndividualCopy(reporter, gPairs[j].fConfig, success, tru eSubset, subsetCopy, 227 TestIndividualCopy(reporter, gPairs[j].fConfig, success, tru eSubset, subsetCopy,
214 true); 228 true);
215 } 229 }
216 } // for (size_t j = ... 230 } // for (size_t j = ...
217 } // for (size_t i = ... 231 } // for (size_t i = ...
218 } // GrContextFactory::GLContextType 232 } // GrContextFactory::GLContextType
219 } 233 }
220 234
221 #endif 235 #endif
OLDNEW
« no previous file with comments | « tests/CanvasStateTest.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698