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 "SkTableColorFilter.h" | 8 #include "SkTableColorFilter.h" |
9 | 9 |
10 #include "GrContext.h" | |
11 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
12 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
13 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
14 #include "SkString.h" | 13 #include "SkString.h" |
15 #include "SkUnPreMultiply.h" | 14 #include "SkUnPreMultiply.h" |
16 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
17 | 16 |
18 class SkTable_ColorFilter : public SkColorFilter { | 17 class SkTable_ColorFilter : public SkColorFilter { |
19 public: | 18 public: |
20 SkTable_ColorFilter(const uint8_t tableA[], const uint8_t tableR[], | 19 SkTable_ColorFilter(const uint8_t tableA[], const uint8_t tableR[], |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 459 |
461 /////////////////////////////////////////////////////////////////////////////// | 460 /////////////////////////////////////////////////////////////////////////////// |
462 const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap
bitmap, | 461 const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap
bitmap, |
463 unsigned flags) { | 462 unsigned flags) { |
464 | 463 |
465 GrTextureStripAtlas::Desc desc; | 464 GrTextureStripAtlas::Desc desc; |
466 desc.fWidth = bitmap.width(); | 465 desc.fWidth = bitmap.width(); |
467 desc.fHeight = 128; | 466 desc.fHeight = 128; |
468 desc.fRowHeight = bitmap.height(); | 467 desc.fRowHeight = bitmap.height(); |
469 desc.fContext = context; | 468 desc.fContext = context; |
470 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *context->caps()); | 469 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info()); |
471 GrTextureStripAtlas* atlas = GrTextureStripAtlas::GetAtlas(desc); | 470 GrTextureStripAtlas* atlas = GrTextureStripAtlas::GetAtlas(desc); |
472 int row = atlas->lockRow(bitmap); | 471 int row = atlas->lockRow(bitmap); |
473 SkAutoTUnref<GrTexture> texture; | 472 SkAutoTUnref<GrTexture> texture; |
474 if (-1 == row) { | 473 if (-1 == row) { |
475 atlas = nullptr; | 474 atlas = nullptr; |
476 texture.reset(GrRefCachedBitmapTexture(context, bitmap, GrTextureParams:
:ClampNoFilter())); | 475 texture.reset(GrRefCachedBitmapTexture(context, bitmap, GrTextureParams:
:ClampNoFilter())); |
477 } else { | 476 } else { |
478 texture.reset(SkRef(atlas->getTexture())); | 477 texture.reset(SkRef(atlas->getTexture())); |
479 } | 478 } |
480 | 479 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 593 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
595 const uint8_t tableR[256], | 594 const uint8_t tableR[256], |
596 const uint8_t tableG[256], | 595 const uint8_t tableG[256], |
597 const uint8_t tableB[256]) { | 596 const uint8_t tableB[256]) { |
598 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); | 597 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); |
599 } | 598 } |
600 | 599 |
601 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 600 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
602 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 601 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
603 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 602 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |