| 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" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkGradientShader.h" | 12 #include "SkGradientShader.h" |
| 13 #include "SkImage.h" | 13 #include "SkImage.h" |
| 14 #include "SkImage_Base.h" |
| 14 #include "SkShader.h" | 15 #include "SkShader.h" |
| 15 #include "SkSurface.h" | 16 #include "SkSurface.h" |
| 16 | 17 |
| 17 #if SK_SUPPORT_GPU | 18 #if SK_SUPPORT_GPU |
| 18 #include "SkGr.h" | 19 #include "SkGr.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 static SkBitmap make_chessbm(int w, int h) { | 22 static SkBitmap make_chessbm(int w, int h) { |
| 22 SkBitmap bm; | 23 SkBitmap bm; |
| 23 bm.allocN32Pixels(w, h); | 24 bm.allocN32Pixels(w, h); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 canvas->drawRect(rect, paint); | 79 canvas->drawRect(rect, paint); |
| 79 rect.inset(wScalar / 8, hScalar / 8); | 80 rect.inset(wScalar / 8, hScalar / 8); |
| 80 mat.postScale(SK_Scalar1 / 4, SK_Scalar1 / 4); | 81 mat.postScale(SK_Scalar1 / 4, SK_Scalar1 / 4); |
| 81 } | 82 } |
| 82 | 83 |
| 83 SkImage* image = surface->newImageSnapshot(); | 84 SkImage* image = surface->newImageSnapshot(); |
| 84 | 85 |
| 85 SkBitmap tempBM; | 86 SkBitmap tempBM; |
| 86 | 87 |
| 87 #if SK_SUPPORT_GPU | 88 #if SK_SUPPORT_GPU |
| 88 if (image->getTexture()) { | 89 if (GrTexture* texture = as_IB(image)->peekTexture()) { |
| 89 GrWrapTextureInBitmap(image->getTexture(), | 90 GrWrapTextureInBitmap(texture, image->width(), image->height(), image->i
sOpaque(), &tempBM); |
| 90 image->width(), image->height(), image->isOpaque()
, &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 |
| (...skipping 119 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 |