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

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

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
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 "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo de tmy, 34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo de tmy,
35 const SkMatrix* localMatrix) 35 const SkMatrix* localMatrix)
36 : INHERITED(localMatrix) { 36 : INHERITED(localMatrix) {
37 fRawBitmap = src; 37 fRawBitmap = src;
38 fTileModeX = (uint8_t)tmx; 38 fTileModeX = (uint8_t)tmx;
39 fTileModeY = (uint8_t)tmy; 39 fTileModeY = (uint8_t)tmy;
40 } 40 }
41 41
42 SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer) 42 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
43 : INHERITED(buffer) { 43 SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer) : INHERITED(buffer) {
44 buffer.readBitmap(&fRawBitmap); 44 buffer.readBitmap(&fRawBitmap);
45 fRawBitmap.setImmutable(); 45 fRawBitmap.setImmutable();
46 fTileModeX = buffer.readUInt(); 46 fTileModeX = buffer.readUInt();
47 fTileModeY = buffer.readUInt(); 47 fTileModeY = buffer.readUInt();
48 } 48 }
49 #endif
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)fTileModeX; 61 xy[0] = (TileMode)fTileModeX;
61 xy[1] = (TileMode)fTileModeY; 62 xy[1] = (TileMode)fTileModeY;
62 } 63 }
63 return kDefault_BitmapType; 64 return kDefault_BitmapType;
64 } 65 }
65 66
67 SkFlattenable* SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) {
68 SkMatrix lm;
69 buffer.readMatrix(&lm);
70 SkBitmap bm;
71 if (!buffer.readBitmap(&bm)) {
72 return NULL;
73 }
74 TileMode mx = (TileMode)buffer.readUInt();
75 TileMode my = (TileMode)buffer.readUInt();
76 return SkShader::CreateBitmapShader(bm, mx, my, &lm);
77 }
78
66 void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const { 79 void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const {
67 this->INHERITED::flatten(buffer); 80 buffer.writeMatrix(this->getLocalMatrix());
68
69 buffer.writeBitmap(fRawBitmap); 81 buffer.writeBitmap(fRawBitmap);
70 buffer.writeUInt(fTileModeX); 82 buffer.writeUInt(fTileModeX);
71 buffer.writeUInt(fTileModeY); 83 buffer.writeUInt(fTileModeY);
72 } 84 }
73 85
74 static bool only_scale_and_translate(const SkMatrix& matrix) { 86 static bool only_scale_and_translate(const SkMatrix& matrix) {
75 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; 87 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
76 return (matrix.getType() & ~mask) == 0; 88 return (matrix.getType() & ~mask) == 0;
77 } 89 }
78 90
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 #else 483 #else
472 484
473 bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint, 485 bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
474 const SkMatrix* localMatrix, GrColor* paint Color, 486 const SkMatrix* localMatrix, GrColor* paint Color,
475 GrEffect** effect) const { 487 GrEffect** effect) const {
476 SkDEBUGFAIL("Should not call in GPU-less build"); 488 SkDEBUGFAIL("Should not call in GPU-less build");
477 return false; 489 return false;
478 } 490 }
479 491
480 #endif 492 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698