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

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

Issue 1127993004: Revert of Revert of Revert of Make drawImage a virtual on SkDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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_Gpu.cpp ('k') | src/pipe/SkGPipePriv.h » ('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 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 "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 int64_t size = (int64_t)info.height() * rowBytes; 46 int64_t size = (int64_t)info.height() * rowBytes;
47 if (size > (int64_t)kMaxPixelByteSize) { 47 if (size > (int64_t)kMaxPixelByteSize) {
48 return false; 48 return false;
49 } 49 }
50 return true; 50 return true;
51 } 51 }
52 52
53 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, const SkSurfaceProps* ); 53 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, const SkSurfaceProps* );
54 virtual ~SkImage_Raster(); 54 virtual ~SkImage_Raster();
55 55
56 void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const override;
57 void onDrawRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) con st override;
56 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove rride; 58 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove rride;
57 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st override; 59 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st override;
58 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; 60 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
59 bool getROPixels(SkBitmap*) const override; 61 bool getROPixels(SkBitmap*) const override;
60 62
61 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 63 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
62 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig in, size_t rowBytes, 64 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig in, size_t rowBytes,
63 const SkSurfaceProps*); 65 const SkSurfaceProps*);
64 66
65 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 67 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 fBitmap.lockPixels(); 113 fBitmap.lockPixels();
112 } 114 }
113 115
114 SkImage_Raster::~SkImage_Raster() {} 116 SkImage_Raster::~SkImage_Raster() {}
115 117
116 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo de tileY, 118 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo de tileY,
117 const SkMatrix* localMatrix) const { 119 const SkMatrix* localMatrix) const {
118 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); 120 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix);
119 } 121 }
120 122
123 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) const {
124 SkBitmap shallowCopy(fBitmap);
125 canvas->drawBitmap(shallowCopy, x, y, paint);
126 }
127
128 void SkImage_Raster::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRec t& dst,
129 const SkPaint* paint) const {
130 SkBitmap shallowCopy(fBitmap);
131 canvas->drawBitmapRectToRect(shallowCopy, src, dst, paint);
132 }
133
121 SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurface Props& props) const { 134 SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurface Props& props) const {
122 return SkSurface::NewRaster(info, &props); 135 return SkSurface::NewRaster(info, &props);
123 } 136 }
124 137
125 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes, 138 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes,
126 int srcX, int srcY) const { 139 int srcX, int srcY) const {
127 SkBitmap shallowCopy(fBitmap); 140 SkBitmap shallowCopy(fBitmap);
128 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY); 141 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
129 } 142 }
130 143
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 229 }
217 230
218 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { 231 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) {
219 return ((const SkImage_Raster*)image)->getPixelRef(); 232 return ((const SkImage_Raster*)image)->getPixelRef();
220 } 233 }
221 234
222 bool SkImage_Raster::isOpaque() const { 235 bool SkImage_Raster::isOpaque() const {
223 return fBitmap.isOpaque(); 236 return fBitmap.isOpaque();
224 } 237 }
225 238
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | src/pipe/SkGPipePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698