OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkImage_Base.h" | 8 #include "SkImage_Base.h" |
9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes) | 85 SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes) |
86 : INHERITED(info.fWidth, info.fHeight) { | 86 : INHERITED(info.fWidth, info.fHeight) { |
87 fBitmap.setConfig(info, rowBytes); | 87 fBitmap.setConfig(info, rowBytes); |
88 SkAutoTUnref<SkPixelRef> ref( | 88 SkAutoTUnref<SkPixelRef> ref( |
89 SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data, 0)); | 89 SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data, 0)); |
90 fBitmap.setPixelRef(ref); | 90 fBitmap.setPixelRef(ref); |
91 fBitmap.setImmutable(); | 91 fBitmap.setImmutable(); |
92 } | 92 } |
93 | 93 |
94 SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes
) | 94 SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes
) |
95 : INHERITED(info.fWidth, info.fHeight) { | 95 : INHERITED(info.fWidth, info.fHeight) |
96 SkBitmap::Config config = SkImageInfoToBitmapConfig(info); | 96 { |
97 | 97 fBitmap.setConfig(info, rowBytes); |
98 fBitmap.setConfig(config, info.fWidth, info.fHeight, rowBytes, info.fAlphaTy
pe); | |
99 fBitmap.setPixelRef(pr); | 98 fBitmap.setPixelRef(pr); |
100 } | 99 } |
101 | 100 |
102 SkImage_Raster::~SkImage_Raster() {} | 101 SkImage_Raster::~SkImage_Raster() {} |
103 | 102 |
104 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa
int* paint) { | 103 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa
int* paint) { |
105 canvas->drawBitmap(fBitmap, x, y, paint); | 104 canvas->drawBitmap(fBitmap, x, y, paint); |
106 } | 105 } |
107 | 106 |
108 void SkImage_Raster::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const
SkRect& dst, const SkPaint* paint) { | 107 void SkImage_Raster::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const
SkRect& dst, const SkPaint* paint) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 156 } |
158 | 157 |
159 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, | 158 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, |
160 size_t rowBytes) { | 159 size_t rowBytes) { |
161 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); | 160 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); |
162 } | 161 } |
163 | 162 |
164 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { | 163 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { |
165 return ((SkImage_Raster*)image)->getPixelRef(); | 164 return ((SkImage_Raster*)image)->getPixelRef(); |
166 } | 165 } |
OLD | NEW |