OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrSurface.h" | 8 #include "GrSurface.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrSurfacePriv.h" | 10 #include "GrSurfacePriv.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const void** data, | 86 const void** data, |
87 size_t* rowBytes) { | 87 size_t* rowBytes) { |
88 return adjust_params<const void>(surfaceWidth, surfaceHeight, bpp, left, top
, width, height, | 88 return adjust_params<const void>(surfaceWidth, surfaceHeight, bpp, left, top
, width, height, |
89 data, rowBytes); | 89 data, rowBytes); |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 ////////////////////////////////////////////////////////////////////////////// | 93 ////////////////////////////////////////////////////////////////////////////// |
94 | 94 |
95 bool GrSurface::writePixels(int left, int top, int width, int height, | 95 bool GrSurface::writePixels(int left, int top, int width, int height, |
96 GrPixelConfig config, const void* buffer, size_t row
Bytes, | 96 GrPixelConfig config, const SkTArray<SkMipMapLevel>&
texels, |
97 uint32_t pixelOpsFlags) { | 97 uint32_t pixelOpsFlags) { |
98 // go through context so that all necessary flushing occurs | 98 // go through context so that all necessary flushing occurs |
99 GrContext* context = this->getContext(); | 99 GrContext* context = this->getContext(); |
100 if (nullptr == context) { | 100 if (nullptr == context) { |
101 return false; | 101 return false; |
102 } | 102 } |
103 return context->writeSurfacePixels(this, left, top, width, height, config, b
uffer, rowBytes, | 103 return context->writeSurfacePixels(this, left, top, width, height, config, t
exels, |
104 pixelOpsFlags); | 104 pixelOpsFlags); |
105 } | 105 } |
106 | 106 |
| 107 bool GrSurface::writePixels(int left, int top, int width, int height, |
| 108 GrPixelConfig config, const void* buffer, size_t row
Bytes, |
| 109 uint32_t pixelOpsFlags) { |
| 110 // make sure the size's range fits within the texelmap's size range |
| 111 if (width <= 0 || height <= 0) { |
| 112 return false; |
| 113 } |
| 114 const uint32_t baseLevelWidth = width; |
| 115 const uint32_t baseLevelHeight = height; |
| 116 |
| 117 SkMipMapLevel level(buffer, rowBytes, baseLevelWidth, baseLevelHeight); |
| 118 const int levelCount = 1; |
| 119 SkTArray<SkMipMapLevel> texels(levelCount); |
| 120 texels.push_back(level); |
| 121 |
| 122 return this->writePixels(left, top, width, height, config, texels, pixelOpsF
lags); |
| 123 } |
| 124 |
107 bool GrSurface::readPixels(int left, int top, int width, int height, | 125 bool GrSurface::readPixels(int left, int top, int width, int height, |
108 GrPixelConfig config, void* buffer, size_t rowBytes, | 126 GrPixelConfig config, void* buffer, size_t rowBytes, |
109 uint32_t pixelOpsFlags) { | 127 uint32_t pixelOpsFlags) { |
110 // go through context so that all necessary flushing occurs | 128 // go through context so that all necessary flushing occurs |
111 GrContext* context = this->getContext(); | 129 GrContext* context = this->getContext(); |
112 if (nullptr == context) { | 130 if (nullptr == context) { |
113 return false; | 131 return false; |
114 } | 132 } |
115 return context->readSurfacePixels(this, left, top, width, height, config, bu
ffer, | 133 return context->readSurfacePixels(this, left, top, width, height, config, bu
ffer, |
116 rowBytes, pixelOpsFlags); | 134 rowBytes, pixelOpsFlags); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 221 |
204 void GrSurface::onRelease() { | 222 void GrSurface::onRelease() { |
205 this->invokeReleaseProc(); | 223 this->invokeReleaseProc(); |
206 this->INHERITED::onRelease(); | 224 this->INHERITED::onRelease(); |
207 } | 225 } |
208 | 226 |
209 void GrSurface::onAbandon() { | 227 void GrSurface::onAbandon() { |
210 this->invokeReleaseProc(); | 228 this->invokeReleaseProc(); |
211 this->INHERITED::onAbandon(); | 229 this->INHERITED::onAbandon(); |
212 } | 230 } |
OLD | NEW |