| 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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
| 10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 for (int x = 0; x < bm.width(); x++) { | 28 for (int x = 0; x < bm.width(); x++) { |
| 29 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK; | 29 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK; |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 bm.unlockPixels(); | 32 bm.unlockPixels(); |
| 33 return bm; | 33 return bm; |
| 34 } | 34 } |
| 35 | 35 |
| 36 static sk_sp<SkImage> makebm(SkCanvas* origCanvas, SkBitmap* resultBM, int w, in
t h) { | 36 static sk_sp<SkImage> makebm(SkCanvas* origCanvas, SkBitmap* resultBM, int w, in
t h) { |
| 37 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); | 37 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); |
| 38 | 38 |
| 39 auto surface(origCanvas->makeSurface(info)); | 39 auto surface(origCanvas->makeSurface(info)); |
| 40 if (nullptr == surface) { | 40 if (nullptr == surface) { |
| 41 // picture canvas will return null, so fall-back to raster | 41 // picture canvas will return null, so fall-back to raster |
| 42 surface = SkSurface::MakeRaster(info); | 42 surface = SkSurface::MakeRaster(info); |
| 43 } | 43 } |
| 44 | 44 |
| 45 SkCanvas* canvas = surface->getCanvas(); | 45 SkCanvas* canvas = surface->getCanvas(); |
| 46 | 46 |
| 47 canvas->clear(SK_ColorTRANSPARENT); | 47 canvas->clear(SK_ColorTRANSPARENT); |
| 48 | 48 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 mat.postScale(SK_Scalar1 / 4, SK_Scalar1 / 4); | 81 mat.postScale(SK_Scalar1 / 4, SK_Scalar1 / 4); |
| 82 } | 82 } |
| 83 | 83 |
| 84 auto image = surface->makeImageSnapshot(); | 84 auto image = surface->makeImageSnapshot(); |
| 85 | 85 |
| 86 SkBitmap tempBM; | 86 SkBitmap tempBM; |
| 87 | 87 |
| 88 #if SK_SUPPORT_GPU | 88 #if SK_SUPPORT_GPU |
| 89 if (GrTexture* texture = as_IB(image)->peekTexture()) { | 89 if (GrTexture* texture = as_IB(image)->peekTexture()) { |
| 90 GrWrapTextureInBitmap(texture, image->width(), image->height(), image->i
sOpaque(), &tempBM); | 90 GrWrapTextureInBitmap(texture, image->width(), image->height(), image->i
sOpaque(), &tempBM); |
| 91 } else | 91 } else |
| 92 #endif | 92 #endif |
| 93 { | 93 { |
| 94 image->asLegacyBitmap(&tempBM, SkImage::kRO_LegacyBitmapMode); | 94 image->asLegacyBitmap(&tempBM, SkImage::kRO_LegacyBitmapMode); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Let backends know we won't change this, so they don't have to deep copy i
t defensively. | 97 // Let backends know we won't change this, so they don't have to deep copy i
t defensively. |
| 98 tempBM.setImmutable(); | 98 tempBM.setImmutable(); |
| 99 *resultBM = tempBM; | 99 *resultBM = tempBM; |
| 100 | 100 |
| 101 return image; | 101 return image; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 canvas->drawBitmapRect(bm, srcRect, dstRect, &paint); | 220 canvas->drawBitmapRect(bm, srcRect, dstRect, &paint); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 private: | 224 private: |
| 225 typedef skiagm::GM INHERITED; | 225 typedef skiagm::GM INHERITED; |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 DEF_GM( return new DrawBitmapRectGM(canvasproc, nullptr); ) | 228 DEF_GM( return new DrawBitmapRectGM(canvasproc, nullptr); ) |
| 229 DEF_GM( return new DrawBitmapRectGM(imageproc, "-imagerect"); ) | 229 DEF_GM( return new DrawBitmapRectGM(imageproc, "-imagerect"); ) |
| OLD | NEW |