| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkImageGenerator.h" | 8 #include "SkImageGenerator.h" |
| 9 #include "SkNextID.h" | 9 #include "SkNextID.h" |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return this->onGetYUV8Planes(sizes, planes, rowBytes); | 104 return this->onGetYUV8Planes(sizes, planes, rowBytes); |
| 105 } | 105 } |
| 106 | 106 |
| 107 GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subs
et) { | 107 GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subs
et) { |
| 108 if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subs
et)) { | 108 if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subs
et)) { |
| 109 return nullptr; | 109 return nullptr; |
| 110 } | 110 } |
| 111 return this->onGenerateTexture(ctx, subset); | 111 return this->onGenerateTexture(ctx, subset); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool SkImageGenerator::computeScaledDimensions(SkScalar scale, SupportedSizes* s
izes) { |
| 115 if (scale > 0 && scale <= 1) { |
| 116 return this->onComputeScaledDimensions(scale, sizes); |
| 117 } |
| 118 return false; |
| 119 } |
| 120 |
| 121 bool SkImageGenerator::generateScaledPixels(const SkISize& scaledSize, |
| 122 const SkIPoint& subsetOrigin, |
| 123 const SkPixmap& subsetPixels) { |
| 124 if (scaledSize.width() <= 0 || scaledSize.height() <= 0) { |
| 125 return false; |
| 126 } |
| 127 if (subsetPixels.width() <= 0 || subsetPixels.height() <= 0) { |
| 128 return false; |
| 129 } |
| 130 const SkIRect subset = SkIRect::MakeXYWH(subsetOrigin.x(), subsetOrigin.y(), |
| 131 subsetPixels.width(), subsetPixels.
height()); |
| 132 if (!SkIRect::MakeWH(scaledSize.width(), scaledSize.height()).contains(subse
t)) { |
| 133 return false; |
| 134 } |
| 135 return this->onGenerateScaledPixels(scaledSize, subsetOrigin, subsetPixels); |
| 136 } |
| 137 |
| 114 ////////////////////////////////////////////////////////////////////////////////
///////////// | 138 ////////////////////////////////////////////////////////////////////////////////
///////////// |
| 115 | 139 |
| 116 SkData* SkImageGenerator::onRefEncodedData() { | 140 SkData* SkImageGenerator::onRefEncodedData() { |
| 117 return nullptr; | 141 return nullptr; |
| 118 } | 142 } |
| 119 | 143 |
| 120 bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb
, | 144 bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb
, |
| 121 SkPMColor* colors, int* colorCount) { | 145 SkPMColor* colors, int* colorCount) { |
| 122 return false; | 146 return false; |
| 123 } | 147 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if (nullptr == data) { | 238 if (nullptr == data) { |
| 215 return nullptr; | 239 return nullptr; |
| 216 } | 240 } |
| 217 if (gFactory) { | 241 if (gFactory) { |
| 218 if (SkImageGenerator* generator = gFactory(data)) { | 242 if (SkImageGenerator* generator = gFactory(data)) { |
| 219 return generator; | 243 return generator; |
| 220 } | 244 } |
| 221 } | 245 } |
| 222 return SkImageGenerator::NewFromEncodedImpl(data); | 246 return SkImageGenerator::NewFromEncodedImpl(data); |
| 223 } | 247 } |
| OLD | NEW |