OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 bmdst.eraseColor(0xFFFFFFFF); | 54 bmdst.eraseColor(0xFFFFFFFF); |
55 SkPixmap pmdst; | 55 SkPixmap pmdst; |
56 bmdst.peekPixels(&pmdst); | 56 bmdst.peekPixels(&pmdst); |
57 | 57 |
58 SkImageInfo info = SkImageInfo::MakeN32Premul(ir.width(), ir.height(), kLine
ar_SkColorProfileType); | 58 SkImageInfo info = SkImageInfo::MakeN32Premul(ir.width(), ir.height(), kLine
ar_SkColorProfileType); |
59 | 59 |
60 SkAutoTUnref<SkImage> image{SkImage::NewRasterCopy( | 60 SkAutoTUnref<SkImage> image{SkImage::NewRasterCopy( |
61 info, pmsrc.addr32(), pmsrc.rowBytes())}; | 61 info, pmsrc.addr32(), pmsrc.rowBytes())}; |
62 SkPaint paint; | 62 SkPaint paint; |
63 int32_t storage[300]; | 63 int32_t storage[300]; |
64 SkShader* shader = image->newShader(SkShader::kClamp_TileMode, SkShader::kCl
amp_TileMode); | 64 paint.setShader(image->makeShader(SkShader::kClamp_TileMode, SkShader::kClam
p_TileMode)); |
65 if (useBilerp) { | 65 if (useBilerp) { |
66 paint.setFilterQuality(SkFilterQuality::kLow_SkFilterQuality); | 66 paint.setFilterQuality(SkFilterQuality::kLow_SkFilterQuality); |
67 } else { | 67 } else { |
68 paint.setFilterQuality(SkFilterQuality::kNone_SkFilterQuality); | 68 paint.setFilterQuality(SkFilterQuality::kNone_SkFilterQuality); |
69 } | 69 } |
70 paint.setShader(shader)->unref(); | |
71 const SkShader::ContextRec rec(paint, *mat, nullptr, | 70 const SkShader::ContextRec rec(paint, *mat, nullptr, |
72 SkBlitter::PreferredShaderDest(pmsrc.info()))
; | 71 SkBlitter::PreferredShaderDest(pmsrc.info()))
; |
73 SkASSERT(paint.getShader()->contextSize(rec) <= sizeof(storage)); | 72 SkASSERT(paint.getShader()->contextSize(rec) <= sizeof(storage)); |
74 | 73 |
75 SkShader::Context* ctx = paint.getShader()->createContext(rec, storage); | 74 SkShader::Context* ctx = paint.getShader()->createContext(rec, storage); |
76 | 75 |
77 for (int y = 0; y < ir.height(); y++) { | 76 for (int y = 0; y < ir.height(); y++) { |
78 ctx->shadeSpan(0, y, pmdst.writable_addr32(0, y), ir.width()); | 77 ctx->shadeSpan(0, y, pmdst.writable_addr32(0, y), ir.width()); |
79 } | 78 } |
80 | 79 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 193 } |
195 canvas->restore(); | 194 canvas->restore(); |
196 canvas->translate(0, H + 20); | 195 canvas->translate(0, H + 20); |
197 } | 196 } |
198 canvas->restore(); | 197 canvas->restore(); |
199 canvas->translate(0, (H + 20) * SK_ARRAY_COUNT(mats)); | 198 canvas->translate(0, (H + 20) * SK_ARRAY_COUNT(mats)); |
200 if (useBilerp) break; | 199 if (useBilerp) break; |
201 useBilerp = true; | 200 useBilerp = true; |
202 } | 201 } |
203 } | 202 } |
OLD | NEW |