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

Side by Side Diff: src/core/SkBitmapProcShader.cpp

Issue 134163010: Refactor read and write buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: original write flags were fine Created 6 years, 10 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkFlattenableBuffers.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h"
10 #include "SkPixelRef.h" 11 #include "SkPixelRef.h"
11 #include "SkErrorInternals.h" 12 #include "SkErrorInternals.h"
12 #include "SkBitmapProcShader.h" 13 #include "SkBitmapProcShader.h"
13 14
14 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
15 #include "effects/GrSimpleTextureEffect.h" 16 #include "effects/GrSimpleTextureEffect.h"
16 #include "effects/GrBicubicEffect.h" 17 #include "effects/GrBicubicEffect.h"
17 #endif 18 #endif
18 19
19 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { 20 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) {
(...skipping 11 matching lines...) Expand all
31 } 32 }
32 33
33 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, 34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src,
34 TileMode tmx, TileMode tmy) { 35 TileMode tmx, TileMode tmy) {
35 fRawBitmap = src; 36 fRawBitmap = src;
36 fState.fTileModeX = (uint8_t)tmx; 37 fState.fTileModeX = (uint8_t)tmx;
37 fState.fTileModeY = (uint8_t)tmy; 38 fState.fTileModeY = (uint8_t)tmy;
38 fFlags = 0; // computed in setContext 39 fFlags = 0; // computed in setContext
39 } 40 }
40 41
41 SkBitmapProcShader::SkBitmapProcShader(SkFlattenableReadBuffer& buffer) 42 SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer)
42 : INHERITED(buffer) { 43 : INHERITED(buffer) {
43 buffer.readBitmap(&fRawBitmap); 44 buffer.readBitmap(&fRawBitmap);
44 fRawBitmap.setImmutable(); 45 fRawBitmap.setImmutable();
45 fState.fTileModeX = buffer.readUInt(); 46 fState.fTileModeX = buffer.readUInt();
46 fState.fTileModeY = buffer.readUInt(); 47 fState.fTileModeY = buffer.readUInt();
47 fFlags = 0; // computed in setContext 48 fFlags = 0; // computed in setContext
48 } 49 }
49 50
50 SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture, 51 SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture,
51 SkMatrix* texM, 52 SkMatrix* texM,
52 TileMode xy[]) const { 53 TileMode xy[]) const {
53 if (texture) { 54 if (texture) {
54 *texture = fRawBitmap; 55 *texture = fRawBitmap;
55 } 56 }
56 if (texM) { 57 if (texM) {
57 texM->reset(); 58 texM->reset();
58 } 59 }
59 if (xy) { 60 if (xy) {
60 xy[0] = (TileMode)fState.fTileModeX; 61 xy[0] = (TileMode)fState.fTileModeX;
61 xy[1] = (TileMode)fState.fTileModeY; 62 xy[1] = (TileMode)fState.fTileModeY;
62 } 63 }
63 return kDefault_BitmapType; 64 return kDefault_BitmapType;
64 } 65 }
65 66
66 void SkBitmapProcShader::flatten(SkFlattenableWriteBuffer& buffer) const { 67 void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const {
67 this->INHERITED::flatten(buffer); 68 this->INHERITED::flatten(buffer);
68 69
69 buffer.writeBitmap(fRawBitmap); 70 buffer.writeBitmap(fRawBitmap);
70 buffer.writeUInt(fState.fTileModeX); 71 buffer.writeUInt(fState.fTileModeX);
71 buffer.writeUInt(fState.fTileModeY); 72 buffer.writeUInt(fState.fTileModeY);
72 } 73 }
73 74
74 static bool only_scale_and_translate(const SkMatrix& matrix) { 75 static bool only_scale_and_translate(const SkMatrix& matrix) {
75 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; 76 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
76 return (matrix.getType() & ~mask) == 0; 77 return (matrix.getType() & ~mask) == 0;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 GrEffectRef* effect = NULL; 437 GrEffectRef* effect = NULL;
437 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { 438 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) {
438 effect = GrBicubicEffect::Create(texture, matrix, tm); 439 effect = GrBicubicEffect::Create(texture, matrix, tm);
439 } else { 440 } else {
440 effect = GrSimpleTextureEffect::Create(texture, matrix, params); 441 effect = GrSimpleTextureEffect::Create(texture, matrix, params);
441 } 442 }
442 GrUnlockAndUnrefCachedBitmapTexture(texture); 443 GrUnlockAndUnrefCachedBitmapTexture(texture);
443 return effect; 444 return effect;
444 } 445 }
445 #endif 446 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698