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

Side by Side Diff: src/image/SkImage_Raster.cpp

Issue 855473002: initial preroll api (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « src/image/SkImage_Base.h ('k') | no next file » | 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 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, const SkSurfaceProps* ); 52 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, const SkSurfaceProps* );
53 virtual ~SkImage_Raster(); 53 virtual ~SkImage_Raster();
54 54
55 void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_OVERRIDE ; 55 void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_OVERRIDE ;
56 void onDrawRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) con st SK_OVERRIDE; 56 void onDrawRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) con st SK_OVERRIDE;
57 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_ OVERRIDE; 57 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_ OVERRIDE;
58 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st SK_OVERRIDE; 58 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st SK_OVERRIDE;
59 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const SK_OVERRI DE; 59 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const SK_OVERRI DE;
60 bool getROPixels(SkBitmap*) const SK_OVERRIDE; 60 bool getROPixels(SkBitmap*) const SK_OVERRIDE;
61 void onPreroll() const SK_OVERRIDE;
61 62
62 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 63 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
63 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes, const SkSur faceProps*); 64 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes, const SkSur faceProps*);
64 65
65 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 66 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
66 67
67 virtual SkShader* onNewShader(SkShader::TileMode, 68 virtual SkShader* onNewShader(SkShader::TileMode,
68 SkShader::TileMode, 69 SkShader::TileMode,
69 const SkMatrix* localMatrix) const SK_OVERRIDE ; 70 const SkMatrix* localMatrix) const SK_OVERRIDE ;
70 71
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 *infoPtr = info; 148 *infoPtr = info;
148 *rowBytesPtr = fBitmap.rowBytes(); 149 *rowBytesPtr = fBitmap.rowBytes();
149 return fBitmap.getPixels(); 150 return fBitmap.getPixels();
150 } 151 }
151 152
152 bool SkImage_Raster::getROPixels(SkBitmap* dst) const { 153 bool SkImage_Raster::getROPixels(SkBitmap* dst) const {
153 *dst = fBitmap; 154 *dst = fBitmap;
154 return true; 155 return true;
155 } 156 }
156 157
158 void SkImage_Raster::onPreroll() const {
159 SkBitmap bm(fBitmap);
160 bm.lockPixels();
161 bm.unlockPixels();
162 }
163
157 /////////////////////////////////////////////////////////////////////////////// 164 ///////////////////////////////////////////////////////////////////////////////
158 165
159 SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, siz e_t rowBytes) { 166 SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, siz e_t rowBytes) {
160 if (!SkImage_Raster::ValidArgs(info, rowBytes) || !pixels) { 167 if (!SkImage_Raster::ValidArgs(info, rowBytes) || !pixels) {
161 return NULL; 168 return NULL;
162 } 169 }
163 170
164 // Here we actually make a copy of the caller's pixel data 171 // Here we actually make a copy of the caller's pixel data
165 SkAutoDataUnref data(SkData::NewWithCopy(pixels, info.height() * rowBytes)); 172 SkAutoDataUnref data(SkData::NewWithCopy(pixels, info.height() * rowBytes));
166 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, NULL)); 173 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, NULL));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes, props)); 208 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes, props));
202 } 209 }
203 210
204 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { 211 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) {
205 return ((const SkImage_Raster*)image)->getPixelRef(); 212 return ((const SkImage_Raster*)image)->getPixelRef();
206 } 213 }
207 214
208 bool SkImage_Raster::isOpaque() const { 215 bool SkImage_Raster::isOpaque() const {
209 return fBitmap.isOpaque(); 216 return fBitmap.isOpaque();
210 } 217 }
218
OLDNEW
« no previous file with comments | « src/image/SkImage_Base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698