Received: by 10.100.171.5 with SMTP id t5mr613648ane.13.1349301960035; Wed, 03 Oct 2012 15:06:00 -0700 (PDT) X-BeenThere: android-developers@googlegroups.com Received: by 10.236.92.236 with SMTP id j72ls1331347yhf.1.gmail; Wed, 03 Oct 2012 15:03:51 -0700 (PDT) Received: by 10.236.175.7 with SMTP id y7mr2434527yhl.14.1349301831519; Wed, 03 Oct 2012 15:03:51 -0700 (PDT) Received: by 10.236.175.7 with SMTP id y7mr2434526yhl.14.1349301831504; Wed, 03 Oct 2012 15:03:51 -0700 (PDT) Return-Path: Received: from mail-gg0-f181.google.com (mail-gg0-f181.google.com [209.85.161.181]) by gmr-mx.google.com with ESMTPS id u42si1178191yhg.5.2012.10.03.15.03.51 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Oct 2012 15:03:51 -0700 (PDT) Received-SPF: pass (google.com: domain of romain...@google.com designates 209.85.161.181 as permitted sender) client-ip=209.85.161.181; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of romain...@google.com designates 209.85.161.181 as permitted sender) smtp.mail=romain...@google.com; dkim=pass header...@google.com Received: by ggdk2 with SMTP id k2so1269793ggd.26 for ; Wed, 03 Oct 2012 15:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record; bh=AsHHaOT8iQSfvWGv/bGTUHjav/nvWaBNY13syKjsQHc=; b=WwkmvbM0K9aHREtNEsdDmpE42KymeFWTJMeIdt42DLZ6agStu1ktu7wohvrwftbz4A wp9uXdN6rRKH8+G2N0MD3utCadXRcwUQXqVnBVBzLPI1zo0brqLXS2AJuXn4300NGsbd oafmPMgrwwLESdHYJG49O1rSVN/GNPa/mYHpEoWkszYqhsZKypRNLdhamFPhv4ZIRzx5 y5d4tWVpMLBE7QMZaEVH+7vzZEoTR2jX1dLfE+F0M0ejTKtgLOKmqOgdZwqe1vSrc5s4 b2zoO3PDCQfG+os7jjKT3pStzwBWnFotuDNZwY8Sa/A3LNQvcpW9VwM7p2u3eXzOW20e aUnA== d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record:x-gm-message-state; bh=AsHHaOT8iQSfvWGv/bGTUHjav/nvWaBNY13syKjsQHc=; b=C1OIiJJQfDBg7IF8dS367ktRrifMsIYoDoC+WcFA5Q80ADvH2sePVucBPgnBRpFQcQ Xjerr15rrcxVA+ThvIFLDD9vcp6Oou2+zi+tpmFnefoIDYUtwDmvqU45lunptp17E8yw OOomFo81vYqrevvi4OV7CPrFYcF8kCPCMyPFs13VVsFQ6dy71QJotsBkPBuaaJ31TZVS nVPkIU4qoRH3+HYw3TAIY4e8ZijvAqYylsz0rFyWZR69mcnFzXTX6gy+SWQLqa/vmKZV fReglSCxs2qZWHPeoFYs7DBtsLTP/4PnxjhnPJE37YlerQgHc3kNVxyw8DmYfaZDXoOK pXNA== Received: by 10.236.108.202 with SMTP id q50mr3440483yhg.6.1349301831346; Wed, 03 Oct 2012 15:03:51 -0700 (PDT) MIME-Version: 1.0 Sender: romain...@google.com Received: by 10.101.5.13 with HTTP; Wed, 3 Oct 2012 15:03:30 -0700 (PDT) In-Reply-To: References: From: Romain Guy Date: Wed, 3 Oct 2012 15:03:30 -0700 Message-ID: Subject: Re: [android-developers] TextureView canvas drawing problems To: Android Developers Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-Gm-Message-State: ALoCoQkkZ6agE2qcQOFueL+/cD1dcrax7ebJ2iZBJxiPiqQP40GZhoSha1L0pDgDoeQ5pWJTNfmagc7/Xpsebj+GWCYVEda1GrpzKOl7AIPyWKHtMSne4JpYS/RwbGjA4ACkwYq+HnsvLoqMRnipDyMJUL2+4kq2VOpQOSgq55vG/tpUPTL73QG6GZtGVC4hOTVnKdBopdx3N+4YGiy2oP25pv7430J12g== Here is a fully working example of Canvas & TextureView: http://pastebin.com/J4uDgrZ8 On Wed, Oct 3, 2012 at 3:01 PM, Romain Guy wrote: > The problem is that you are calling updateTexImage() yourself. Do > *not* do this. You are interfering with TextureView, preventing it > from receiving the events that it uses to refresh the screen. > > On Tue, Oct 2, 2012 at 7:40 AM, Conrad Chapman wrote: >> Also asked in StackOverflow here >> http://stackoverflow.com/questions/12688409/android-textureview-canvas-drawing-problems >> >> I have an app that used SurfaceView to draw dynamic 2D graphs. It worked ok >> but transormations etc as we know are not supported. So I went to >> TextureView. My old code used another class/thread to do the drawing via the >> Surfaceholder.lockCanvas(); So I changed this to TextureView.lockcanvas. >> When this runs the canvas is not accelerated (the view is). It does not >> display initially but if I touch the screen it displays??? The touch is >> handled by the main activity. >> >> Obviously it works as it will display eventually but why doesn't it display >> immediately? >> >> The TextureView class implements SurfaceTextureListener as such below. >> @Override >> public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, >> int height) { >> // TODO Auto-generated method stub >> isRunning = true; >> mySurface = surface; >> mChart.setTextureSurface(surface); >> mChart.setSurfaceSize(width, height); >> mPaint.setColor(ZOOM_BUTTONS_COLOR); >> //mySurface.setOnFrameAvailableListener(frameready); >> mChart.Redraw(true); >> } >> @Override >> public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { >> // TODO Auto-generated method stub >> isRunning = false; >> return false; >> } >> this block below also workswhen manipluating the view later on (pan and >> zoom) >> public void Render(Bitmap buffmap){ >> //mCanvas = null; >> post(new Runnable() { >> public void run() { >> invalidate(); >> mySurface.updateTexImage(); >> } >> }); >> >> >> The drawing from the worker thread/class is >> protected void RenderCanvas(){ >> //mCanvas = null; >> Canvas c = null; >> //synchronized (mCanvas) { >> //mCanvas = null; >> try { >> c = mChartView.lockCanvas(null); >> >> synchronized (mCanvas) { >> c.drawBitmap(buffBitmap, 0, 0, null); >> >> } >> } finally { >> if (c != null) { >> mChartView.unlockCanvasAndPost(c); >> } >> } >> mChartView.Render(null); >> } >> >> Can I work like this? Non-GL content in a TextureView? >> Please help desperate for an answer. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscribe@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > > -- > Romain Guy > Android framework engineer > romain...@android.com -- Romain Guy Android framework engineer romain...@android.com