Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1725)

Side by Side Diff: include/core/SkBitmap.h

Issue 171723007: add new copyTo version to SkBitmap, which takes SkColorType (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/gmmain.cpp ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkPoint.h" 14 #include "SkPoint.h"
15 #include "SkRefCnt.h" 15 #include "SkRefCnt.h"
16 16
17 //#define SK_SUPPORT_LEGACY_COPYTO_CONFIG
18
17 struct SkMask; 19 struct SkMask;
18 struct SkIRect; 20 struct SkIRect;
19 struct SkRect; 21 struct SkRect;
20 class SkPaint; 22 class SkPaint;
21 class SkPixelRef; 23 class SkPixelRef;
22 class SkPixelRefFactory; 24 class SkPixelRefFactory;
23 class SkRegion; 25 class SkRegion;
24 class SkString; 26 class SkString;
25 27
26 #define SK_SUPPORT_DEEPCOPYTO_CONFIG 28 #define SK_SUPPORT_DEEPCOPYTO_CONFIG
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 the dst bitmap. If the subset rectangle, intersected with the bitmap's 613 the dst bitmap. If the subset rectangle, intersected with the bitmap's
612 dimensions is empty, or if there is an unsupported config, false will be 614 dimensions is empty, or if there is an unsupported config, false will be
613 returned and dst will be untouched. 615 returned and dst will be untouched.
614 @param dst The bitmap that will be set to a subset of this bitmap 616 @param dst The bitmap that will be set to a subset of this bitmap
615 @param subset The rectangle of pixels in this bitmap that dst will 617 @param subset The rectangle of pixels in this bitmap that dst will
616 reference. 618 reference.
617 @return true if the subset copy was successfully made. 619 @return true if the subset copy was successfully made.
618 */ 620 */
619 bool extractSubset(SkBitmap* dst, const SkIRect& subset) const; 621 bool extractSubset(SkBitmap* dst, const SkIRect& subset) const;
620 622
621 /** Makes a deep copy of this bitmap, respecting the requested config, 623 #ifdef SK_SUPPORT_LEGACY_COPYTO_CONFIG
624 bool copyTo(SkBitmap* dst, Config c, Allocator* allocator) const;
625 bool canCopyTo(Config newConfig) const;
626 #endif
627 /** Makes a deep copy of this bitmap, respecting the requested colorType,
622 * and allocating the dst pixels on the cpu. 628 * and allocating the dst pixels on the cpu.
623 * Returns false if either there is an error (i.e. the src does not have 629 * Returns false if either there is an error (i.e. the src does not have
624 * pixels) or the request cannot be satisfied (e.g. the src has per-pixel 630 * pixels) or the request cannot be satisfied (e.g. the src has per-pixel
625 * alpha, and the requested config does not support alpha). 631 * alpha, and the requested config does not support alpha).
626 * @param dst The bitmap to be sized and allocated 632 * @param dst The bitmap to be sized and allocated
627 * @param c The desired config for dst 633 * @param ct The desired colorType for dst
628 * @param allocator Allocator used to allocate the pixelref for the dst 634 * @param allocator Allocator used to allocate the pixelref for the dst
629 * bitmap. If this is null, the standard HeapAllocator 635 * bitmap. If this is null, the standard HeapAllocator
630 * will be used. 636 * will be used.
631 * @return true if the copy could be made. 637 * @return true if the copy was made.
632 */ 638 */
633 bool copyTo(SkBitmap* dst, Config c, Allocator* allocator = NULL) const; 639 bool copyTo(SkBitmap* dst, SkColorType ct, Allocator* = NULL) const;
640
641 bool copyTo(SkBitmap* dst, Allocator* allocator = NULL) const {
642 return this->copyTo(dst, this->colorType(), allocator);
643 }
644
645 /**
646 * Returns true if this bitmap's pixels can be converted into the requested
647 * colorType, such that copyTo() could succeed.
648 */
649 bool canCopyTo(SkColorType colorType) const;
634 650
635 /** Makes a deep copy of this bitmap, respecting the requested config, and 651 /** Makes a deep copy of this bitmap, respecting the requested config, and
636 * with custom allocation logic that will keep the copied pixels 652 * with custom allocation logic that will keep the copied pixels
637 * in the same domain as the source: If the src pixels are allocated for 653 * in the same domain as the source: If the src pixels are allocated for
638 * the cpu, then so will the dst. If the src pixels are allocated on the 654 * the cpu, then so will the dst. If the src pixels are allocated on the
639 * gpu (typically as a texture), the it will do the same for the dst. 655 * gpu (typically as a texture), the it will do the same for the dst.
640 * If the request cannot be fulfilled, returns false and dst is unmodified. 656 * If the request cannot be fulfilled, returns false and dst is unmodified.
641 */ 657 */
642 #ifndef SK_SUPPORT_DEEPCOPYTO_CONFIG 658 #ifndef SK_SUPPORT_DEEPCOPYTO_CONFIG
643 private: 659 private:
644 #endif 660 #endif
645 bool deepCopyTo(SkBitmap* dst, Config c) const; 661 bool deepCopyTo(SkBitmap* dst, Config c) const;
646 public: 662 public:
647 663
648 /** Makes a deep copy of this bitmap, keeping the copied pixels 664 /** Makes a deep copy of this bitmap, keeping the copied pixels
649 * in the same domain as the source: If the src pixels are allocated for 665 * in the same domain as the source: If the src pixels are allocated for
650 * the cpu, then so will the dst. If the src pixels are allocated on the 666 * the cpu, then so will the dst. If the src pixels are allocated on the
651 * gpu (typically as a texture), the it will do the same for the dst. 667 * gpu (typically as a texture), the it will do the same for the dst.
652 * If the request cannot be fulfilled, returns false and dst is unmodified. 668 * If the request cannot be fulfilled, returns false and dst is unmodified.
653 */ 669 */
654 bool deepCopyTo(SkBitmap* dst) const; 670 bool deepCopyTo(SkBitmap* dst) const;
655 671
656 /** Returns true if this bitmap can be deep copied into the requested config
657 by calling copyTo().
658 */
659 bool canCopyTo(Config newConfig) const;
660
661 SK_ATTR_DEPRECATED("use setFilterLevel on SkPaint") 672 SK_ATTR_DEPRECATED("use setFilterLevel on SkPaint")
662 void buildMipMap(bool forceRebuild = false); 673 void buildMipMap(bool forceRebuild = false);
663 674
664 #ifdef SK_BUILD_FOR_ANDROID 675 #ifdef SK_BUILD_FOR_ANDROID
665 bool hasHardwareMipMap() const { 676 bool hasHardwareMipMap() const {
666 return (fFlags & kHasHardwareMipMap_Flag) != 0; 677 return (fFlags & kHasHardwareMipMap_Flag) != 0;
667 } 678 }
668 679
669 void setHasHardwareMipMap(bool hasHardwareMipMap) { 680 void setHasHardwareMipMap(bool hasHardwareMipMap) {
670 if (hasHardwareMipMap) { 681 if (hasHardwareMipMap) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 940 }
930 941
931 /////////////////////////////////////////////////////////////////////////////// 942 ///////////////////////////////////////////////////////////////////////////////
932 // 943 //
933 // Helpers until we can fully deprecate SkBitmap::Config 944 // Helpers until we can fully deprecate SkBitmap::Config
934 // 945 //
935 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); 946 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType);
936 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); 947 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config);
937 948
938 #endif 949 #endif
OLDNEW
« no previous file with comments | « gm/gmmain.cpp ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698