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

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

Issue 19729007: Add SkImage->draw() call with src and dst rects. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | « src/image/SkImage_Picture.cpp ('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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 return true; 49 return true;
50 } 50 }
51 51
52 static SkImage* NewEmpty(); 52 static SkImage* NewEmpty();
53 53
54 SkImage_Raster(const SkImage::Info&, SkData*, size_t rb); 54 SkImage_Raster(const SkImage::Info&, SkData*, size_t rb);
55 virtual ~SkImage_Raster(); 55 virtual ~SkImage_Raster();
56 56
57 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRI DE; 57 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRI DE;
58 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) SK_OVERRIDE;
58 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; 59 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
59 60
60 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 61 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
61 SkImage_Raster(const SkImage::Info&, SkPixelRef*, size_t rowBytes); 62 SkImage_Raster(const SkImage::Info&, SkPixelRef*, size_t rowBytes);
62 63
63 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 64 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
64 65
65 private: 66 private:
66 SkImage_Raster() : INHERITED(0, 0) {} 67 SkImage_Raster() : INHERITED(0, 0) {}
67 68
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 fBitmap.setPixelRef(pr); 103 fBitmap.setPixelRef(pr);
103 fBitmap.setIsOpaque(isOpaque); 104 fBitmap.setIsOpaque(isOpaque);
104 } 105 }
105 106
106 SkImage_Raster::~SkImage_Raster() {} 107 SkImage_Raster::~SkImage_Raster() {}
107 108
108 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) { 109 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) {
109 canvas->drawBitmap(fBitmap, x, y, paint); 110 canvas->drawBitmap(fBitmap, x, y, paint);
110 } 111 }
111 112
113 void SkImage_Raster::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst, const SkPaint* paint) {
114 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
115 }
116
112 bool SkImage_Raster::getROPixels(SkBitmap* dst) const { 117 bool SkImage_Raster::getROPixels(SkBitmap* dst) const {
113 *dst = fBitmap; 118 *dst = fBitmap;
114 return true; 119 return true;
115 } 120 }
116 121
117 /////////////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////////////
118 123
119 SkImage* SkImage::NewRasterCopy(const SkImage::Info& info, const void* pixels, s ize_t rowBytes) { 124 SkImage* SkImage::NewRasterCopy(const SkImage::Info& info, const void* pixels, s ize_t rowBytes) {
120 if (!SkImage_Raster::ValidArgs(info, rowBytes)) { 125 if (!SkImage_Raster::ValidArgs(info, rowBytes)) {
121 return NULL; 126 return NULL;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 162 }
158 163
159 SkImage* SkNewImageFromPixelRef(const SkImage::Info& info, SkPixelRef* pr, 164 SkImage* SkNewImageFromPixelRef(const SkImage::Info& info, SkPixelRef* pr,
160 size_t rowBytes) { 165 size_t rowBytes) {
161 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); 166 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
162 } 167 }
163 168
164 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { 169 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {
165 return ((SkImage_Raster*)image)->getPixelRef(); 170 return ((SkImage_Raster*)image)->getPixelRef();
166 } 171 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Picture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698