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

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

Issue 26702002: force readbuffer clients to use specialized readFoo for flattenables (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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
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"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkFlattenableBuffers.h" 12 #include "SkFlattenableBuffers.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 14
15 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe ct& rect) { 15 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe ct& rect) {
16 SkASSERT(s); 16 SkASSERT(s);
17 return SkNEW_ARGS(SkRectShaderImageFilter, (s, rect)); 17 return SkNEW_ARGS(SkRectShaderImageFilter, (s, rect));
18 } 18 }
19 19
20 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const SkRect& rect ) 20 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const SkRect& rect )
21 : INHERITED(NULL) 21 : INHERITED(NULL)
22 , fShader(s) 22 , fShader(s)
23 , fRect(rect) { 23 , fRect(rect) {
24 SkASSERT(s); 24 SkASSERT(s);
25 s->ref(); 25 s->ref();
26 } 26 }
27 27
28 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer ) 28 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer )
29 : INHERITED(buffer) { 29 : INHERITED(buffer) {
30 fShader = buffer.readFlattenableT<SkShader>(); 30 fShader = buffer.readShader();
31 buffer.readRect(&fRect); 31 buffer.readRect(&fRect);
32 } 32 }
33 33
34 void SkRectShaderImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 34 void SkRectShaderImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
35 this->INHERITED::flatten(buffer); 35 this->INHERITED::flatten(buffer);
36 36
37 buffer.writeFlattenable(fShader); 37 buffer.writeFlattenable(fShader);
38 buffer.writeRect(fRect); 38 buffer.writeRect(fRect);
39 } 39 }
40 40
(...skipping 17 matching lines...) Expand all
58 58
59 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(SkScalarCeilToInt(rect .width()), 59 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(SkScalarCeilToInt(rect .width()),
60 SkScalarCeilToInt(rect .height()))); 60 SkScalarCeilToInt(rect .height())));
61 SkCanvas canvas(device.get()); 61 SkCanvas canvas(device.get());
62 SkPaint paint; 62 SkPaint paint;
63 paint.setShader(fShader); 63 paint.setShader(fShader);
64 canvas.drawRect(rect, paint); 64 canvas.drawRect(rect, paint);
65 *result = device.get()->accessBitmap(false); 65 *result = device.get()->accessBitmap(false);
66 return true; 66 return true;
67 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698