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

Side by Side Diff: src/effects/SkRectShaderImageFilter.cpp

Issue 26220004: SkRectShaderImageFilter: add a new factory method which takes a CropRect. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: More docs Created 7 years, 2 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 | « include/effects/SkRectShaderImageFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkRectShaderImageFilter.h" 8 #include "SkRectShaderImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 13 matching lines...) Expand all
24 #else 24 #else
25 uint32_t flags = CropRect::kHasAll_CropEdge; 25 uint32_t flags = CropRect::kHasAll_CropEdge;
26 if (rect.width() == 0 || rect.height() == 0) { 26 if (rect.width() == 0 || rect.height() == 0) {
27 flags = 0x0; 27 flags = 0x0;
28 } 28 }
29 CropRect cropRect(rect, flags); 29 CropRect cropRect(rect, flags);
30 #endif 30 #endif
31 return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect)); 31 return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect));
32 } 32 }
33 33
34 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const Crop Rect* cropRect) {
35 SkASSERT(s);
36 return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect));
37 }
38
34 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr opRect) 39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr opRect)
35 : INHERITED(NULL, cropRect) 40 : INHERITED(NULL, cropRect)
36 , fShader(s) { 41 , fShader(s) {
37 SkASSERT(s); 42 SkASSERT(s);
38 s->ref(); 43 s->ref();
39 } 44 }
40 45
41 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer ) 46 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer )
42 : INHERITED(buffer) { 47 : INHERITED(buffer) {
43 fShader = buffer.readFlattenableT<SkShader>(); 48 fShader = buffer.readFlattenableT<SkShader>();
(...skipping 28 matching lines...) Expand all
72 SkMatrix matrix; 77 SkMatrix matrix;
73 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop )); 78 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop ));
74 fShader->setLocalMatrix(matrix); 79 fShader->setLocalMatrix(matrix);
75 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); 80 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height()));
76 canvas.drawRect(rect, paint); 81 canvas.drawRect(rect, paint);
77 *result = device.get()->accessBitmap(false); 82 *result = device.get()->accessBitmap(false);
78 offset->fX += bounds.fLeft; 83 offset->fX += bounds.fLeft;
79 offset->fY += bounds.fTop; 84 offset->fY += bounds.fTop;
80 return true; 85 return true;
81 } 86 }
OLDNEW
« no previous file with comments | « include/effects/SkRectShaderImageFilter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698