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

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

Issue 409653003: Now able to set the localMatrix when creating a SkShader from a SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Corrects warnings in windows build Created 6 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
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | tests/ImageNewShaderTest.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 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) SK_OVERRIDE; 57 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) SK_OVERRIDE;
58 virtual bool onReadPixels(SkBitmap*, const SkIRect&) const SK_OVERRIDE; 58 virtual bool onReadPixels(SkBitmap*, const SkIRect&) const SK_OVERRIDE;
59 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const S K_OVERRIDE; 59 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const S K_OVERRIDE;
60 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; 60 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
61 61
62 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 62 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
63 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes); 63 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes);
64 64
65 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 65 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
66 66
67 virtual SkShader* onNewShader(SkShader::TileMode, SkShader::TileMode) const SK_OVERRIDE; 67 virtual SkShader* onNewShader(SkShader::TileMode,
68 SkShader::TileMode,
69 const SkMatrix* localMatrix) const SK_OVERRIDE ;
68 70
69 private: 71 private:
70 SkImage_Raster() : INHERITED(0, 0) {} 72 SkImage_Raster() : INHERITED(0, 0) {}
71 73
72 SkBitmap fBitmap; 74 SkBitmap fBitmap;
73 75
74 typedef SkImage_Base INHERITED; 76 typedef SkImage_Base INHERITED;
75 }; 77 };
76 78
77 /////////////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////////////
(...skipping 28 matching lines...) Expand all
106 SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes ) 108 SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes )
107 : INHERITED(info.fWidth, info.fHeight) 109 : INHERITED(info.fWidth, info.fHeight)
108 { 110 {
109 fBitmap.setInfo(info, rowBytes); 111 fBitmap.setInfo(info, rowBytes);
110 fBitmap.setPixelRef(pr); 112 fBitmap.setPixelRef(pr);
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) const { 118 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX,
117 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, NULL); 119 SkShader::TileMode tileY,
120 const SkMatrix* localMatrix) const
121 {
122 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix);
118 } 123 }
119 124
120 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) { 125 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) {
121 canvas->drawBitmap(fBitmap, x, y, paint); 126 canvas->drawBitmap(fBitmap, x, y, paint);
122 } 127 }
123 128
124 void SkImage_Raster::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, 129 void SkImage_Raster::onDrawRectToRect(SkCanvas* canvas, const SkRect* src,
125 const SkRect& dst, const SkPaint* paint) { 130 const SkRect& dst, const SkPaint* paint) {
126 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); 131 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
127 } 132 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 201 }
197 202
198 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, 203 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
199 size_t rowBytes) { 204 size_t rowBytes) {
200 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); 205 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
201 } 206 }
202 207
203 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { 208 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {
204 return ((SkImage_Raster*)image)->getPixelRef(); 209 return ((SkImage_Raster*)image)->getPixelRef();
205 } 210 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | tests/ImageNewShaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698