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

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

Issue 1576083002: restore lost optimization when the shader can report const_in_y (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | 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 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 "SkBitmapProvider.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 return new (storage) BitmapProcShaderContext(shader, rec, state); 94 return new (storage) BitmapProcShaderContext(shader, rec, state);
95 } 95 }
96 96
97 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const { 97 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const {
98 return MakeContext(*this, (TileMode)fTileModeX, (TileMode)fTileModeY, 98 return MakeContext(*this, (TileMode)fTileModeX, (TileMode)fTileModeY,
99 SkBitmapProvider(fRawBitmap), rec, storage); 99 SkBitmapProvider(fRawBitmap), rec, storage);
100 } 100 }
101 101
102 static bool only_scale_and_translate(const SkMatrix& matrix) {
103 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
104 return (matrix.getType() & ~mask) == 0;
105 }
106
102 SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(const SkSha der& shader, 107 SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(const SkSha der& shader,
103 const Conte xtRec& rec, 108 const Conte xtRec& rec,
104 SkBitmapPro cState* state) 109 SkBitmapPro cState* state)
105 : INHERITED(shader, rec) 110 : INHERITED(shader, rec)
106 , fState(state) 111 , fState(state)
107 { 112 {
108 fFlags = 0; 113 fFlags = 0;
109 if (fState->fPixmap.isOpaque() && (255 == this->getPaintAlpha())) { 114 if (fState->fPixmap.isOpaque() && (255 == this->getPaintAlpha())) {
110 fFlags |= kOpaqueAlpha_Flag; 115 fFlags |= kOpaqueAlpha_Flag;
111 } 116 }
117
118 if (1 == fState->fPixmap.height() && only_scale_and_translate(this->getTotal Inverse())) {
119 fFlags |= kConstInY32_Flag;
120 }
112 } 121 }
113 122
114 SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() { 123 SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() {
115 // The bitmap proc state has been created outside of the context on memory t hat will be freed 124 // The bitmap proc state has been created outside of the context on memory t hat will be freed
116 // elsewhere. Only call the destructor but leave the freeing of the memory t o the caller. 125 // elsewhere. Only call the destructor but leave the freeing of the memory t o the caller.
117 fState->~SkBitmapProcState(); 126 fState->~SkBitmapProcState();
118 } 127 }
119 128
120 #define BUF_MAX 128 129 #define BUF_MAX 128
121 130
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); 343 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
335 } 344 }
336 345
337 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { 346 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
338 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); 347 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner);
339 } 348 }
340 return GrFragmentProcessor::MulOutputByInputAlpha(inner); 349 return GrFragmentProcessor::MulOutputByInputAlpha(inner);
341 } 350 }
342 351
343 #endif 352 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698