| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "SkGr.h" | 8 #include "SkGr.h" |
| 9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
| 10 #include "SkConfig8888.h" | 10 #include "SkConfig8888.h" |
| 11 #include "SkData.h" | 11 #include "SkData.h" |
| 12 #include "SkMessageBus.h" | 12 #include "SkMessageBus.h" |
| 13 #include "SkPixelRef.h" | 13 #include "SkPixelRef.h" |
| 14 #include "SkTextureCompressor.h" |
| 14 #include "GrResourceCache.h" | 15 #include "GrResourceCache.h" |
| 15 #include "GrGpu.h" | 16 #include "GrGpu.h" |
| 16 #include "effects/GrDitherEffect.h" | 17 #include "effects/GrDitherEffect.h" |
| 17 #include "GrDrawTargetCaps.h" | 18 #include "GrDrawTargetCaps.h" |
| 18 #include "effects/GrYUVtoRGBEffect.h" | 19 #include "effects/GrYUVtoRGBEffect.h" |
| 19 | 20 |
| 20 #ifndef SK_IGNORE_ETC1_SUPPORT | 21 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 21 # include "ktx.h" | 22 # include "ktx.h" |
| 22 # include "etc1.h" | 23 # include "etc1.h" |
| 23 #endif | 24 #endif |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return NULL; | 159 return NULL; |
| 159 } | 160 } |
| 160 | 161 |
| 161 // Everything seems good... skip ahead to the data. | 162 // Everything seems good... skip ahead to the data. |
| 162 bytes += ETC_PKM_HEADER_SIZE; | 163 bytes += ETC_PKM_HEADER_SIZE; |
| 163 desc.fConfig = kETC1_GrPixelConfig; | 164 desc.fConfig = kETC1_GrPixelConfig; |
| 164 } else if (SkKTXFile::is_ktx(bytes)) { | 165 } else if (SkKTXFile::is_ktx(bytes)) { |
| 165 SkKTXFile ktx(data); | 166 SkKTXFile ktx(data); |
| 166 | 167 |
| 167 // Is it actually an ETC1 texture? | 168 // Is it actually an ETC1 texture? |
| 168 if (!ktx.isETC1()) { | 169 if (!ktx.isCompressedFormat(SkTextureCompressor::kETC1_Format)) { |
| 169 return NULL; | 170 return NULL; |
| 170 } | 171 } |
| 171 | 172 |
| 172 // Does the data match the dimensions of the bitmap? If not, | 173 // Does the data match the dimensions of the bitmap? If not, |
| 173 // then we don't know how to scale the image to match it... | 174 // then we don't know how to scale the image to match it... |
| 174 if (ktx.width() != bm.width() || ktx.height() != bm.height()) { | 175 if (ktx.width() != bm.width() || ktx.height() != bm.height()) { |
| 175 return NULL; | 176 return NULL; |
| 176 } | 177 } |
| 177 | 178 |
| 178 bytes = ktx.pixelData(); | 179 bytes = ktx.pixelData(); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) &&
NULL != effect) { | 617 if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) &&
NULL != effect) { |
| 617 grPaint->addColorEffect(effect)->unref(); | 618 grPaint->addColorEffect(effect)->unref(); |
| 618 constantColor = false; | 619 constantColor = false; |
| 619 } | 620 } |
| 620 } | 621 } |
| 621 | 622 |
| 622 // The grcolor is automatically set when calling asneweffect. | 623 // The grcolor is automatically set when calling asneweffect. |
| 623 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. | 624 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. |
| 624 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
); | 625 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
); |
| 625 } | 626 } |
| OLD | NEW |