OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SubsetZoomBench.h" | 8 #include "SubsetZoomBench.h" |
9 #include "SubsetBenchPriv.h" | 9 #include "SubsetBenchPriv.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 int w = fSubsetWidth; | 70 int w = fSubsetWidth; |
71 int h = fSubsetHeight; | 71 int h = fSubsetHeight; |
72 do { | 72 do { |
73 const int subsetStartX = SkTMax(0, centerX - w / 2); | 73 const int subsetStartX = SkTMax(0, centerX - w / 2); |
74 const int subsetStartY = SkTMax(0, centerY - h / 2); | 74 const int subsetStartY = SkTMax(0, centerY - h / 2); |
75 const int subsetWidth = SkTMin(w, info.width() - subsetStartX); | 75 const int subsetWidth = SkTMin(w, info.width() - subsetStartX); |
76 const int subsetHeight = SkTMin(h, info.height() - subsetStartY)
; | 76 const int subsetHeight = SkTMin(h, info.height() - subsetStartY)
; |
77 // Note that if we subsetted and scaled in a single step, we cou
ld use the | 77 // Note that if we subsetted and scaled in a single step, we cou
ld use the |
78 // same bitmap - as is often done in actual use cases. | 78 // same bitmap - as is often done in actual use cases. |
79 SkBitmap bitmap; | 79 SkBitmap bitmap; |
80 bitmap.allocPixels(info.makeWH(subsetWidth, subsetHeight)); | 80 SkImageInfo subsetInfo = info.makeWH(subsetWidth, subsetHeight); |
| 81 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
81 | 82 |
82 uint32_t bpp = info.bytesPerPixel(); | 83 uint32_t bpp = info.bytesPerPixel(); |
83 scanlineDecoder->skipScanlines(subsetStartY); | 84 scanlineDecoder->skipScanlines(subsetStartY); |
84 for (int y = 0; y < subsetHeight; y++) { | 85 for (int y = 0; y < subsetHeight; y++) { |
85 scanlineDecoder->getScanlines(row.get(), 1, 0); | 86 scanlineDecoder->getScanlines(row.get(), 1, 0); |
86 memcpy(bitmap.getAddr(0, y), row.get() + subsetStartX * bpp, | 87 memcpy(bitmap.getAddr(0, y), row.get() + subsetStartX * bpp, |
87 subsetWidth * bpp); | 88 subsetWidth * bpp); |
88 } | 89 } |
89 w <<= 1; | 90 w <<= 1; |
90 h <<= 1; | 91 h <<= 1; |
(...skipping 17 matching lines...) Expand all Loading... |
108 SkBitmap bitmap; | 109 SkBitmap bitmap; |
109 SkIRect rect = SkIRect::MakeXYWH(subsetStartX, subsetStartY, sub
setWidth, | 110 SkIRect rect = SkIRect::MakeXYWH(subsetStartX, subsetStartY, sub
setWidth, |
110 subsetHeight); | 111 subsetHeight); |
111 decoder->decodeSubset(&bitmap, rect, fColorType); | 112 decoder->decodeSubset(&bitmap, rect, fColorType); |
112 w <<= 1; | 113 w <<= 1; |
113 h <<= 1; | 114 h <<= 1; |
114 } while (w < 2 * width || h < 2 * height); | 115 } while (w < 2 * width || h < 2 * height); |
115 } | 116 } |
116 } | 117 } |
117 } | 118 } |
OLD | NEW |