OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 #ifndef SkBitmap_DEFINED | 8 #ifndef SkBitmap_DEFINED |
9 #define SkBitmap_DEFINED | 9 #define SkBitmap_DEFINED |
10 | 10 |
11 #include "SkColor.h" | 11 #include "SkColor.h" |
12 #include "SkColorTable.h" | 12 #include "SkColorTable.h" |
13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
14 #include "SkPixmap.h" | 14 #include "SkPixmap.h" |
15 #include "SkPoint.h" | 15 #include "SkPoint.h" |
16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
17 | 17 |
18 struct SkMask; | 18 struct SkMask; |
19 struct SkIRect; | 19 struct SkIRect; |
20 struct SkRect; | 20 struct SkRect; |
21 class SkPaint; | 21 class SkPaint; |
22 class SkPixelRef; | 22 class SkPixelRef; |
23 class SkPixelRefFactory; | 23 class SkPixelRefFactory; |
24 class SkRegion; | 24 class SkRegion; |
25 class SkString; | 25 class SkString; |
| 26 |
| 27 #ifdef SK_SUPPORT_LEGACY_BITMAP_GETTEXTURE |
26 class GrTexture; | 28 class GrTexture; |
| 29 #endif |
27 | 30 |
28 /** \class SkBitmap | 31 /** \class SkBitmap |
29 | 32 |
30 The SkBitmap class specifies a raster bitmap. A bitmap has an integer width | 33 The SkBitmap class specifies a raster bitmap. A bitmap has an integer width |
31 and height, and a format (colortype), and a pointer to the actual pixels. | 34 and height, and a format (colortype), and a pointer to the actual pixels. |
32 Bitmaps can be drawn into a SkCanvas, but they are also used to specify the | 35 Bitmaps can be drawn into a SkCanvas, but they are also used to specify the |
33 target of a SkCanvas' drawing operations. | 36 target of a SkCanvas' drawing operations. |
34 A const SkBitmap exposes getAddr(), which lets a caller write its pixels; | 37 A const SkBitmap exposes getAddr(), which lets a caller write its pixels; |
35 the constness is considered to apply to the bitmap's configuration, not | 38 the constness is considered to apply to the bitmap's configuration, not |
36 its contents. | 39 its contents. |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 464 |
462 /** Call this to be sure that the bitmap is valid enough to be drawn (i.e. | 465 /** Call this to be sure that the bitmap is valid enough to be drawn (i.e. |
463 it has non-null pixels, and if required by its colortype, it has a | 466 it has non-null pixels, and if required by its colortype, it has a |
464 non-null colortable. Returns true if all of the above are met. | 467 non-null colortable. Returns true if all of the above are met. |
465 */ | 468 */ |
466 bool readyToDraw() const { | 469 bool readyToDraw() const { |
467 return this->getPixels() != NULL && | 470 return this->getPixels() != NULL && |
468 (this->colorType() != kIndex_8_SkColorType || fColorTable); | 471 (this->colorType() != kIndex_8_SkColorType || fColorTable); |
469 } | 472 } |
470 | 473 |
471 /** Returns the pixelRef's texture, or NULL | 474 #ifdef SK_SUPPORT_LEGACY_BITMAP_GETTEXTURE |
472 */ | 475 GrTexture* getTexture() const { return nullptr; } |
473 GrTexture* getTexture() const; | 476 #endif |
474 | 477 |
475 /** Return the bitmap's colortable, if it uses one (i.e. colorType is | 478 /** Return the bitmap's colortable, if it uses one (i.e. colorType is |
476 Index_8) and the pixels are locked. | 479 Index_8) and the pixels are locked. |
477 Otherwise returns NULL. Does not affect the colortable's | 480 Otherwise returns NULL. Does not affect the colortable's |
478 reference count. | 481 reference count. |
479 */ | 482 */ |
480 SkColorTable* getColorTable() const { return fColorTable; } | 483 SkColorTable* getColorTable() const { return fColorTable; } |
481 | 484 |
482 /** Returns a non-zero, unique value corresponding to the pixels in our | 485 /** Returns a non-zero, unique value corresponding to the pixels in our |
483 pixelref. Each time the pixels are changed (and notifyPixelsChanged | 486 pixelref. Each time the pixels are changed (and notifyPixelsChanged |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 828 |
826 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { | 829 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { |
827 SkASSERT(fPixels); | 830 SkASSERT(fPixels); |
828 SkASSERT(kIndex_8_SkColorType == this->colorType()); | 831 SkASSERT(kIndex_8_SkColorType == this->colorType()); |
829 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); | 832 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); |
830 SkASSERT(fColorTable); | 833 SkASSERT(fColorTable); |
831 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; | 834 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; |
832 } | 835 } |
833 | 836 |
834 #endif | 837 #endif |
OLD | NEW |