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

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

Issue 1346713002: move SkBitmapProvider to its own file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix spelling Created 5 years, 3 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/core/SkBitmapProcShader.h ('k') | src/core/SkBitmapProcState.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProcState.h" 9 #include "SkBitmapProcState.h"
10 #include "SkBitmapProvider.h"
10 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
11 #include "SkErrorInternals.h" 12 #include "SkErrorInternals.h"
12 #include "SkPixelRef.h" 13 #include "SkPixelRef.h"
13 #include "SkReadBuffer.h" 14 #include "SkReadBuffer.h"
14 #include "SkWriteBuffer.h" 15 #include "SkWriteBuffer.h"
15 16
16 #if SK_SUPPORT_GPU 17 #if SK_SUPPORT_GPU
17 #include "effects/GrBicubicEffect.h" 18 #include "effects/GrBicubicEffect.h"
18 #include "effects/GrExtractAlphaFragmentProcessor.h" 19 #include "effects/GrExtractAlphaFragmentProcessor.h"
19 #include "effects/GrSimpleTextureEffect.h" 20 #include "effects/GrSimpleTextureEffect.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; 72 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
72 return (matrix.getType() & ~mask) == 0; 73 return (matrix.getType() & ~mask) == 0;
73 } 74 }
74 75
75 bool SkBitmapProcShader::isOpaque() const { 76 bool SkBitmapProcShader::isOpaque() const {
76 return fRawBitmap.isOpaque(); 77 return fRawBitmap.isOpaque();
77 } 78 }
78 79
79 SkShader::Context* SkBitmapProcShader::MakeContext(const SkShader& shader, 80 SkShader::Context* SkBitmapProcShader::MakeContext(const SkShader& shader,
80 TileMode tmx, TileMode tmy, 81 TileMode tmx, TileMode tmy,
81 const SkBitmap& bitmap, 82 const SkBitmapProvider& provi der,
82 const ContextRec& rec, void* storage) { 83 const ContextRec& rec, void* storage) {
83 SkMatrix totalInverse; 84 SkMatrix totalInverse;
84 // Do this first, so we know the matrix can be inverted. 85 // Do this first, so we know the matrix can be inverted.
85 if (!shader.computeTotalInverse(rec, &totalInverse)) { 86 if (!shader.computeTotalInverse(rec, &totalInverse)) {
86 return nullptr; 87 return nullptr;
87 } 88 }
88 89
89 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); 90 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
90 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(SkBitmapProv ider(bitmap), 91 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider, tm x, tmy);
91 tmx, tmy);
92 92
93 SkASSERT(state); 93 SkASSERT(state);
94 if (!state->chooseProcs(totalInverse, *rec.fPaint)) { 94 if (!state->chooseProcs(totalInverse, *rec.fPaint)) {
95 state->~SkBitmapProcState(); 95 state->~SkBitmapProcState();
96 return nullptr; 96 return nullptr;
97 } 97 }
98 98
99 return new (storage) BitmapProcShaderContext(shader, rec, state); 99 return new (storage) BitmapProcShaderContext(shader, rec, state);
100 } 100 }
101 101
102 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const { 102 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const {
103 return MakeContext(*this, (TileMode)fTileModeX, (TileMode)fTileModeY, fRawBi tmap, rec, storage); 103 return MakeContext(*this, (TileMode)fTileModeX, (TileMode)fTileModeY,
104 SkBitmapProvider(fRawBitmap), rec, storage);
104 } 105 }
105 106
106 SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(const SkSha der& shader, 107 SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(const SkSha der& shader,
107 const Conte xtRec& rec, 108 const Conte xtRec& rec,
108 SkBitmapPro cState* state) 109 SkBitmapPro cState* state)
109 : INHERITED(shader, rec) 110 : INHERITED(shader, rec)
110 , fState(state) 111 , fState(state)
111 { 112 {
112 const SkPixmap& pixmap = fState->fPixmap; 113 const SkPixmap& pixmap = fState->fPixmap;
113 bool isOpaque = pixmap.isOpaque(); 114 bool isOpaque = pixmap.isOpaque();
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 inner.reset(GrSimpleTextureEffect::Create(procDataManager, texture, matr ix, params)); 408 inner.reset(GrSimpleTextureEffect::Create(procDataManager, texture, matr ix, params));
408 } 409 }
409 410
410 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { 411 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
411 return SkRef(inner.get()); 412 return SkRef(inner.get());
412 } 413 }
413 return GrExtractAlphaFragmentProcessor::Create(inner); 414 return GrExtractAlphaFragmentProcessor::Create(inner);
414 } 415 }
415 416
416 #endif 417 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkBitmapProcState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698