Index: include/gpu/GrContext.h |
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h |
index 17751664196ce850022382e7d9b809744e953b7c..72b530e0680f0dd8903022e3254a449cb89fce39 100644 |
--- a/include/gpu/GrContext.h |
+++ b/include/gpu/GrContext.h |
@@ -15,8 +15,10 @@ |
#include "GrRenderTarget.h" |
#include "GrTextureProvider.h" |
#include "SkMatrix.h" |
-#include "SkMutex.h" |
+#include "../private/SkMutex.h" |
+#include "SkMipMapLevel.h" |
#include "SkPathEffect.h" |
+#include "SkTArray.h" |
#include "SkTypes.h" |
struct GrBatchAtlasConfig; |
@@ -175,12 +177,17 @@ public: |
* Callers should take a ref if they rely on the GrDrawContext sticking around. |
* NULL will be returned if the context has been abandoned. |
* |
+ * @param rt the render target receiving the draws |
* @param surfaceProps the surface properties (mainly defines text drawing) |
* |
* @return a draw context |
*/ |
- GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps = NULL) { |
- return fDrawingMgr.drawContext(surfaceProps); |
+ GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps = NULL) { |
bsalomon
2015/10/19 14:56:18
Is this supposed to be showing up in the diff? Loo
|
+ return fDrawingMgr.drawContext(rt, surfaceProps); |
+ } |
+ |
+ GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarget* rt) { |
+ return fDrawingMgr.textContext(surfaceProps, rt); |
} |
/////////////////////////////////////////////////////////////////////////// |
@@ -258,15 +265,32 @@ public: |
* @param width width of rectangle to write in pixels. |
* @param height height of rectangle to write in pixels. |
* @param config the pixel config of the source buffer |
- * @param buffer memory to read pixels from |
- * @param rowBytes number of bytes between consecutive rows. Zero |
- * means rows are tightly packed. |
+ * @param texels array of mipmap levels containing texel data to load. |
+ * Begins with full-sized palette data for paletted textures. |
+ * For compressed formats it contains the compressed pixel data. |
+ * Otherwise, it contains width*height texels. If the array is empty, |
+ * texture data is uninitialized. |
* @param pixelOpsFlags see PixelOpsFlags enum above. |
+ * |
* @return true if the write succeeded, false if not. The write can fail because of an |
* unsupported combination of surface and src configs. |
*/ |
bool writeSurfacePixels(GrSurface* surface, |
int left, int top, int width, int height, |
+ GrPixelConfig config, const SkTArray<SkMipMapLevel>& texels, |
+ uint32_t pixelOpsFlags = 0); |
+ |
+ /** |
+ * This function is a shim which creates a SkTArray<SkMipMapLevel> of size 1. |
+ * It then calls writeSurfacePixels with that SkTArray. |
+ * |
+ * @param buffer Pointer to the pixel values (optional). |
+ * @param rowBytes The number of bytes between rows of the texture. Zero |
+ * implies tightly packed rows. For compressed pixel configs, this |
+ * field is ignored. |
+ */ |
+ bool writeSurfacePixels(GrSurface* surface, |
+ int left, int top, int width, int height, |
GrPixelConfig config, const void* buffer, |
size_t rowBytes, |
uint32_t pixelOpsFlags = 0); |
@@ -410,17 +434,19 @@ private: |
GrContext(); // init must be called after the constructor. |
bool init(GrBackend, GrBackendContext, const GrContextOptions& options); |
- // Currently the DrawingMgr stores a separate GrDrawContext for each |
+ // Currently the DrawingMgr creates a separate GrTextContext for each |
// combination of text drawing options (pixel geometry x DFT use) |
- // and hands the appropriate one back given the user's request. |
- // All of the GrDrawContexts still land in the same GrDrawTarget! |
+ // and hands the appropriate one back given the DrawContext's request. |
+ // |
+ // It allocates a new GrDrawContext for each GrRenderTarget |
+ // but all of them still land in the same GrDrawTarget! |
// |
// In the future this class will allocate a new GrDrawContext for |
// each GrRenderTarget/GrDrawTarget and manage the DAG. |
class DrawingMgr { |
public: |
- DrawingMgr() : fDrawTarget(NULL) { |
- sk_bzero(fDrawContext, sizeof(fDrawContext)); |
+ DrawingMgr() : fDrawTarget(nullptr), fNVPRTextContext(nullptr) { |
+ sk_bzero(fTextContexts, sizeof(fTextContexts)); |
} |
~DrawingMgr(); |
@@ -430,13 +456,14 @@ private: |
void abandon(); |
bool abandoned() const { return NULL == fDrawTarget; } |
- void purgeResources(); |
void reset(); |
void flush(); |
- // Callers should take a ref if they rely on the GrDrawContext sticking around. |
+ // Callers assume the creation ref of the drawContext! |
// NULL will be returned if the context has been abandoned. |
- GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps); |
+ GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps); |
+ |
+ GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); |
private: |
void cleanup(); |
@@ -449,7 +476,8 @@ private: |
GrContext* fContext; |
GrDrawTarget* fDrawTarget; |
- GrDrawContext* fDrawContext[kNumPixelGeometries][kNumDFTOptions]; |
+ GrTextContext* fNVPRTextContext; |
+ GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions]; |
}; |
DrawingMgr fDrawingMgr; |
@@ -462,13 +490,13 @@ private: |
* of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they |
* return NULL. |
*/ |
- const GrFragmentProcessor* createPMToUPMEffect(GrProcessorDataManager*, GrTexture*, |
- bool swapRAndB, const SkMatrix&) const; |
- const GrFragmentProcessor* createUPMToPMEffect(GrProcessorDataManager*, GrTexture*, |
- bool swapRAndB, const SkMatrix&) const; |
+ const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, |
+ const SkMatrix&) const; |
+ const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, |
+ const SkMatrix&) const; |
/** Called before either of the above two functions to determine the appropriate fragment |
- processors for conversions. This must be called by readSurfacePixels befor a mutex is taken, |
- since testingvPM conversions itself will call readSurfacePixels */ |
+ processors for conversions. This must be called by readSurfacePixels before a mutex is |
+ taken, since testingvPM conversions itself will call readSurfacePixels */ |
void testPMConversionsIfNecessary(uint32_t flags); |
/** Returns true if we've already determined that createPMtoUPMEffect and createUPMToPMEffect |
will fail. In such cases fall back to SW conversion. */ |