| OLD | NEW |
| 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 "gm.h" | 8 #include "gm.h" |
| 9 #include "SkSurface.h" | 9 #include "SkSurface.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 static const char* kLabel1 = "Original Img"; | 146 static const char* kLabel1 = "Original Img"; |
| 147 static const char* kLabel2 = "Modified Img"; | 147 static const char* kLabel2 = "Modified Img"; |
| 148 static const char* kLabel3 = "Cur Surface"; | 148 static const char* kLabel3 = "Cur Surface"; |
| 149 static const char* kLabel4 = "Full Crop"; | 149 static const char* kLabel4 = "Full Crop"; |
| 150 static const char* kLabel5 = "Over-crop"; | 150 static const char* kLabel5 = "Over-crop"; |
| 151 static const char* kLabel6 = "Upper-left"; | 151 static const char* kLabel6 = "Upper-left"; |
| 152 static const char* kLabel7 = "No Crop"; | 152 static const char* kLabel7 = "No Crop"; |
| 153 | 153 |
| 154 static const char* kLabel8 = "Pre-Alloc Img"; | 154 static const char* kLabel8 = "Pre-Alloc Img"; |
| 155 static const char* kLabel9 = "New Alloc Img"; | 155 static const char* kLabel9 = "New Alloc Img"; |
| 156 static const char* kLabel10 = "SkPicture"; | 156 static const char* kLabel10 = "Null Paint"; |
| 157 static const char* kLabel11 = "Null Paint"; | 157 static const char* kLabel11 = "GPU"; |
| 158 static const char* kLabel12 = "GPU"; | |
| 159 | 158 |
| 160 SkPaint textPaint; | 159 SkPaint textPaint; |
| 160 textPaint.setAntiAlias(true); |
| 161 textPaint.setTextSize(8); |
| 161 | 162 |
| 162 canvas->drawText(kLabel1, strlen(kLabel1), 10, 60, textPaint); | 163 canvas->drawText(kLabel1, strlen(kLabel1), 10, 60, textPaint); |
| 163 canvas->drawText(kLabel2, strlen(kLabel2), 10, 140, textPaint); | 164 canvas->drawText(kLabel2, strlen(kLabel2), 10, 140, textPaint); |
| 164 canvas->drawText(kLabel3, strlen(kLabel3), 10, 220, textPaint); | 165 canvas->drawText(kLabel3, strlen(kLabel3), 10, 220, textPaint); |
| 165 canvas->drawText(kLabel4, strlen(kLabel4), 10, 300, textPaint); | 166 canvas->drawText(kLabel4, strlen(kLabel4), 10, 300, textPaint); |
| 166 canvas->drawText(kLabel5, strlen(kLabel5), 10, 380, textPaint); | 167 canvas->drawText(kLabel5, strlen(kLabel5), 10, 380, textPaint); |
| 167 canvas->drawText(kLabel6, strlen(kLabel6), 10, 460, textPaint); | 168 canvas->drawText(kLabel6, strlen(kLabel6), 10, 460, textPaint); |
| 168 canvas->drawText(kLabel7, strlen(kLabel7), 10, 540, textPaint); | 169 canvas->drawText(kLabel7, strlen(kLabel7), 10, 540, textPaint); |
| 169 | 170 |
| 170 canvas->drawText(kLabel8, strlen(kLabel8), 80, 10, textPaint); | 171 canvas->drawText(kLabel8, strlen(kLabel8), 80, 10, textPaint); |
| 171 canvas->drawText(kLabel9, strlen(kLabel9), 160, 10, textPaint); | 172 canvas->drawText(kLabel9, strlen(kLabel9), 160, 10, textPaint); |
| 172 canvas->drawText(kLabel10, strlen(kLabel10), 250, 10, textPaint); | 173 canvas->drawText(kLabel10, strlen(kLabel10), 250, 10, textPaint); |
| 173 canvas->drawText(kLabel11, strlen(kLabel11), 320, 10, textPaint); | 174 canvas->drawText(kLabel11, strlen(kLabel11), 320, 10, textPaint); |
| 174 canvas->drawText(kLabel12, strlen(kLabel12), 410, 10, textPaint); | |
| 175 | 175 |
| 176 canvas->translate(80, 20); | 176 canvas->translate(80, 20); |
| 177 | 177 |
| 178 // since we draw into this directly, we need to start fresh | 178 // since we draw into this directly, we need to start fresh |
| 179 sk_bzero(fBuffer, fBufferSize); | 179 sk_bzero(fBuffer, fBufferSize); |
| 180 | 180 |
| 181 SkImageInfo info = SkImageInfo::MakeN32Premul(W, H); | 181 SkImageInfo info = SkImageInfo::MakeN32Premul(W, H); |
| 182 SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer,
RB)); | 182 SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer,
RB)); |
| 183 SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info)); | 183 SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info)); |
| 184 SkAutoTUnref<SkSurface> surf2(SkSurface::NewPicture(info.fWidth, info.fH
eight)); | |
| 185 SkAutoTUnref<SkSurface> surf3(SkSurface::NewPicture(info.fWidth, info.fH
eight)); | |
| 186 #if SK_SUPPORT_GPU | 184 #if SK_SUPPORT_GPU |
| 187 GrContext* ctx = canvas->getGrContext(); | 185 GrContext* ctx = canvas->getGrContext(); |
| 188 | 186 |
| 189 SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info, 0)); | 187 SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info, 0)); |
| 190 #endif | 188 #endif |
| 191 | 189 |
| 192 test_surface(canvas, surf0, true); | 190 test_surface(canvas, surf0, true); |
| 193 canvas->translate(80, 0); | 191 canvas->translate(80, 0); |
| 194 test_surface(canvas, surf1, true); | 192 test_surface(canvas, surf1, true); |
| 195 canvas->translate(80, 0); | |
| 196 test_surface(canvas, surf2, true); | |
| 197 canvas->translate(80, 0); | |
| 198 test_surface(canvas, surf3, false); | |
| 199 #if SK_SUPPORT_GPU | 193 #if SK_SUPPORT_GPU |
| 200 if (NULL != ctx) { | 194 if (NULL != ctx) { |
| 201 canvas->translate(80, 0); | 195 canvas->translate(80, 0); |
| 202 test_surface(canvas, surf4, true); | 196 test_surface(canvas, surf4, true); |
| 203 } | 197 } |
| 204 #endif | 198 #endif |
| 205 } | 199 } |
| 206 | 200 |
| 207 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 201 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 208 return GM::kSkipPicture_Flag | GM::kSkipPipe_Flag; | 202 return GM::kSkipPicture_Flag | GM::kSkipPipe_Flag; |
| 209 } | 203 } |
| 210 | 204 |
| 211 private: | 205 private: |
| 212 typedef skiagm::GM INHERITED; | 206 typedef skiagm::GM INHERITED; |
| 213 }; | 207 }; |
| 214 | 208 |
| 215 ////////////////////////////////////////////////////////////////////////////// | 209 ////////////////////////////////////////////////////////////////////////////// |
| 216 | 210 |
| 217 static skiagm::GM* MyFactory(void*) { return new ImageGM; } | 211 static skiagm::GM* MyFactory(void*) { return new ImageGM; } |
| 218 static skiagm::GMRegistry reg(MyFactory); | 212 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |